Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::BlendChunk Class Reference
[OpenGL State Handling]

State chunk to wrap pixel combination functions. See BlendChunk for a description. More...

#include <OSGBlendChunk.h>

Inheritance diagram for osg::BlendChunk:

osg::BlendChunkBase osg::StateChunk osg::StateChunkBase osg::Attachment osg::FieldContainer List of all members.

Public Types

typedef BlendChunkPtr Ptr
enum  {
  SrcFactorFieldId = Inherited::NextFieldId, DestFactorFieldId = SrcFactorFieldId + 1, EquationFieldId = DestFactorFieldId + 1, ColorFieldId = EquationFieldId + 1,
  AlphaFuncFieldId = ColorFieldId + 1, AlphaValueFieldId = AlphaFuncFieldId + 1, AlphaSrcFactorFieldId = AlphaValueFieldId + 1, AlphaDestFactorFieldId = AlphaSrcFactorFieldId + 1,
  NextFieldId = AlphaDestFactorFieldId + 1
}

Public Member Functions

Chunk Class Access
*virtual const StateChunkClassgetClass (void) const
Sync
*virtual void changed (BitVector whichField, UInt32 origin)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
State Commands
*virtual void activate (DrawActionBase *action, UInt32 index=0)
virtual void changeFrom (DrawActionBase *action, StateChunk *old, UInt32 index=0)
virtual void deactivate (DrawActionBase *action, UInt32 index=0)
virtual bool isTransparent (void) const
Comparison
*virtual Real32 switchCost (StateChunk *chunk)
virtual bool operator< (const StateChunk &other) const
virtual bool operator== (const StateChunk &other) const
virtual bool operator!= (const StateChunk &other) const
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFGLenumgetSFSrcFactor (void)
 Get the BlendChunk::_sfSrcFactor field.
SFGLenumgetSFDestFactor (void)
 Get the BlendChunk::_sfDestFactor field.
SFGLenumgetSFEquation (void)
 Get the BlendChunk::_sfEquation field.
SFColor4fgetSFColor (void)
 Get the BlendChunk::_sfColor field.
SFGLenumgetSFAlphaFunc (void)
 Get the BlendChunk::_sfAlphaFunc field.
SFReal32getSFAlphaValue (void)
 Get the BlendChunk::_sfAlphaValue field.
SFGLenumgetSFAlphaSrcFactor (void)
 Get the BlendChunk::_sfAlphaSrcFactor field.
SFGLenumgetSFAlphaDestFactor (void)
 Get the BlendChunk::_sfAlphaDestFactor field.
GLenumgetSrcFactor (void)
 Get the value of the BlendChunk::_sfSrcFactor field.
const GLenumgetSrcFactor (void) const
 Get the value of the BlendChunk::_sfSrcFactor field.
GLenumgetDestFactor (void)
 Get the value of the BlendChunk::_sfDestFactor field.
const GLenumgetDestFactor (void) const
 Get the value of the BlendChunk::_sfDestFactor field.
GLenumgetEquation (void)
 Get the value of the BlendChunk::_sfEquation field.
const GLenumgetEquation (void) const
 Get the value of the BlendChunk::_sfEquation field.
Color4fgetColor (void)
 Get the value of the BlendChunk::_sfColor field.
const Color4fgetColor (void) const
 Get the value of the BlendChunk::_sfColor field.
GLenumgetAlphaFunc (void)
 Get the value of the BlendChunk::_sfAlphaFunc field.
const GLenumgetAlphaFunc (void) const
 Get the value of the BlendChunk::_sfAlphaFunc field.
Real32getAlphaValue (void)
 Get the value of the BlendChunk::_sfAlphaValue field.
const Real32getAlphaValue (void) const
 Get the value of the BlendChunk::_sfAlphaValue field.
GLenumgetAlphaSrcFactor (void)
 Get the value of the BlendChunk::_sfAlphaSrcFactor field.
const GLenumgetAlphaSrcFactor (void) const
 Get the value of the BlendChunk::_sfAlphaSrcFactor field.
GLenumgetAlphaDestFactor (void)
 Get the value of the BlendChunk::_sfAlphaDestFactor field.
const GLenumgetAlphaDestFactor (void) const
 Get the value of the BlendChunk::_sfAlphaDestFactor field.
Field Set
*void setSrcFactor (const GLenum &value)
 Set the value of the BlendChunk::_sfSrcFactor field.
void setDestFactor (const GLenum &value)
 Set the value of the BlendChunk::_sfDestFactor field.
void setEquation (const GLenum &value)
 Set the value of the BlendChunk::_sfEquation field.
void setColor (const Color4f &value)
 Set the value of the BlendChunk::_sfColor field.
void setAlphaFunc (const GLenum &value)
 Set the value of the BlendChunk::_sfAlphaFunc field.
void setAlphaValue (const Real32 &value)
 Set the value of the BlendChunk::_sfAlphaValue field.
void setAlphaSrcFactor (const GLenum &value)
 Set the value of the BlendChunk::_sfAlphaSrcFactor field.
void setAlphaDestFactor (const GLenum &value)
 Set the value of the BlendChunk::_sfAlphaDestFactor field.
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Copy
*virtual FieldContainerPtr shallowCopy (void) const

Static Public Member Functions

Static Chunk Class Access
*static UInt32 getStaticClassId (void)
static const StateChunkClassgetStaticClass (void)
Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class
Construction
*static BlendChunkPtr create (void)
 create a new instance of the class
static BlendChunkPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype

Static Public Attributes

static const osg::BitVector SrcFactorFieldMask
static const osg::BitVector DestFactorFieldMask
static const osg::BitVector EquationFieldMask
static const osg::BitVector ColorFieldMask
static const osg::BitVector AlphaFuncFieldMask
static const osg::BitVector AlphaValueFieldMask
static const osg::BitVector AlphaSrcFactorFieldMask
static const osg::BitVector AlphaDestFactorFieldMask
static const osg::BitVector MTInfluenceMask
static const BitVector InternalFieldMask = (1 << Attachment::InternalFieldId)
static const BitVector ParentsFieldMask = (1 << Attachment::ParentsFieldId)
static const BitVector NextFieldMask

Protected Member Functions

Constructors
BlendChunk (void)
 BlendChunk (const BlendChunk &source)
Destructors
*virtual ~BlendChunk (void)
Sync
*void executeSyncImpl (BlendChunkBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)

Protected Attributes

Fields
*SFGLenum _sfSrcFactor
SFGLenum _sfDestFactor
SFGLenum _sfEquation
SFColor4f _sfColor
SFGLenum _sfAlphaFunc
SFReal32 _sfAlphaValue
SFGLenum _sfAlphaSrcFactor
SFGLenum _sfAlphaDestFactor

Private Types

typedef BlendChunkBase Inherited

Private Member Functions

void operator= (const BlendChunk &source)

Static Private Member Functions

static void initMethod (void)

Static Private Attributes

static StateChunkClass _class
OpenGL Extension Handling
*static UInt32 _extBlend
static UInt32 _extImaging
static UInt32 _extBlendSubtract
static UInt32 _extBlendMinMax
static UInt32 _extBlendLogicOp
static UInt32 _extBlendFuncSeparate
static UInt32 _funcBlendColor
static UInt32 _funcBlendEquation
static UInt32 _funcBlendEquationExt
static UInt32 _funcBlendFuncSeparateExt

Friends

class FieldContainer
class BlendChunkBase

Detailed Description

See BlendChunk for a description.

This chunk wraps glBlendFunc() (osg::BlendChunk::_sfSrcFactor, osg::BlendChunk::_sfDestFactor), glBlendEquation() or glBlendEquationEXT() (whichever is supported) (osg::BlendChunk::_sfEquation), glBlendColor() (osg::BlendChunk::_sfColor) and glAlphaFunc() (osg::BlendChunk::_sfAlphaFunc, osg::BlendChunk::_sfAlphaValue) including glEnable(GL_ALPHA_TEST).

Definition at line 55 of file OSGBlendChunk.h.


Member Typedef Documentation

typedef BlendChunkBase osg::BlendChunk::Inherited [private]
 

Reimplemented from osg::BlendChunkBase.

Definition at line 140 of file OSGBlendChunk.h.

typedef BlendChunkPtr osg::BlendChunkBase::Ptr [inherited]
 

Reimplemented from osg::StateChunkBase.

Definition at line 97 of file OSGBlendChunkBase.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
SrcFactorFieldId 
DestFactorFieldId 
EquationFieldId 
ColorFieldId 
AlphaFuncFieldId 
AlphaValueFieldId 
AlphaSrcFactorFieldId 
AlphaDestFactorFieldId 
NextFieldId 

Reimplemented from osg::Attachment.

Definition at line 99 of file OSGBlendChunkBase.h.

00100     {
00101         SrcFactorFieldId       = Inherited::NextFieldId,
00102         DestFactorFieldId      = SrcFactorFieldId       + 1,
00103         EquationFieldId        = DestFactorFieldId      + 1,
00104         ColorFieldId           = EquationFieldId        + 1,
00105         AlphaFuncFieldId       = ColorFieldId           + 1,
00106         AlphaValueFieldId      = AlphaFuncFieldId       + 1,
00107         AlphaSrcFactorFieldId  = AlphaValueFieldId      + 1,
00108         AlphaDestFactorFieldId = AlphaSrcFactorFieldId  + 1,
00109         NextFieldId            = AlphaDestFactorFieldId + 1
00110     };


Constructor & Destructor Documentation

BlendChunk::BlendChunk void   )  [protected]
 

Definition at line 111 of file OSGBlendChunk.cpp.

References _extBlend, _extBlendFuncSeparate, _extBlendLogicOp, _extBlendMinMax, _extBlendSubtract, _extImaging, _funcBlendColor, _funcBlendEquation, _funcBlendEquationExt, _funcBlendFuncSeparateExt, OSG_DLSYM_UNDERSCORE, osg::Window::registerExtension(), and osg::Window::registerFunction().

00111                            :
00112     Inherited()
00113 {
00114     _extBlend             =
00115         Window::registerExtension("GL_EXT_blend_color");
00116     _extImaging           =
00117         Window::registerExtension("GL_ARB_imaging");
00118     _extBlendSubtract     =
00119         Window::registerExtension("GL_EXT_blend_subtract");
00120     _extBlendMinMax       =
00121         Window::registerExtension("GL_EXT_blend_minmax");
00122     _extBlendLogicOp      =
00123         Window::registerExtension("GL_EXT_blend_logic_op");
00124     _extBlendFuncSeparate      =
00125         Window::registerExtension("GL_EXT_blend_func_separate");
00126     _funcBlendColor       = Window::registerFunction(
00127           OSG_DLSYM_UNDERSCORE"glBlendColorEXT",        _extBlend);
00128     _funcBlendEquation    = Window::registerFunction(
00129           OSG_DLSYM_UNDERSCORE"glBlendEquation",        _extImaging);
00130     _funcBlendEquationExt = Window::registerFunction(
00131           OSG_DLSYM_UNDERSCORE"glBlendEquationEXT",     _extBlendLogicOp);
00132     _funcBlendFuncSeparateExt = Window::registerFunction(
00133           OSG_DLSYM_UNDERSCORE"glBlendFuncSeparateEXT", _extBlendFuncSeparate);
00134 }

BlendChunk::BlendChunk const BlendChunk source  )  [protected]
 

Definition at line 136 of file OSGBlendChunk.cpp.

00136                                                :
00137     Inherited(source)
00138 {
00139 }

BlendChunk::~BlendChunk void   )  [protected, virtual]
 

Definition at line 141 of file OSGBlendChunk.cpp.

00142 {
00143 }


Member Function Documentation

const StateChunkClass * BlendChunk::getClass void   )  const [virtual]
 

Reimplemented from osg::StateChunk.

Definition at line 147 of file OSGBlendChunk.cpp.

References _class.

00148 {
00149     return &_class;
00150 }

UInt32 osg::BlendChunk::getStaticClassId void   )  [inline, static]
 

Reimplemented from osg::StateChunk.

Definition at line 46 of file OSGBlendChunk.inl.

References osg::StateChunkClass::getId(), and getStaticClass().

00047 {
00048     return getStaticClass()->getId();
00049 }

const StateChunkClass * osg::BlendChunk::getStaticClass void   )  [inline, static]
 

Reimplemented from osg::StateChunk.

Definition at line 52 of file OSGBlendChunk.inl.

References _class.

Referenced by getStaticClassId().

00053 {
00054     return &BlendChunk::_class;
00055 }

void BlendChunk::changed BitVector  whichField,
UInt32  origin
[virtual]
 

Reimplemented from osg::StateChunk.

Definition at line 154 of file OSGBlendChunk.cpp.

References osg::StateChunk::changed().

00155 {
00156     Inherited::changed(whichField, origin);
00157 }

void BlendChunk::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

Reimplemented from osg::StateChunk.

Definition at line 161 of file OSGBlendChunk.cpp.

References SLOG.

00163 {
00164     SLOG << "Dump BlendChunk NI" << std::endl;
00165 }

void BlendChunk::activate DrawActionBase action,
UInt32  index = 0
[virtual]
 

Activate the chunk, i.e. set the OpenGl state covered by the chunk which is different from the default state to the given state.

Reimplemented from osg::StateChunk.

Definition at line 169 of file OSGBlendChunk.cpp.

References _extBlend, _extBlendFuncSeparate, _extBlendLogicOp, _extBlendMinMax, _extBlendSubtract, _extImaging, _funcBlendColor, _funcBlendEquation, _funcBlendEquationExt, _funcBlendFuncSeparateExt, osg::BlendChunkBase::_sfAlphaDestFactor, osg::BlendChunkBase::_sfAlphaFunc, osg::BlendChunkBase::_sfAlphaSrcFactor, osg::BlendChunkBase::_sfAlphaValue, osg::BlendChunkBase::_sfColor, osg::BlendChunkBase::_sfDestFactor, osg::BlendChunkBase::_sfEquation, osg::BlendChunkBase::_sfSrcFactor, FWARNING, osg::Window::getFunction(), osg::SField< FieldTypeT, fieldNameSpace >::getValue(), osg::DrawActionBase::getWindow(), GLenum, osg::Window::hasExtension(), OSG_APIENTRY, and OSG_GL_UNUSED.

00170 {
00171     GLenum src   = _sfSrcFactor.getValue();
00172     GLenum dest  = _sfDestFactor.getValue();
00173     GLenum asrc  = _sfAlphaSrcFactor.getValue();
00174     GLenum adest = _sfAlphaDestFactor.getValue();
00175 
00176     if(src != GL_ONE || dest != GL_ZERO ||
00177        (asrc  != OSG_GL_UNUSED && asrc  != GL_ONE) || 
00178        (adest != OSG_GL_UNUSED && adest != GL_ZERO)
00179       )
00180     {
00181         if(asrc != OSG_GL_UNUSED || adest != OSG_GL_UNUSED)
00182         {
00183             if(asrc == OSG_GL_UNUSED || adest == OSG_GL_UNUSED)
00184             {
00185                 FWARNING(("BlendChunk::activate: only one of alpha src and"
00186                           " alpha dest is set. Ignored.\n"));
00187                 glBlendFunc(src, dest);
00188             }
00189             else if(action->getWindow()->hasExtension(_extBlendFuncSeparate))
00190             {
00191                 // get "glBlendFuncSeparate" function pointer
00192                 void (OSG_APIENTRY* blendfuncsep)(GLenum,GLenum,GLenum,GLenum) =
00193                    (void (OSG_APIENTRY*)(GLenum,GLenum,GLenum,GLenum))
00194                    action->getWindow()->getFunction(_funcBlendFuncSeparateExt);
00195 
00196                 blendfuncsep(src, dest, asrc, adest);
00197             }
00198             else
00199             {
00200                 FWARNING(("BlendChunk::activate: Window %p doesn't "
00201                           "support EXT_blend_func_separate, ignored.\n"));
00202                 glBlendFunc(src, dest);
00203             }
00204         }
00205         else
00206             glBlendFunc(src, dest);
00207 
00208 #if GL_EXT_blend_color
00209         // This is not nice, but efficient
00210         // As the OpenGL constants are fixed it should be safe
00211         if((src   >= GL_CONSTANT_COLOR_EXT && 
00212             src   <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00213            (dest  >= GL_CONSTANT_COLOR_EXT && 
00214             dest  <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00215            (asrc  >= GL_CONSTANT_COLOR_EXT && 
00216             asrc  <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00217            (adest >= GL_CONSTANT_COLOR_EXT && 
00218             adest <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT )
00219           )
00220         {
00221             if(action->getWindow()->hasExtension(_extBlend))
00222             {
00223                 // get "glBlendColorEXT" function pointer
00224                 void (OSG_APIENTRY*blendcolor)(GLclampf red,GLclampf green,GLclampf blue,
00225                      GLclampf alpha ) =
00226                     (void (OSG_APIENTRY*)(GLclampf red,GLclampf green,GLclampf blue,
00227                      GLclampf alpha))
00228                     action->getWindow()->getFunction(_funcBlendColor);
00229 
00230                  blendcolor(_sfColor.getValue().red(),
00231                             _sfColor.getValue().green(),
00232                             _sfColor.getValue().blue(),
00233                             _sfColor.getValue().alpha());
00234             }
00235         }
00236 #endif
00237         glEnable(GL_BLEND);
00238     }
00239 
00240     if(_sfEquation.getValue() != GL_NONE)
00241     {
00242 #if defined(GL_ARB_imaging)
00243         if(action->getWindow()->hasExtension(_extImaging))
00244         {
00245             // get "glBlendEquation" function pointer
00246             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00247                 (void (OSG_APIENTRY*)(GLenum mode))
00248                 action->getWindow()->getFunction(_funcBlendEquation);
00249 
00250              blendeq(_sfEquation.getValue());
00251         }
00252 
00253 #elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || \
00254     defined(GL_EXT_blend_logic_op)
00255         if(action->getWindow()->hasExtension(_extBlendSubtract) ||
00256            action->getWindow()->hasExtension(_extBlendMinMax) ||
00257            action->getWindow()->hasExtension(_extBlendLogicOp))
00258         {
00259             // get "glBlendEquationEXT" function pointer
00260             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00261                 (void (OSG_APIENTRY*)(GLenum mode))
00262                 action->getWindow()->getFunction(_funcBlendEquationExt);
00263 
00264              blendeq(_sfEquation.getValue());
00265         }
00266 #endif
00267     }
00268     
00269     if(_sfAlphaFunc.getValue() != GL_NONE)
00270     {
00271         glAlphaFunc(_sfAlphaFunc.getValue(), _sfAlphaValue.getValue());
00272         glEnable(GL_ALPHA_TEST);
00273     }
00274 }

void BlendChunk::changeFrom DrawActionBase action,
StateChunk old_chunk,
UInt32  index = 0
[virtual]
 

Change from an old chunk of the same type to this chunk. Note that in general no type checking is done, make sure to use this on a legal combination of chunks!

Reimplemented from osg::StateChunk.

Definition at line 276 of file OSGBlendChunk.cpp.

References _extBlend, _extBlendFuncSeparate, _extBlendLogicOp, _extBlendMinMax, _extBlendSubtract, _extImaging, _funcBlendColor, _funcBlendEquation, _funcBlendEquationExt, _funcBlendFuncSeparateExt, osg::BlendChunkBase::_sfAlphaDestFactor, osg::BlendChunkBase::_sfAlphaFunc, osg::BlendChunkBase::_sfAlphaSrcFactor, osg::BlendChunkBase::_sfAlphaValue, osg::BlendChunkBase::_sfColor, osg::BlendChunkBase::_sfDestFactor, osg::BlendChunkBase::_sfEquation, osg::BlendChunkBase::_sfSrcFactor, FWARNING, osg::Window::getFunction(), osg::SField< FieldTypeT, fieldNameSpace >::getValue(), osg::DrawActionBase::getWindow(), GLenum, osg::Window::hasExtension(), OSG_APIENTRY, and OSG_GL_UNUSED.

00279 {
00280     BlendChunk *old = dynamic_cast<BlendChunk *>(old_chunk);
00281 
00282     GLenum src    = _sfSrcFactor.getValue();
00283     GLenum dest   = _sfDestFactor.getValue();
00284     GLenum osrc   = old->_sfSrcFactor.getValue();
00285     GLenum odest  = old->_sfDestFactor.getValue();
00286     GLenum asrc   = _sfAlphaSrcFactor.getValue();
00287     GLenum adest  = _sfAlphaDestFactor.getValue();
00288     GLenum oasrc  = old->_sfAlphaSrcFactor.getValue();
00289     GLenum oadest = old->_sfAlphaDestFactor.getValue();
00290 
00291     if(src != GL_ONE || dest != GL_ZERO ||
00292        (asrc  != OSG_GL_UNUSED && asrc  != GL_ONE) || 
00293        (adest != OSG_GL_UNUSED && adest != GL_ZERO)
00294       )
00295     {
00296         if(asrc != OSG_GL_UNUSED || adest != OSG_GL_UNUSED)
00297         {
00298             if(asrc == OSG_GL_UNUSED || adest == OSG_GL_UNUSED)
00299             {
00300                 FWARNING(("BlendChunk::changeFrom: only one of alpha src and"
00301                           " alpha dest is set. Ignored.\n"));
00302                 glBlendFunc(src, dest);
00303             }
00304             else if(action->getWindow()->hasExtension(_extBlendFuncSeparate))
00305             {
00306                 if(osrc  != src  || odest  != dest ||
00307                    oasrc != asrc || oadest != adest 
00308                    )
00309                 {
00310                     // get "glBlendFuncSeparate" function pointer
00311                     void (OSG_APIENTRY* blendfuncsep)(GLenum,GLenum,
00312                                                       GLenum,GLenum) =
00313                        (void (OSG_APIENTRY*)(GLenum,GLenum,GLenum,GLenum))
00314                        action->getWindow()->getFunction(
00315                                 _funcBlendFuncSeparateExt);
00316 
00317                     blendfuncsep(src, dest, asrc, adest);
00318                 }
00319             }
00320             else
00321             {
00322                 FWARNING(("BlendChunk::changeFrom: Window %p doesn't "
00323                           "support EXT_blend_func_separate, ignored.\n"));
00324                 glBlendFunc(src, dest);
00325             }
00326         }
00327         else if(osrc != src || odest != dest)
00328             glBlendFunc(src, dest);
00329 
00330 #if GL_EXT_blend_color
00331         // This is not nice, but efficient
00332         // As the OpenGL constants are fixed it should be safe
00333         if((src   >= GL_CONSTANT_COLOR_EXT && 
00334             src   <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00335            (dest  >= GL_CONSTANT_COLOR_EXT && 
00336             dest  <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00337            (asrc  >= GL_CONSTANT_COLOR_EXT && 
00338             asrc  <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT ) ||
00339            (adest >= GL_CONSTANT_COLOR_EXT && 
00340             adest <= GL_ONE_MINUS_CONSTANT_ALPHA_EXT )
00341           )
00342         {
00343             if ( action->getWindow()->hasExtension(_extBlend ))
00344             {
00345                 // get "glBlendColorEXT" function pointer
00346                 void (OSG_APIENTRY*blendcolor)(GLclampf red,GLclampf green,GLclampf blue,
00347                      GLclampf alpha ) =
00348                     (void (OSG_APIENTRY*)(GLclampf red,GLclampf green,GLclampf blue,
00349                      GLclampf alpha))
00350                     action->getWindow()->getFunction( _funcBlendColor );
00351 
00352                  blendcolor(_sfColor.getValue().red(),
00353                             _sfColor.getValue().green(),
00354                             _sfColor.getValue().blue(),
00355                             _sfColor.getValue().alpha());
00356             }
00357         }
00358 #endif
00359         if(osrc == GL_ONE && odest == GL_ZERO)
00360             glEnable(GL_BLEND);
00361     }
00362     else
00363     {
00364         if(osrc != GL_ONE || odest != GL_ZERO || 
00365            (oasrc  != OSG_GL_UNUSED && oasrc  != GL_ONE) || 
00366            (oadest != OSG_GL_UNUSED && oadest != GL_ZERO)
00367           )
00368             glDisable(GL_BLEND);
00369     }
00370 
00371     if(_sfEquation.getValue() != old->_sfEquation.getValue())
00372     {
00373 #if defined(GL_ARB_imaging)
00374         if(action->getWindow()->hasExtension(_extImaging))
00375         {
00376             // get "glBlendEquation" function pointer
00377             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00378                 (void (OSG_APIENTRY*)(GLenum mode))
00379                 action->getWindow()->getFunction(_funcBlendEquation);
00380 
00381              blendeq(_sfEquation.getValue());
00382         }
00383 
00384 #elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || \
00385     defined(GL_EXT_blend_logic_op)
00386         if(action->getWindow()->hasExtension(_extBlendSubtract) ||
00387            action->getWindow()->hasExtension(_extBlendMinMax) ||
00388            action->getWindow()->hasExtension(_extBlendLogicOp))
00389         {
00390             // get "glBlendEquationEXT" function pointer
00391             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00392                 (void (OSG_APIENTRY*)(GLenum mode))
00393                 action->getWindow()->getFunction(_funcBlendEquationExt);
00394 
00395              blendeq(_sfEquation.getValue());
00396         }
00397 #endif
00398     }
00399     
00400     if(_sfAlphaFunc.getValue() != GL_NONE)
00401     {
00402         if(old->_sfAlphaFunc.getValue()  != _sfAlphaFunc.getValue() ||
00403            old->_sfAlphaValue.getValue() != _sfAlphaValue.getValue())
00404             glAlphaFunc(_sfAlphaFunc.getValue(), _sfAlphaValue.getValue());
00405         
00406         if(old->_sfAlphaFunc.getValue() == GL_NONE)
00407             glEnable(GL_ALPHA_TEST);
00408     }
00409     else
00410     {
00411         if(old->_sfAlphaFunc.getValue() != GL_NONE)
00412             glDisable(GL_ALPHA_TEST);        
00413     }
00414     
00415 }

void BlendChunk::deactivate DrawActionBase action,
UInt32  index = 0
[virtual]
 

Deactivate the chunk, i.e. set the OpenGl state covered by the chunk which is different from the default state to the default state.

Reimplemented from osg::StateChunk.

Definition at line 417 of file OSGBlendChunk.cpp.

References _extBlendLogicOp, _extBlendMinMax, _extBlendSubtract, _extImaging, _funcBlendEquation, _funcBlendEquationExt, osg::BlendChunkBase::_sfAlphaDestFactor, osg::BlendChunkBase::_sfAlphaFunc, osg::BlendChunkBase::_sfAlphaSrcFactor, osg::BlendChunkBase::_sfDestFactor, osg::BlendChunkBase::_sfEquation, osg::BlendChunkBase::_sfSrcFactor, osg::Window::getFunction(), osg::SField< FieldTypeT, fieldNameSpace >::getValue(), osg::DrawActionBase::getWindow(), GL_FUNC_ADD, GLenum, osg::Window::hasExtension(), OSG_APIENTRY, and OSG_GL_UNUSED.

00418 {
00419     GLenum src    = _sfSrcFactor.getValue();
00420     GLenum dest   = _sfDestFactor.getValue();
00421     GLenum asrc   = _sfAlphaSrcFactor.getValue();
00422     GLenum adest  = _sfAlphaDestFactor.getValue();
00423 
00424     if(src != GL_ONE || dest != GL_ZERO ||
00425        (asrc  != OSG_GL_UNUSED && asrc  != GL_ONE) || 
00426        (adest != OSG_GL_UNUSED && adest != GL_ZERO)
00427       )
00428     {
00429         glDisable(GL_BLEND);
00430     }
00431 
00432     if(_sfEquation.getValue() != GL_NONE)
00433     {
00434 #if defined(GL_ARB_imaging)
00435         if(action->getWindow()->hasExtension(_extImaging))
00436         {
00437             // get "glBlendEquation" function pointer
00438             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00439                 (void (OSG_APIENTRY*)(GLenum mode))
00440                 action->getWindow()->getFunction(_funcBlendEquation);
00441 
00442              blendeq(GL_FUNC_ADD);
00443         }
00444 
00445 #elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || \
00446     defined(GL_EXT_blend_logic_op)
00447         if(action->getWindow()->hasExtension(_extBlendSubtract) ||
00448            action->getWindow()->hasExtension(_extBlendMinMax) ||
00449            action->getWindow()->hasExtension(_extBlendLogicOp))
00450         {
00451             // get "glBlendEquationEXT" function pointer
00452             void (OSG_APIENTRY* blendeq)(GLenum mode) =
00453                 (void (OSG_APIENTRY*)(GLenum mode))
00454                 action->getWindow()->getFunction(_funcBlendEquationExt);
00455 
00456              blendeq(GL_FUNC_ADD_EXT);
00457         }
00458 #endif
00459     }
00460     
00461     if(_sfAlphaFunc.getValue() != GL_NONE)
00462     {
00463         glDisable(GL_ALPHA_TEST);
00464     }
00465 }

bool BlendChunk::isTransparent void   )  const [virtual]
 

Check if the chunk is transparent, i.e. needs to be rendered after the opaque objects.

Reimplemented from osg::StateChunk.

Definition at line 469 of file OSGBlendChunk.cpp.

References osg::BlendChunkBase::getDestFactor().

00470 {
00471     return getDestFactor() != GL_ZERO;
00472 }

Real32 BlendChunk::switchCost StateChunk chunk  )  [virtual]
 

Calculate how expensive it is to switch from one instance of the chunk class to another. In most cases not implemented yet, will return 0.

Reimplemented from osg::StateChunk.

Definition at line 474 of file OSGBlendChunk.cpp.

00475 {
00476     return 0;
00477 }

bool BlendChunk::operator<