00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _SO_BLEND_ELEMENT_H
00022 #define _SO_BLEND_ELEMENT_H
00023
00024 #include <Inventor/SbColorRGBA.h>
00025 #include <Inventor/elements/SoElement.h>
00026 #include <Inventor/elements/SoSubElement.h>
00027 #include <Inventor/SbEnums.h>
00028
00038 class SoBlendElement : public SoElement
00039 {
00040 SO_ELEMENT_HEADER( SoBlendElement );
00041
00042 public:
00046 enum BlendFactor
00047 {
00048 ZERO = SbEnums::BLEND_ZERO,
00049 ONE = SbEnums::BLEND_ONE,
00050 SRC_COLOR = SbEnums::BLEND_SRC_COLOR,
00051 ONE_MINUS_SRC_COLOR = SbEnums::BLEND_ONE_MINUS_SRC_COLOR,
00052 DST_COLOR = SbEnums::BLEND_DST_COLOR,
00053 ONE_MINUS_DST_COLOR = SbEnums::BLEND_ONE_MINUS_DST_COLOR,
00054 SRC_ALPHA = SbEnums::BLEND_SRC_ALPHA,
00055 ONE_MINUS_SRC_ALPHA = SbEnums::BLEND_ONE_MINUS_SRC_ALPHA,
00056 DST_ALPHA = SbEnums::BLEND_DST_ALPHA,
00057 ONE_MINUS_DST_ALPHA = SbEnums::BLEND_ONE_MINUS_DST_ALPHA,
00058 CONSTANT_COLOR = SbEnums::BLEND_CONSTANT_COLOR,
00059 ONE_MINUS_CONSTANT_COLOR = SbEnums::BLEND_ONE_MINUS_CONSTANT_COLOR,
00060 CONSTANT_ALPHA = SbEnums::BLEND_CONSTANT_ALPHA,
00061 ONE_MINUS_CONSTANT_ALPHA = SbEnums::BLEND_ONE_MINUS_CONSTANT_ALPHA,
00062 SRC_ALPHA_SATURATE = SbEnums::BLEND_SRC_ALPHA_SATURATE,
00063 SRC1_COLOR = SbEnums::BLEND_SRC1_COLOR,
00064 ONE_MINUS_SRC1_COLOR = SbEnums::BLEND_ONE_MINUS_SRC1_COLOR,
00065 SRC1_ALPHA = SbEnums::BLEND_SRC1_ALPHA,
00066 ONE_MINUS_SRC1_ALPHA = SbEnums::BLEND_ONE_MINUS_SRC1_ALPHA
00067 };
00068
00072 enum BlendEquation
00073 {
00074 FUNC_ADD = SbEnums::BLEND_FUNC_ADD,
00075 FUNC_SUBTRACT = SbEnums::BLEND_FUNC_SUBTRACT,
00076 FUNC_REVERSE_SUBTRACT = SbEnums::BLEND_FUNC_REVERSE_SUBTRACT,
00077 MIN = SbEnums::BLEND_FUNC_MIN,
00078 MAX = SbEnums::BLEND_FUNC_MAX
00079 };
00080
00087 struct BlendElementParameters {
00088 BlendElementParameters()
00089 : enabled(false)
00090 , sourceRGBFactor( SoBlendElement::ONE )
00091 , destinationRGBFactor( SoBlendElement::ZERO )
00092 , sourceAlphaFactor( SoBlendElement::ONE )
00093 , destinationAlphaFactor( SoBlendElement::ZERO )
00094 , equation( SoBlendElement::FUNC_ADD )
00095 , color( SbColorRGBA( 0, 0, 0, 0 ) )
00096 {
00097 }
00098
00099 bool operator == (const BlendElementParameters& other) const;
00100 bool operator != (const BlendElementParameters& other) const;
00101
00102 bool enabled;
00103 BlendFactor sourceRGBFactor;
00104 BlendFactor destinationRGBFactor;
00105 BlendFactor sourceAlphaFactor;
00106 BlendFactor destinationAlphaFactor;
00107 BlendEquation equation;
00108 SbColorRGBA color;
00109 };
00110
00114 static void set( SoState* state, const BlendElementParameters& parameters );
00115
00119 static void setBlending( SoState* state, bool enabled );
00120
00125 static void setFunction( SoState* state, const BlendFactor source, const BlendFactor destination );
00126
00130 static void get( SoState* state, BlendElementParameters& parameter );
00131
00135 virtual void print( FILE* fp ) const;
00136
00140 virtual void push( SoState* state );
00141
00145 virtual void pop( SoState* state, const SoElement* prevTopElement );
00146
00147 private:
00148 virtual ~SoBlendElement();
00149
00151 virtual void init( SoState* state );
00152
00156 virtual void setElt( const BlendElementParameters& parameter );
00157
00161 virtual SbBool matches( const SoElement* element ) const;
00162
00166 virtual SoElement* copyMatchInfo() const;
00167
00168 private:
00169
00171 static void initClass();
00172
00174 static void exitClass();
00175
00176 private:
00178 BlendElementParameters m_parameters;
00179 };
00180
00181 #endif // _SO_BLEND_ELEMENT_H
00182