SoLazyElement(3)
๐ SoLazyElement ๐
okay so this is a page from the Library Functions Manual and it's all about the class SoLazyElement โ buckle up bestie, it's a long one ๐ซถ
๐ธ NAME ๐ธ
SoLazyElement โ the SoLazyElement class is used to handle material and shape properties. that's the whole vibe, material + shape properties, no cap.
โจ SYNOPSIS โจ
#include <Inventor/elements/SoLazyElement.h>
- Inherits
SoElement. - Inherited by
SoGLLazyElement.
it's giving "middle of the family tree" energy ๐ณ
๐ Public Types ๐
enum casesโ the big list of lazy cases, andLIGHT_MODEL_CASEstarts at0:
enum cases { LIGHT_MODEL_CASE = 0, COLOR_MATERIAL_CASE, DIFFUSE_CASE,
AMBIENT_CASE, EMISSIVE_CASE, SPECULAR_CASE, SHININESS_CASE,
BLENDING_CASE, TRANSPARENCY_CASE, VERTEXORDERING_CASE, TWOSIDE_CASE,
CULLING_CASE, SHADE_MODEL_CASE, GLIMAGE_CASE, ALPHATEST_CASE,
LAZYCASES_LAST }
enum masksโ the bitmask version, one bit per case, and yesALL_MASKis literally all of them:
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, VERTEXORDERING_MASK = 1 <<
VERTEXORDERING_CASE, TWOSIDE_MASK = 1 << TWOSIDE_CASE, CULLING_MASK
= 1 << CULLING_CASE, SHADE_MODEL_MASK = 1 << SHADE_MODEL_CASE,
GLIMAGE_MASK = 1 << GLIMAGE_CASE, ALPHATEST_MASK = 1 <<
ALPHATEST_CASE, ALL_MASK = (1 << LAZYCASES_LAST)-1 }
enum internalMasksโ the combo masks, for when you want a bundle of masks and not just one ๐:
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) }
enum LightModelโ two moods only:
enum LightModel { BASE_COLOR, PHONG }
enum VertexOrderingโ pick your direction, bestie:
enum VertexOrdering { CW, CCW }
๐ Public Member Functions ๐
virtual void init (SoState *state)virtual void push (SoState *state)virtual SbBool matches (const SoElement *) constvirtual SoElement * copyMatchInfo (void) constint32_t getNumDiffuse (void) constint32_t getNumTransparencies (void) constint32_t getNumColorIndices (void) constSbBool isPacked (void) constSbBool isTransparent (void) constconst uint32_t * getPackedPointer (void) constconst SbColor * getDiffusePointer (void) constconst int32_t * getColorIndexPointer (void) constconst float * getTransparencyPointer (void) const
a whole row of getters, it's giving "let me just peek at that" ๐ซฃ
๐ฎ Public Member Functions inherited from SoElement
const SoType getTypeId (void) constint getStackIndex (void) constvirtual void pop (SoState *state, const SoElement *prevTopElement)void setDepth (const int depth)int getDepth (void) constvirtual void print (FILE *file=stdout) constvirtual ~SoElement ()
โญ Static Public Member Functions โญ
static SoType getClassTypeId (void)static int getClassStackIndex (void)static void * createInstance (void)static void initClass ()static void setToDefault (SoState *state)static void setDiffuse (SoState *state, SoNode *node, int32_t numcolors, const SbColor *colors, SoColorPacker *packer)static void setTransparency (SoState *state, SoNode *node, int32_t numvalues, const float *transparency, SoColorPacker *packer)static void setPacked (SoState *state, SoNode *node, int32_t numcolors, const uint32_t *colors, const SbBool packedtransparency=FALSE)static void setColorIndices (SoState *state, SoNode *node, int32_t numindices, const int32_t *indices)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, SbBool value)static void enableBlending (SoState *state, int sfactor, int dfactor)static void enableSeparateBlending (SoState *state, int sfactor, int dfactor, int alpha_sfactor, int alpha_dfactor)static void disableBlending (SoState *state)static void setLightModel (SoState *state, const int32_t model)static void setVertexOrdering (SoState *state, VertexOrdering ordering)static void setBackfaceCulling (SoState *state, SbBool onoff)static void setTwosideLighting (SoState *state, SbBool onoff)static void setShadeModel (SoState *state, SbBool flatshading)static void setGLImageId (SoState *state, uint32_t glimageid, SbBool alphatest)static void setAlphaTest (SoState *state, SbBool onoff)static const SbColor & getDiffuse (SoState *state, int index)static float getTransparency (SoState *, int index)static const uint32_t * getPackedColors (SoState *)static const int32_t * getColorIndices (SoState *)static int32_t getColorIndex (SoState *, int num)static const SbColor & getAmbient (SoState *)static const SbColor & getEmissive (SoState *)static const SbColor & getSpecular (SoState *)static float getShininess (SoState *)static SbBool getColorMaterial (SoState *)static SbBool getBlending (SoState *, int &sfactor, int &dfactor)static SbBool getAlphaBlending (SoState *, int &sfactor, int &dfactor)static int32_t getLightModel (SoState *)static SbBool getAlphaTest (SoState *state)static SoLazyElement * getInstance (SoState *state)static float getDefaultAmbientIntensity (void)static SbColor getDefaultDiffuse (void)static SbColor getDefaultAmbient (void)static SbColor getDefaultSpecular (void)static SbColor getDefaultEmissive (void)static float getDefaultShininess (void)static uint32_t getDefaultPacked (void)static float getDefaultTransparency (void)static int32_t getDefaultLightModel (void)static int32_t getDefaultColorIndex (void)static void setMaterials (SoState *state, SoNode *node, uint32_t bitmask, SoColorPacker *cPacker, const SbColor *diffuse, const int numdiffuse, const float *transp, const int numtransp, const SbColor &ambient, const SbColor &emissive, const SbColor &specular, const float shininess, const SbBool istransparent)static SoLazyElement * getWInstance (SoState *state)static void setTransparencyType (SoState *state, int32_t type)
okay that's a LOT of statics, but every single one is here, we don't skip ๐ฏ
๐ฆ Static Public Member Functions inherited from SoElement
static void initClass (void)static SoType getClassTypeId (void)static int getClassStackIndex (void)static void initElements (void)static int getNumStackIndices (void)static SoType getIdFromStackIndex (const int stackIndex)
๐ Protected Member Functions ๐
virtual void lazyDidSet (uint32_t mask)virtual void lazyDidntSet (uint32_t mask)virtual void setDiffuseElt (SoNode *, int32_t numcolors, const SbColor *colors, SoColorPacker *packer)virtual void setPackedElt (SoNode *node, int32_t numcolors, const uint32_t *colors, const SbBool packedtransparency)virtual void setColorIndexElt (SoNode *node, int32_t numindices, const int32_t *indices)virtual void setTranspElt (SoNode *node, int32_t numtransp, const float *transp, SoColorPacker *packer)virtual void setTranspTypeElt (int32_t type)virtual void setAmbientElt (const SbColor *color)virtual void setEmissiveElt (const SbColor *color)virtual void setSpecularElt (const SbColor *color)virtual void setShininessElt (float value)virtual void setColorMaterialElt (SbBool value)virtual void enableBlendingElt (int sfactor, int dfactor, int alpha_sfactor, int alpha_dfactor)virtual void disableBlendingElt (void)virtual void setLightModelElt (SoState *state, int32_t model)virtual void setMaterialElt (SoNode *node, uint32_t bitmask, SoColorPacker *packer, const SbColor *diffuse, const int numdiffuse, const float *transp, const int numtransp, const SbColor &ambient, const SbColor &emissive, const SbColor &specular, const float shininess, const SbBool istransparent)virtual void setVertexOrderingElt (VertexOrdering ordering)virtual void setBackfaceCullingElt (SbBool onoff)virtual void setTwosideLightingElt (SbBool onoff)virtual void setShadeModelElt (SbBool flatshading)virtual void setGLImageIdElt (uint32_t glimageid, SbBool alphatest)virtual void setAlphaTestElt (SbBool onoff)
๐ง Protected Member Functions inherited from SoElement
SoElement (void)void capture (SoState *const state) constvirtual void captureThis (SoState *state) constvoid setTypeId (const SoType typeId)void setStackIndex (const int index)SoElement * getNextInStack (void) constSoElement * getNextFree (void) const
๐ Protected Attributes ๐
struct SoLazyElement::CoinState coinstate
๐ Protected Attributes inherited from SoElement
SoType typeIdint stackIndexint depth
๐ Additional Inherited Members ๐
๐ซ Static Protected Member Functions inherited from SoElement
static SoElement * getElement (SoState *const state, const int stackIndex)static const SoElement * getConstElement (SoState *const state, const int stackIndex)static int createStackIndex (const SoType id)
๐ Static Protected Attributes inherited from SoElement
static int classStackIndexstatic SoTypeList * stackToType
๐ธ DETAILED DESCRIPTION ๐ธ
The SoLazyElement class is used to handle material and shape properties. that's the tl;dr bestie ๐
So[GL]LazyElement is, as the name implies, an element that is lazy about sending things to OpenGL. and honestly? relatable. ๐ด the changes are not sent to OpenGL until SoGLLazyElement::send() is called. this means that you can change the state of certain attributes several times, but the state will only be sent to OpenGL once. batch it, don't spam it โจ
When creating a new shape node in Coin, it's a common operation to modify the OpenGL diffuse color. there are several ways you can send the color to OpenGL. if you're not going to use the color outside your node, you can just as well send it using plain OpenGL. you can also set the color in the element, and then force a send by using:
SoGLLazyElement::send(state, SoLazyElement::DIFFUSE_MASK)
However โ and this is the important part, so listen up ๐ซถ โ when creating an extension shape node, it's always recommended to create an instance of SoMaterialBundle on the stack. if this instance is created after you update SoLazyElement with a new color, the new color will be sent to OpenGL when you call:
SoMaterialBundle::sendFirst()
this call will also update all other lazy OpenGL state, and it's actually required to either use SoMaterialBundle::sendFirst() or call SoGLLazyElement::send(state, SoLazyElement::ALL_MASK) when creating a shape node. like, required required. not optional, no skipping ๐
If you decide to send the color to OpenGL usingglColor*(), you should notifySoGLLazyElementabout this by calling:cpp SoGLLazyElement::reset(state, SoLazyElement::DIFFUSE_MASK)This will notifySoGLLazyElementthat the current OpenGL diffuse color is unknown. it's giving "hey bestie I went behind your back with raw GL, pls forgive ๐"
๐ง Member Function Documentation ๐ง
void * SoLazyElement::createInstance (void ) [static]
okay so bestie, this API member is considered internal to the library, because it is not likely to be of interest to the application programmer. That's it. That's the tea. โ No cap. If you're out here writing apps, you probably don't need to touch this one. ๐
void SoLazyElement::initClass (void ) [static]
This static method initializes static data for the SoDiffuseColorElement class. Yes, it says SoDiffuseColorElement โ I'm not fixing it, I'm just reporting it. ๐ซถ It's giving "trust the source". Periodt. โจ
void SoLazyElement::init (SoState * state) [virtual]
This function initializes the element type in the given SoState. It is called for the first element of each enabled element type in SoState objects. That's the whole vibe. ๐ฆ
- Reimplemented from
SoElement. - Reimplemented in
SoGLLazyElement.
void SoLazyElement::push (SoState * state) [virtual]
This method is called every time a new element is required in one of the stacks. When does that happen? When a writable element is requested, using SoState::getElement() or indirectly SoElement::getElement(), and the depth of the current element is less than the state depth. Lowkey iconic. ๐
Override this method if your element needs to copy data from the previous top of stack. The push() method is called on the new element, and the previous element can be found using SoElement::getNextInStack(). Bestie, that's the whole flow. ๐
- Reimplemented from
SoElement. - Reimplemented in
SoGLLazyElement.
SbBool SoLazyElement::matches (const SoElement * ) const [virtual]
Will always return TRUE in Coin. Always. No cap. โ
- Implements
SoElement.
SoElement * SoLazyElement::copyMatchInfo (void ) const [virtual]
Just returns NULL in Coin. It's giving minimal effort, and honestly? Respect. ๐
- Implements
SoElement.
void SoLazyElement::setToDefault (SoState * state) [static]
Internal function used for resetting the OpenGL state before FBO rendering. That's the whole job. ๐
๐ธ Author ๐ธ
Generated automatically by Doxygen for Coin from the source code. So don't @ me about the formatting, bestie โ the tool did it. ๐
That's the whole page, and it was Coin, Version 3.1.3, SoLazyElement(3). The date? Not in this footer, but the vibe is eternal. ๐ฆโจ Byeee!
๐ฆ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 ยท GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 ยท GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 ยท GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms