Open Inventor Reference
SoGLLazyElement Class Reference

Element that manages the GL state for the SoLazyElement. More...

#include <Inventor/elements/SoGLLazyElement.h>

Inheritance diagram for SoGLLazyElement:
SoLazyElement SoElement

Classes

struct  GLLazyState
 provide a public typedef for GLLazyState, so that GLRenderCache can use it: More...
 

Public Member Functions

virtual void init (SoState *state)
 Initializes element. More...
 
virtual void push (SoState *state)
 Override push() and pop() methods to maintain GL state. More...
 
virtual void pop (SoState *state, const SoElement *prevTopElement)
 
void sendDiffuseByIndex (int index) const
 Send diffuse color and transparency, by index Included for compatibility with SoMaterialBundle To be used by a shape to send additional colors after first send() Should NEVER be the first send of a shape!
More...
 
void reset (SoState *state, uint32_t bitmask) const
 Destroy knowledge of GL state. More...
 
void send (const SoState *state, uint32_t mask) const
 Sends indicated component(s) to GL: Only sends if value is not already in GL. More...
 
virtual bool matches (const SoElement *) const
 note: matches, copyMatchinfo not used by this element. More...
 
virtual SoElementcopyMatchInfo () const
 Create a copy that we can put in a cache used list and call matches() on later. More...
 
bool lazyMatches (uint32_t checkGLFlag, uint32_t checkIVFlag, const SoGLLazyElement *eltInState)
 Replace matches() for this element: matches "this" element GL or IV state with values in eltInState. More...
 
SoGLLazyElementcopyLazyMatchInfo (SoState *state)
 Replaces copyMatchInfo for this element: makes a GLLazyElement with some initialization. More...
 
void getCopyGL (SoGLLazyElement *cacheLazyElement, SoGLLazyElement::GLLazyState &cacheGLState)
 method that makes a copy of GL state at cache close(). More...
 
void copyBackGL (SoGLLazyElement *cacheLazyElement, SoGLLazyElement::GLLazyState &cacheGLState)
 method that copies GL state back into "this" element after cache has been called. More...
 
void sendVPPacked (SoState *state, const unsigned char *pcolor)
 Send a packed color (not in state). More...
 
virtual ~SoGLLazyElement ()
 Note: destructor is public, so cache can delete its copy. More...
 
void mergeCacheInfo (SoGLRenderCache *childCache, SoGLRenderCache *parentCache, uint32_t doSendFlag, uint32_t checkIVFlag, uint32_t checkGLFlag)
 
void updateColorVBO (SoState *state, SoVBO *vbo)
 Update the passed VBO with the packed colors if the diffuse/transparency node ids do not match. More...
 
- Public Member Functions inherited from SoLazyElement
int32_t getNumDiffuse () const
 Methods to inquire about current colors: More...
 
int32_t getNumTransparencies () const
 
bool isPacked () const
 
bool isTransparent () const
 
virtual void print (FILE *fp) const
 Prints element (for debugging) More...
 
const uint32_tgetPackedPointer () const
 Following SoINTERNAL get() methods do NOT cause cache dependency, should only be invoked by nodes that use the reallySend method on SoGLLazyElement to establish correct cache dependencies by tracking what was actually sent to GL. More...
 
const SbColorgetDiffusePointer () const
 
const float * getTransparencyPointer () const
 
- Public Member Functions inherited from SoElement
SoType getTypeId () const
 Returns type identifier for element instance. More...
 
int getStackIndex () const
 Returns the stack index for an element instance. More...
 
void setDepth (int dpth)
 Sets stuff in an element instance. More...
 
void setNext (SoElement *nxt)
 
void setNextInStack (SoElement *nxt)
 
void setNextFree (SoElement *nxt)
 
int getDepth () const
 Returns stuff from element instance. More...
 
SoElementgetNext () const
 
virtual ~SoElement ()
 Destructor. More...
 

Static Public Member Functions

static void sendAllMaterial (SoState *state)
 Static sends, always send top-of-stack. Intended for extender use.
More...
 
static void sendNoMaterial (SoState *state)
 
static void sendOnlyDiffuseColor (SoState *state)
 
static SoGLLazyElementgetInstance (const SoState *state)
 Return the top (current) instance of the element in the state Note it does NOT cause cache dependency! It also casts away the const. More...
 
static void initClass ()
 Initializes the SoGLLazyElement class. More...
 
- Static Public Member Functions inherited from SoLazyElement
static void setDiffuse (SoState *state, SoNode *node, int32_t numColors, const SbColor *colors, SoColorPacker *cPacker)
 static set methods: More...
 
static void setTransparency (SoState *state, SoNode *node, int32_t numTransp, const float *transp, SoColorPacker *cPacker)
 
static void setPacked (SoState *state, SoNode *node, int32_t numColors, const uint32_t *colors)
 
static void setAmbient (SoState *state, const SbColor *color)
 
static void setEmissive (SoState *state, const SbColor *color)
 
static void setSpecular (SoState *state, const SbColor *color)
 
static void setShininess (SoState *state, float value)
 
static void setColorMaterial (SoState *state, bool value)
 
static void setBlending (SoState *state, bool value)
 
static void setOverrideBlending (SoState *state, bool flag)
 This method allows to enable overriding of the blending mode. More...
 
static void setLightModel (SoState *state, const int32_t model)
 
static const SbColorgetDiffuse (SoState *state, int index)
 get() methods get value from Inventor state. More...
 
static float getTransparency (SoState *, int index)
 
static const uint32_tgetPackedColors (SoState *)
 
static const SbColorgetAmbient (SoState *)
 
static const SbColorgetEmissive (SoState *)
 
static const SbColorgetSpecular (SoState *)
 
static float getShininess (SoState *)
 
static bool getColorMaterial (SoState *)
 
static bool getBlending (SoState *)
 
static int32_t getLightModel (SoState *)
 
static SoLazyElementgetInstance (SoState *state)
 Returns the top (current) instance of the element in the state Note that the cache dependencies associated with this element are managed differently from other elements: this replaces the SoElement::getConstElement that is used by standard elements, but which causes cache dependency. More...
 
static SbColor getDefaultDiffuse ()
 Specify inventor defaults for colors, etc. More...
 
static SbColor getDefaultAmbient ()
 
static SbColor getDefaultSpecular ()
 
static SbColor getDefaultEmissive ()
 
static float getDefaultShininess ()
 
static uint32_t getDefaultPacked ()
 
static float getDefaultTransparency ()
 
static int32_t getDefaultLightModel ()
 
static void setMaterials (SoState *state, SoNode *node, uint32_t bitmask, SoColorPacker *cPacker, const SoMFColor &diffuse, const SoMFFloat &transp, const SoMFColor &ambient, const SoMFColor &emissive, const SoMFColor &specular, const SoMFFloat &shininess)
 set method for use in SoMaterial nodes: More...
 
static SoLazyElementgetWInstance (SoState *state)
 Get a Writable instance, so will force a push if needed: More...
 
static void initClass ()
 Initializes the SoLazyElement class. More...
 
static void setTransparencyType (SoState *state, int32_t type)
 set method for transparency type is SoINTERNAL, because it should only be invoked by SoGLRenderAction More...
 
static void setDrawElementsCallback (SoState *state, SoDrawElementsCallback *cb, void *userData)
 Set a callback for drawElements(). More...
 
static void setUseVertexAttributes (SoState *state, bool flag)
 Sets if vertex attributes should be used instead of old style glVertexPointer/glNormalPointer etc. More...
 
static bool shouldUseVertexAttributes (SoState *state)
 Returns if vertex attributes should be used instead of old style glVertexPointer/glNormalPointer etc. More...
 
static void setDrawArraysCallback (SoState *state, SoDrawArraysCallback *cb, void *userData)
 Set a callback for drawElements(). More...
 
static void drawArrays (SoState *state, GLenum mode, GLint first, GLsizei count)
 Draws the given data using glDrawArrays() or via a callback if one has been set. More...
 
static void drawElements (SoState *state, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
 Draws the given data using glDrawElements() or via a callback if one has been set. More...
 
- Static Public Member Functions inherited from SoElement
static SoType getClassTypeId ()
 Returns type identifier for SoElement class. More...
 
static void initElements ()
 Initialize ALL Inventor element classes. More...
 
static void initClass ()
 Initializes the SoElement class. More...
 
static int getNumStackIndices ()
 Returns the number of stack indices allocated. More...
 
static SoType getIdFromStackIndex (int stackIndex)
 Returns the id for the element with the given stack index. More...
 

Additional Inherited Members

- Public Types inherited from SoLazyElement
enum  cases {
  LIGHT_MODEL_CASE = 0 , COLOR_MATERIAL_CASE = 1 , DIFFUSE_CASE = 2 , AMBIENT_CASE = 3 ,
  EMISSIVE_CASE = 4 , SPECULAR_CASE = 5 , SHININESS_CASE = 6 , BLENDING_CASE = 7 ,
  TRANSPARENCY_CASE = 8
}
 Following masks and cases define the components of the lazy element. More...
 
enum  masks {
  LIGHT_MODEL_MASK = 1<<LIGHT_MODEL_CASE , COLOR_MATERIAL_MASK = 1<<COLOR_MATERIAL_CASE , DIFFUSE_MASK = 1<<DIFFUSE_CASE , AMBIENT_MASK = 1<<AMBIENT_CASE ,
  EMISSIVE_MASK = 1<<EMISSIVE_CASE , SPECULAR_MASK = 1<<SPECULAR_CASE , SHININESS_MASK = 1<<SHININESS_CASE , TRANSPARENCY_MASK = 1<<TRANSPARENCY_CASE ,
  BLENDING_MASK = 1<<BLENDING_CASE , ALL_MASK = (1<<SO_LAZY_NUM_COMPONENTS)-1
}
 
enum  LightModel { BASE_COLOR = 0 , PHONG = 1 }
 Enum values to be used in setting/getting light model: More...
 
enum  VertexAttribs { ATTRIB_VERTEX = 0 , ATTRIB_NORMAL = 1 , ATTRIB_COLOR = 2 , ATTRIB_TEXCOORD = 3 }
 
enum  internalMasks {
  OTHER_COLOR_MASK = AMBIENT_MASK|EMISSIVE_MASK|SPECULAR_MASK|SHININESS_MASK , ALL_COLOR_MASK = OTHER_COLOR_MASK|DIFFUSE_MASK , NO_COLOR_MASK = ALL_MASK & (~ALL_COLOR_MASK) , ALL_BUT_DIFFUSE_MASK = ALL_MASK &(~ DIFFUSE_MASK) ,
  DIFFUSE_ONLY_MASK = ALL_MASK &(~ OTHER_COLOR_MASK)
}
 
- Protected Member Functions inherited from SoLazyElement
virtual ~SoLazyElement ()
 
- Protected Member Functions inherited from SoElement
 SoElement ()
 Constructor; use typeId.createInstance to create elements. More...
 
void capture (SoState *state) const
 Does whatever is necessary in state to capture this element for caching purposes. More...
 
virtual void captureThis (SoState *state) const
 Really captures this element, once it has been determined that a cache is open to capture it. More...
 
void setTypeId (SoType id)
 Sets typeId in instance. More...
 
void setStackIndex (int index)
 Sets stackIndex in instance. More...
 
SoElementgetNextInStack () const
 Returns next instance in specific element stack. More...
 
SoElementgetNextFree () const
 Returns next free element in a specific element stack. More...
 
- Static Protected Member Functions inherited from SoLazyElement
static int getNumPatterns ()
 Returns number of transparency levels supported with stipple patterns. More...
 
- Static Protected Member Functions inherited from SoElement
static SoElementgetElement (SoState *state, int stackIndex)
 Returns an instance of an element from the stack with the given index in the given state. More...
 
static const SoElementgetConstElement (SoState *state, int stackIndex)
 Returns a read-only pointer to the top instance in the given element stack. More...
 
static int createStackIndex (SoType id)
 Creates and returns a new stack index. More...
 
- Protected Attributes inherited from SoLazyElement
ivStateStruct ivState
 
uint32_t invalidBits
 This is more convenient here, but might logically be kept with SoGLLazyElement. More...
 
- Static Protected Attributes inherited from SoLazyElement
static SbColordefaultDiffuseColor
 store pointers to the default color, transp so that we can set point to them if no other color or transp has been set. More...
 
static float * defaultTransparency
 
static uint32_tdefaultPackedColor
 
- Static Protected Attributes inherited from SoElement
static int classStackIndex
 Stack index for SoElement class. More...
 

Detailed Description

Note that this class relies on SoLazyElement to store the inventor color(s), etc. in the instance. This element keeps GL shadow copies of colors

Definition at line 76 of file SoGLLazyElement.h.

Constructor & Destructor Documentation

◆ ~SoGLLazyElement()

virtual SoGLLazyElement::~SoGLLazyElement ( )
virtual

Member Function Documentation

◆ copyBackGL()

void SoGLLazyElement::copyBackGL ( SoGLLazyElement cacheLazyElement,
SoGLLazyElement::GLLazyState cacheGLState 
)
inline

only copies if bit in bitmask is set. also sets invalidBits to FALSE for these components.

Definition at line 178 of file SoGLLazyElement.h.

◆ copyLazyMatchInfo()

SoGLLazyElement* SoGLLazyElement::copyLazyMatchInfo ( SoState state)

also initializes cacheSetBits to zero.

◆ copyMatchInfo()

virtual SoElement* SoGLLazyElement::copyMatchInfo ( ) const
inlinevirtual

Reimplemented from SoLazyElement.

Definition at line 136 of file SoGLLazyElement.h.

◆ getCopyGL()

void SoGLLazyElement::getCopyGL ( SoGLLazyElement cacheLazyElement,
SoGLLazyElement::GLLazyState cacheGLState 
)

goes from state="this" to cacheGLState only copies if bitmask (GLSend of cache lazy element) is set.

◆ getInstance()

static SoGLLazyElement* SoGLLazyElement::getInstance ( const SoState state)
inlinestatic


Definition at line 116 of file SoGLLazyElement.h.

References SoState::getConstElement().

◆ init()

virtual void SoGLLazyElement::init ( SoState state)
virtual

Reimplemented from SoLazyElement.

◆ initClass()

static void SoGLLazyElement::initClass ( )
static

◆ lazyMatches()

bool SoGLLazyElement::lazyMatches ( uint32_t  checkGLFlag,
uint32_t  checkIVFlag,
const SoGLLazyElement eltInState 
)
inline

◆ matches()

virtual bool SoGLLazyElement::matches ( const SoElement ) const
inlinevirtual

they are replaced by lazyMatches, copyLazyMatchInfo

Reimplemented from SoLazyElement.

Definition at line 134 of file SoGLLazyElement.h.

References FALSE.

◆ mergeCacheInfo()

void SoGLLazyElement::mergeCacheInfo ( SoGLRenderCache childCache,
SoGLRenderCache parentCache,
uint32_t  doSendFlag,
uint32_t  checkIVFlag,
uint32_t  checkGLFlag 
)

◆ pop()

virtual void SoGLLazyElement::pop ( SoState state,
const SoElement prevTopElement 
)
virtual

Reimplemented from SoElement.

◆ push()

virtual void SoGLLazyElement::push ( SoState state)
virtual

Reimplemented from SoLazyElement.

◆ reset()

void SoGLLazyElement::reset ( SoState state,
uint32_t  bitmask 
) const

◆ send()

void SoGLLazyElement::send ( const SoState state,
uint32_t  mask 
) const
inline

note: has side effects, cannot really be const. however will not necessarily cause cache dependency.

Definition at line 128 of file SoGLLazyElement.h.

References SoState::isCacheOpen().

◆ sendAllMaterial()

static void SoGLLazyElement::sendAllMaterial ( SoState state)
inlinestatic

◆ sendDiffuseByIndex()

void SoGLLazyElement::sendDiffuseByIndex ( int  index) const

◆ sendNoMaterial()

static void SoGLLazyElement::sendNoMaterial ( SoState state)
inlinestatic

◆ sendOnlyDiffuseColor()

static void SoGLLazyElement::sendOnlyDiffuseColor ( SoState state)
inlinestatic

◆ sendVPPacked()

void SoGLLazyElement::sendVPPacked ( SoState state,
const unsigned char *  pcolor 
)

Send transparency as stipple if necessary.

◆ updateColorVBO()

void SoGLLazyElement::updateColorVBO ( SoState state,
SoVBO vbo 
)

The documentation for this class was generated from the following file: