Open Inventor Reference
SoLazyElement Class Reference

Element that manages several properties such as colors, that need to be lazily tracked by GL. More...

#include <Inventor/elements/SoLazyElement.h>

Inheritance diagram for SoLazyElement:
SoElement SoGLLazyElement

Classes

struct  ivStateStruct
 Struct to hold the inventor state: More...
 

Public Types

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)
}
 

Public Member Functions

virtual void init (SoState *state)
 Initializes element.
 
int32_t getNumDiffuse () const
 Methods to inquire about current colors:
 
int32_t getNumTransparencies () const
 
bool isPacked () const
 
bool isTransparent () const
 
virtual void push (SoState *state)
 push (for non-GL elements)
 
virtual bool matches (const SoElement *) const
 note: matches, copyMatchinfo not used by this element.
 
virtual SoElementcopyMatchInfo () const
 Create a copy that we can put in a cache used list and call matches() on later.
 
virtual void print (FILE *fp) const
 Prints element (for debugging)
 
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.
 
const SbColorgetDiffusePointer () const
 
const float * getTransparencyPointer () const
 
- Public Member Functions inherited from SoElement
virtual void init (SoState *state)
 Initializes element.
 
virtual void push (SoState *state)
 Pushes/pops element.
 
virtual void pop (SoState *state, const SoElement *prevTopElement)
 
virtual void print (FILE *fp) const
 Prints element (for debugging)
 
virtual bool matches (const SoElement *elt) const =0
 Returns TRUE if the element matches another element (of the same class, presumably) with respect to cache validity.
 
virtual SoElementcopyMatchInfo () const =0
 Create a copy that we can put in a cache used list and call matches() on later.
 
SoType getTypeId () const
 Returns type identifier for element instance.
 
int getStackIndex () const
 Returns the stack index for an element instance.
 
void setDepth (int dpth)
 Sets stuff in an element instance.
 
void setNext (SoElement *nxt)
 
void setNextInStack (SoElement *nxt)
 
void setNextFree (SoElement *nxt)
 
int getDepth () const
 Returns stuff from element instance.
 
SoElementgetNext () const
 
virtual ~SoElement ()
 Destructor.
 

Static Public Member Functions

static void setDiffuse (SoState *state, SoNode *node, int32_t numColors, const SbColor *colors, SoColorPacker *cPacker)
 static set methods:
 
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.
 
static void setLightModel (SoState *state, const int32_t model)
 
static const SbColorgetDiffuse (SoState *state, int index)
 get() methods get value from Inventor state.
 
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.
 
static SbColor getDefaultDiffuse ()
 Specify inventor defaults for colors, etc.
 
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:
 
static SoLazyElementgetWInstance (SoState *state)
 Get a Writable instance, so will force a push if needed:
 
static void initClass ()
 Initializes the SoLazyElement class.
 
static void setTransparencyType (SoState *state, int32_t type)
 set method for transparency type is SoINTERNAL, because it should only be invoked by SoGLRenderAction
 
static void setDrawElementsCallback (SoState *state, SoDrawElementsCallback *cb, void *userData)
 Set a callback for drawElements().
 
static void setUseVertexAttributes (SoState *state, bool flag)
 Sets if vertex attributes should be used instead of old style glVertexPointer/glNormalPointer etc.
 
static bool shouldUseVertexAttributes (SoState *state)
 Returns if vertex attributes should be used instead of old style glVertexPointer/glNormalPointer etc.
 
static void setDrawArraysCallback (SoState *state, SoDrawArraysCallback *cb, void *userData)
 Set a callback for drawElements().
 
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.
 
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.
 
- Static Public Member Functions inherited from SoElement
static SoType getClassTypeId ()
 Returns type identifier for SoElement class.
 
static void initElements ()
 Initialize ALL Inventor element classes.
 
static void initClass ()
 Initializes the SoElement class.
 
static int getNumStackIndices ()
 Returns the number of stack indices allocated.
 
static SoType getIdFromStackIndex (int stackIndex)
 Returns the id for the element with the given stack index.
 

Protected Member Functions

virtual void registerRedundantSet (SoState *, uint32_t)
 method to tell the cache that a redundant set was issued.
 
virtual void registerGetDependence (SoState *, uint32_t)
 method to register dependence due to get().
 
virtual ~SoLazyElement ()
 
- Protected Member Functions inherited from SoElement
 SoElement ()
 Constructor; use typeId.createInstance to create elements.
 
void capture (SoState *state) const
 Does whatever is necessary in state to capture this element for caching purposes.
 
virtual void captureThis (SoState *state) const
 Really captures this element, once it has been determined that a cache is open to capture it.
 
void setTypeId (SoType id)
 Sets typeId in instance.
 
void setStackIndex (int index)
 Sets stackIndex in instance.
 
SoElementgetNextInStack () const
 Returns next instance in specific element stack.
 
SoElementgetNextFree () const
 Returns next free element in a specific element stack.
 

Static Protected Member Functions

static int getNumPatterns ()
 Returns number of transparency levels supported with stipple patterns.
 
- 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.
 
static const SoElementgetConstElement (SoState *state, int stackIndex)
 Returns a read-only pointer to the top instance in the given element stack.
 
static int createStackIndex (SoType id)
 Creates and returns a new stack index.
 

Protected Attributes

ivStateStruct ivState
 
uint32_t invalidBits
 This is more convenient here, but might logically be kept with SoGLLazyElement.
 

Static Protected Attributes

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.
 
static float * defaultTransparency
 
static uint32_tdefaultPackedColor
 
- Static Protected Attributes inherited from SoElement
static int classStackIndex
 Stack index for SoElement class.
 

Detailed Description

Also includes: Transparencies GLColorMaterial GLBlendEnablement PolygonStipple Light model Color index

defines used in this element:

Definition at line 99 of file SoLazyElement.h.

Member Enumeration Documentation

◆ cases

Masks are needed by SoEXTENDER apps that need to use SoGLLazyElement::reset(bitmask) to invalidate GL values of particular components. NOTE: the order of these cases should not be changed without careful consideration of dependencies in the reallySend method.

Enumerator
LIGHT_MODEL_CASE 
COLOR_MATERIAL_CASE 
DIFFUSE_CASE 
AMBIENT_CASE 
EMISSIVE_CASE 
SPECULAR_CASE 
SHININESS_CASE 
BLENDING_CASE 
TRANSPARENCY_CASE 

Definition at line 110 of file SoLazyElement.h.

◆ internalMasks

Enumerator
OTHER_COLOR_MASK 
ALL_COLOR_MASK 
NO_COLOR_MASK 
ALL_BUT_DIFFUSE_MASK 
DIFFUSE_ONLY_MASK 

Definition at line 292 of file SoLazyElement.h.

◆ LightModel

Enumerator
BASE_COLOR 
PHONG 

Definition at line 135 of file SoLazyElement.h.

◆ masks

Enumerator
LIGHT_MODEL_MASK 
COLOR_MATERIAL_MASK 
DIFFUSE_MASK 
AMBIENT_MASK 
EMISSIVE_MASK 
SPECULAR_MASK 
SHININESS_MASK 
TRANSPARENCY_MASK 
BLENDING_MASK 
ALL_MASK 

Definition at line 121 of file SoLazyElement.h.

◆ VertexAttribs

Enumerator
ATTRIB_VERTEX 
ATTRIB_NORMAL 
ATTRIB_COLOR 
ATTRIB_TEXCOORD 

Definition at line 270 of file SoLazyElement.h.

Constructor & Destructor Documentation

◆ ~SoLazyElement()

virtual SoLazyElement::~SoLazyElement ( )
protectedvirtual

Member Function Documentation

◆ copyMatchInfo()

virtual SoElement * SoLazyElement::copyMatchInfo ( ) const
virtual

Implements SoElement.

Reimplemented in SoGLLazyElement.

◆ drawArrays()

static void SoLazyElement::drawArrays ( SoState state,
GLenum  mode,
GLint  first,
GLsizei  count 
)
static

◆ drawElements()

static void SoLazyElement::drawElements ( SoState state,
GLenum  mode,
GLsizei  count,
GLenum  type,
const GLvoid *  indices 
)
static

◆ getAmbient()

static const SbColor & SoLazyElement::getAmbient ( SoState )
static

◆ getBlending()

static bool SoLazyElement::getBlending ( SoState )
static

◆ getColorMaterial()

static bool SoLazyElement::getColorMaterial ( SoState )
static

◆ getDefaultAmbient()

static SbColor SoLazyElement::getDefaultAmbient ( )
inlinestatic

Definition at line 204 of file SoLazyElement.h.

Referenced by SoAmbientColorElement::getDefault().

◆ getDefaultDiffuse()

static SbColor SoLazyElement::getDefaultDiffuse ( )
inlinestatic

Definition at line 202 of file SoLazyElement.h.

◆ getDefaultEmissive()

static SbColor SoLazyElement::getDefaultEmissive ( )
inlinestatic

Definition at line 208 of file SoLazyElement.h.

Referenced by SoEmissiveColorElement::getDefault().

◆ getDefaultLightModel()

static int32_t SoLazyElement::getDefaultLightModel ( )
inlinestatic

Definition at line 216 of file SoLazyElement.h.

Referenced by SoLightModelElement::getDefault().

◆ getDefaultPacked()

static uint32_t SoLazyElement::getDefaultPacked ( )
inlinestatic

Definition at line 212 of file SoLazyElement.h.

◆ getDefaultShininess()

static float SoLazyElement::getDefaultShininess ( )
inlinestatic

Definition at line 210 of file SoLazyElement.h.

Referenced by SoShininessElement::getDefault().

◆ getDefaultSpecular()

static SbColor SoLazyElement::getDefaultSpecular ( )
inlinestatic

Definition at line 206 of file SoLazyElement.h.

Referenced by SoSpecularColorElement::getDefault().

◆ getDefaultTransparency()

static float SoLazyElement::getDefaultTransparency ( )
inlinestatic

Definition at line 214 of file SoLazyElement.h.

◆ getDiffuse()

static const SbColor & SoLazyElement::getDiffuse ( SoState state,
int  index 
)
static

The public methods are static, they get an instance of the element. If there is a cache, the appropriate virtual registerGetDependence is called.

◆ getDiffusePointer()

const SbColor * SoLazyElement::getDiffusePointer ( ) const
inline

Definition at line 256 of file SoLazyElement.h.

◆ getEmissive()

static const SbColor & SoLazyElement::getEmissive ( SoState )
static

◆ getInstance()

static SoLazyElement * SoLazyElement::getInstance ( SoState state)
inlinestatic

Note that this element is not const; however modifications to it can cause problems. SoEXTENDER apps should use only SoEXTENDER methods on this element.

Definition at line 197 of file SoLazyElement.h.

References SoState::getElementNoPush().

Referenced by SoGLLazyElement::sendAllMaterial(), SoGLLazyElement::sendNoMaterial(), and SoGLLazyElement::sendOnlyDiffuseColor().

◆ getLightModel()

static int32_t SoLazyElement::getLightModel ( SoState )
static

◆ getNumDiffuse()

int32_t SoLazyElement::getNumDiffuse ( ) const
inline

Definition at line 178 of file SoLazyElement.h.

◆ getNumPatterns()

static int SoLazyElement::getNumPatterns ( )
inlinestaticprotected

(Add one - solid - that is not included in this number.)

Definition at line 372 of file SoLazyElement.h.

◆ getNumTransparencies()

int32_t SoLazyElement::getNumTransparencies ( ) const
inline

Definition at line 180 of file SoLazyElement.h.

◆ getPackedColors()

static const uint32_t * SoLazyElement::getPackedColors ( SoState )
static

◆ getPackedPointer()

const uint32_t * SoLazyElement::getPackedPointer ( ) const
inline

Definition at line 253 of file SoLazyElement.h.

◆ getShininess()

static float SoLazyElement::getShininess ( SoState )
static

Referenced by SoShininessElement::get().

◆ getSpecular()

static const SbColor & SoLazyElement::getSpecular ( SoState )
static

◆ getTransparency()

static float SoLazyElement::getTransparency ( SoState ,
int  index 
)
static

◆ getTransparencyPointer()

const float * SoLazyElement::getTransparencyPointer ( ) const
inline

Definition at line 259 of file SoLazyElement.h.

◆ getWInstance()

static SoLazyElement * SoLazyElement::getWInstance ( SoState state)
inlinestatic

Definition at line 239 of file SoLazyElement.h.

References SoState::getElement().

◆ init()

virtual void SoLazyElement::init ( SoState state)
virtual

Reimplemented from SoElement.

Reimplemented in SoGLLazyElement.

◆ initClass()

static void SoLazyElement::initClass ( )
static

◆ isPacked()

bool SoLazyElement::isPacked ( ) const
inline

Definition at line 182 of file SoLazyElement.h.

◆ isTransparent()

bool SoLazyElement::isTransparent ( ) const
inline

Definition at line 184 of file SoLazyElement.h.

◆ matches()

virtual bool SoLazyElement::matches ( const SoElement ) const
virtual

they are replaced by lazyMatches, copyLazyMatchInfo, on SoGLLazyElement.

Implements SoElement.

Reimplemented in SoGLLazyElement.

◆ print()

virtual void SoLazyElement::print ( FILE *  fp) const
virtual

Reimplemented from SoElement.

◆ push()

virtual void SoLazyElement::push ( SoState state)
virtual

Reimplemented from SoElement.

Reimplemented in SoGLLazyElement.

◆ registerGetDependence()

virtual void SoLazyElement::registerGetDependence ( SoState ,
uint32_t   
)
protectedvirtual


only the GL version does any work

◆ registerRedundantSet()

virtual void SoLazyElement::registerRedundantSet ( SoState ,
uint32_t   
)
protectedvirtual

only the GL version does any work.

◆ setAmbient()

static void SoLazyElement::setAmbient ( SoState state,
const SbColor color 
)
static

◆ setBlending()

static void SoLazyElement::setBlending ( SoState state,
bool  value 
)
static

◆ setColorMaterial()

static void SoLazyElement::setColorMaterial ( SoState state,
bool  value 
)
static

◆ setDiffuse()

static void SoLazyElement::setDiffuse ( SoState state,
SoNode node,
int32_t  numColors,
const SbColor colors,
SoColorPacker cPacker 
)
static

◆ setDrawArraysCallback()

static void SoLazyElement::setDrawArraysCallback ( SoState state,
SoDrawArraysCallback cb,
void *  userData 
)
static

◆ setDrawElementsCallback()

static void SoLazyElement::setDrawElementsCallback ( SoState state,
SoDrawElementsCallback cb,
void *  userData 
)
static

◆ setEmissive()

static void SoLazyElement::setEmissive ( SoState state,
const SbColor color 
)
static

◆ setLightModel()

static void SoLazyElement::setLightModel ( SoState state,
const int32_t  model 
)
static

◆ setMaterials()

static void SoLazyElement::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 
)
static

◆ setOverrideBlending()

static void SoLazyElement::setOverrideBlending ( SoState state,
bool  flag 
)
static

When this method is called with flag == true, any further call to setBlending() will have no effect. This can be turned off again with flag == false.

◆ setPacked()

static void SoLazyElement::setPacked ( SoState state,
SoNode node,
int32_t  numColors,
const uint32_t colors 
)
static

◆ setShininess()

static void SoLazyElement::setShininess ( SoState state,
float  value 
)
static

Referenced by SoShininessElement::set().

◆ setSpecular()

static void SoLazyElement::setSpecular ( SoState state,
const SbColor color 
)
static

◆ setTransparency()

static void SoLazyElement::setTransparency ( SoState state,
SoNode node,
int32_t  numTransp,
const float *  transp,
SoColorPacker cPacker 
)
static

◆ setTransparencyType()

static void SoLazyElement::setTransparencyType ( SoState state,
int32_t  type 
)
static

◆ setUseVertexAttributes()

static void SoLazyElement::setUseVertexAttributes ( SoState state,
bool  flag 
)
static

◆ shouldUseVertexAttributes()

static bool SoLazyElement::shouldUseVertexAttributes ( SoState state)
static

Member Data Documentation

◆ defaultDiffuseColor

SbColor* SoLazyElement::defaultDiffuseColor
staticprotected

Definition at line 366 of file SoLazyElement.h.

◆ defaultPackedColor

uint32_t* SoLazyElement::defaultPackedColor
staticprotected

Definition at line 368 of file SoLazyElement.h.

◆ defaultTransparency

float* SoLazyElement::defaultTransparency
staticprotected

Definition at line 367 of file SoLazyElement.h.

◆ invalidBits

uint32_t SoLazyElement::invalidBits
protected

This is a bitmask indicating what components have not been sent to GL.

Definition at line 360 of file SoLazyElement.h.

Referenced by SoGLLazyElement::sendAllMaterial(), SoGLLazyElement::sendNoMaterial(), and SoGLLazyElement::sendOnlyDiffuseColor().

◆ ivState

ivStateStruct SoLazyElement::ivState
protected

Definition at line 353 of file SoLazyElement.h.

Referenced by SoGLLazyElement::lazyMatches().


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