osg.StateSet

class osg.StateSet
Represents:c++ class
Wraps:osg::StateSet
Bases:osg.Object

Stores a set of modes and attributes which represent a set of OpenGL state. Notice that a osg.StateSet contains just a subset of the whole OpenGL state. In OSG, each osg.Drawable and each osg.Node has a reference to StateSet. These StateSets can be shared between different osg.Drawable s and osg.Node s (that is, several osg.Drawable s and osg.Node s can reference the same StateSet). Indeed, this practice is recommended whenever possible, as this minimizes expensive state changes in the graphics pipeline.

Constructors:

osg.StateSet()

Methods:

:setAttribute(osg.StateAttribute attrib, unsigned value)

Set this osg.StateSet to contain specified attribute and override flag.

Parameters:
:setAttribute(osg.StateAttribute attrib)

Short version. setAttribute call with osg.StateAttribute.ON as second argument.

Parameters:attrib (osg.StateAttribute) –
:setAttributeMode(osg.StateAttribute.Type attribType, unsigned val)

Helper function setting mode for specified attribute.

Parameters:
:getAttributeMode(osg.StateAttribute.Type type)

Helper function getting mode for specified attribute.

Parameters:type (osg.StateAttribute.Type) –
Return type:int
:getAttributeList()

Helper function. Returns Lua table with all attributes.

:removeAttribute(osg.StateAttribute.Type type, unsigned member)

Remove attribute of specified type from StateSet.

Parameters:
:removeAttribute(osg.StateAttribute attrib)

Remove attribute from StateSet.

Parameters:attrib (osg.StateAttribute) –
:getAttribute(osg.StateAttribute.Type type, unsigned member)

Get specified StateAttribute for specified type. Returns nil if no type is contained within StateSet.

Parameters:
Return type:

osg.StateAttribute

:getAttribute(osg.StateAttribute.Type type)

Short version. getAttribute call with 0 as second argument;

Parameters:type (osg.StateAttribute.Type) –
Return type:osg.StateAttribute
:setMode(osg.StateAttribute.GLMode mode, int val)

Set this osg.StateSet to contain the specified GLMode with a given value. Don’t use this method to set modes related to textures. For this purpose, use osg.StateSet.setTextureMode(), that accepts an extra parameter specifying which texture unit shall be affected by the call.

Parameters:
:setMode(GLenum.Value mode, int val)

Parameters:
:getModeList()

Helper function. Returns Lua table where key is osg.StateAttribute.GLMode and value is number.

:getMode(osg.StateAttribute.GLMode mode)

Get the value for a given osg.StateAttribute.GLMode. If mode is contained within this StateSet, returns the value associated with it. Otherwise, returns osg.StateSet.INHERIT_RENDERBIN_DETAILS. Don’t use this method to get the value of modes related to textures. For this purpose, use osg.StateSet.removeTextureMode(), that accepts an extra parameter specifying which texture unit shall be affected by the call.

Parameters:mode (osg.StateAttribute.GLMode) – The osg.StateAttribute.GLMode whose value is desired.
Return type:int
:removeMode(osg.StateAttribute.GLMode mode)

Remove mode from this StateSet. Don’t use this method to remove modes related to textures. For this purpose, use osg.StateSet.removeTextureMode(), that accepts an extra parameter specifying which texture unit shall be affected by the call.

Parameters:mode (osg.StateAttribute.GLMode) –
:setAttributeAndModes(osg.StateAttribute attrib)

Short version. setAttributeAndModes call with osg.StateAttribute.ON as second argument;

Parameters:attrib (osg.StateAttribute) –
:setAttributeAndModes(osg.StateAttribute attrib, int mode)

Set this osg.StateSet to contain specified attribute and set the associated GLMode’s to specified value.

Parameters:
:setTextureMode(unsigned unit, osg.StateAttribute.GLMode mode, int val)

Parameters:
  • unit (unsigned) – The texture unit to be affected (used with multi-texturing).
  • mode (osg.StateAttribute.GLMode) – The OpenGL mode to be added to the StateSet.
  • val (int) – The value to be assigned to mode.
:getTextureMode(unsigned unit, osg.StateAttribute.GLMode mode)

Get specified GLModeValue for specified osg.StateAttribute.GLMode. Returns osg.StateSet.INHERIT_RENDERBIN_DETAILS if no GLModeValue is contained within StateSet.

Parameters:
Return type:

int

:getTextureModeList()

Return the list of all Texture related GLModes contained in this StateSet. Return value is Lua table.

:removeTextureMode(unsigned unit, osg.StateAttribute.GLMode mode)

Remove texture mode from osg.StateSet.

Parameters:
:setTextureAttribute(unsigned unit, osg.StateAttribute attrib, int val)

Set this osg.StateSet to contain specified attribute and override flag.

Parameters:
:setTextureAttribute(unsigned unit, osg.StateAttribute attrib)

Short version. setTextureAttribute call with osg.StateAttribute.OFF as last argument;

Parameters:
:getTextureAttribute(unsigned unit, osg.StateAttribute.Type type)

Get specified Texture related StateAttribute for specified type. Returns nil if no type is contained within StateSet.

Parameters:
Return type:

osg.StateAttribute

:setTextureAttributeMode(unsigned unit, osg.StateAttribute.Type attribType, int val)

Parameters:
:getTextureAttributeMode(unsigned unit, osg.StateAttribute.Type type)

Parameters:
Return type:

int

:getTextureAttributeList()

Return the list of all Texture related StateAttributes contained in this StateSet. Return value is Lua table.

:removeTextureAttribute(unsigned unit, osg.StateAttribute.Type type)

Remove texture attribute of specified type from StateSet.

Parameters:
:setTextureAttributeAndModes(unsigned unit, osg.StateAttribute attrib, int val)

Set this osg.StateSet to contain specified attribute and set the associated GLMode’s to specified value.

Parameters:
:setTextureAttributeAndModes(unsigned unit, osg.StateAttribute attrib)

Short version. setTextureAttributeAndModes call with osg.StateAttribute.ON as last argument;

Parameters:
:clear()

Clear the osg.StateSet of all modes and attributes.

:merge(osg.StateSet rhs)

Merge this osg.StateSet with the osg.StateSet passed as parameter. Every mode and attribute in this osg.StateSet that is marked with osg.StateAttribute.OVERRIDE is replaced with the equivalent mode or attribute from rhs.

Parameters:rhs (osg.StateSet) –
:getNumParents()

Get the number of parents of this StateSet.

Return type:unsigned
:getParent(unsigned index)

Get a single const parent of this StateSet.

Parameters:index (unsigned) – index of the parent to get.
Return type:osg.Object
:setRenderingHint(unsigned hint)

Parameters:hint (unsigned) –
:getRenderingHint()

Get the osg.StateSet.RenderingHint of this StateSet.

Return type:unsigned
:setRenderBinDetails(int binNum, std.string binName, osg.StateSet.RenderBinMode mode)

Set the render bin details.

Parameters:
:setRenderBinToInherit()

Set the render bin details to inherit.

:useRenderBinDetails()

Get whether the render bin details are set and should be used.

Return type:bool
:setRenderBinMode(osg.StateSet.RenderBinMode mode)

Set the render bin mode.

Parameters:mode (osg.StateSet.RenderBinMode) –
:getRenderBinMode()

Get the render bin mode.

Return type:osg.StateSet.RenderBinMode
:setBinNumber(int num)

Set the render bin number.

Parameters:num (int) –
:getBinNumber()

Get the render bin number.

Return type:int
:setBinName(std.string name)

Set the render bin name.

Parameters:name (std.string) –
:getBinName()

Get the render bin name.

Return type:std.string
:setNestRenderBins(bool b)

By default render bins will be nested within each other dependent upon where they are set in the scene graph. This can be problematic if a transparent render bin is attached to an opaque render bin which is attached to another transparent render bin as these render bins will be sorted separately, giving the wrong draw ordering for back-to-front transparency. Therefore, to prevent render bins being nested, call osg.StateSet.setNestRenderBins() with argument false.

Parameters:b (bool) –
:getNestRenderBins()

Get whether associated RenderBin should be nested within parents RenderBin.

Return type:bool
:addUniform(osg.Uniform uniform, int mode)

Set this osg.StateSet to contain specified osg.Uniform and override flag.

Parameters:
:addUniform(osg.Uniform uniform)

Short version. addUniform call with osg.StateAttribute.ON as last argument.

Parameters:uniform (osg.Uniform) –
:setUniformMode(std.string name, int mode)

Parameters:
:getUniformMode(std.string name)

Parameters:name (std.string) –
Return type:int
:removeUniform(std.string name)

Remove osg.Uniform of specified name from StateSet.

Parameters:name (std.string) –
:removeUniform(osg.Uniform uniform)

Remove osg.Uniform from StateSet.

Parameters:uniform (osg.Uniform) –
:getUniform(std.string name)

Get osg.Uniform for specified name. Returns nil if no matching osg.Uniform is contained within StateSet.

Parameters:name (std.string) –
Return type:osg.Uniform
:getOrCreateUniform(std.string name, osg.Uniform.Type type, unsigned numElements)

Get osg.Uniform for specified name, if one is not available create it, add it to this osg.StateSet and return a pointer to it.

Parameters:
Return type:

osg.Uniform

:getOrCreateUniform(std.string name, osg.Uniform.Type type)

Short version. getOrCreateUniform call with 1 as last argument.

Parameters:
Return type:

osg.Uniform

:getUniformList()

Return the list of all Uniforms contained in this StateSet. Return value is Lua table where key is osg.Uniform and value is uniform mode value (number).

:setDefine(std.string defineName, int val)

Added define pass on to shaders that use utilize that define, as specified by the GLSL #pragma import_defines(..) and #pragma requires(..).

Parameters:
:setDefine(std.string defineName, std.string defineValue, int val)

Added define with value to pass on to shaders that use utilize that define, as specified by the GLSL #pragma import_defines(..) and #pragma requires(..).

Parameters:
:removeDefine(std.string defineName)

Remove define.

Parameters:defineName (std.string) –