osg.StateSet¶
-
class
osg.StateSet¶ Represents: c++ class Wraps: osg::StateSet Bases: osg.ObjectStores a set of modes and attributes which represent a set of OpenGL state. Notice that a
osg.StateSetcontains just a subset of the whole OpenGL state. In OSG, eachosg.Drawableand eachosg.Nodehas a reference to StateSet. These StateSets can be shared between differentosg.Drawables andosg.Nodes (that is, severalosg.Drawables andosg.Nodes 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.StateSetto contain specified attribute and override flag.Parameters: - attrib (
osg.StateAttribute) – - value (
unsigned) –
- attrib (
-
:
setAttribute(osg.StateAttribute attrib) Short version.
setAttributecall withosg.StateAttribute.ONas second argument.Parameters: attrib ( osg.StateAttribute) –
-
:
setAttributeMode(osg.StateAttribute.Type attribType, unsigned val)¶ Helper function setting mode for specified attribute.
Parameters: - attribType (
osg.StateAttribute.Type) – - val (
unsigned) –
- attribType (
-
:
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: - type (
osg.StateAttribute.Type) – - member (
unsigned) –
- type (
-
:
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
nilif no type is contained within StateSet.Parameters: - type (
osg.StateAttribute.Type) – - member (
unsigned) –
Return type: - type (
-
:
getAttribute(osg.StateAttribute.Type type) Short version.
getAttributecall with0as second argument;Parameters: type ( osg.StateAttribute.Type) –Return type: osg.StateAttribute
-
:
setMode(osg.StateAttribute.GLMode mode, int val)¶ Set this
osg.StateSetto contain the specified GLMode with a given value. Don’t use this method to set modes related to textures. For this purpose, useosg.StateSet.setTextureMode(), that accepts an extra parameter specifying which texture unit shall be affected by the call.Parameters: - mode (
osg.StateAttribute.GLMode) – - val (
int) –
- mode (
-
:
setMode(GLenum.Value mode, int val) -
Parameters: - mode (
GLenum.Value) – - val (
int) –
- mode (
-
:
getModeList()¶ Helper function. Returns Lua table where key is
osg.StateAttribute.GLModeand value isnumber.
-
:
getMode(osg.StateAttribute.GLMode mode)¶ Get the value for a given
osg.StateAttribute.GLMode. Ifmodeis contained within this StateSet, returns the value associated with it. Otherwise, returnsosg.StateSet.INHERIT_RENDERBIN_DETAILS. Don’t use this method to get the value of modes related to textures. For this purpose, useosg.StateSet.removeTextureMode(), that accepts an extra parameter specifying which texture unit shall be affected by the call.Parameters: mode ( osg.StateAttribute.GLMode) – Theosg.StateAttribute.GLModewhose 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.
setAttributeAndModescall withosg.StateAttribute.ONas second argument;Parameters: attrib ( osg.StateAttribute) –
-
:
setAttributeAndModes(osg.StateAttribute attrib, int mode) Set this
osg.StateSetto contain specified attribute and set the associated GLMode’s to specified value.Parameters: - attrib (
osg.StateAttribute) – - mode (
int) –
- attrib (
-
:
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.
- unit (
-
:
getTextureMode(unsigned unit, osg.StateAttribute.GLMode mode)¶ Get specified GLModeValue for specified
osg.StateAttribute.GLMode. Returnsosg.StateSet.INHERIT_RENDERBIN_DETAILSif no GLModeValue is contained within StateSet.Parameters: - unit (
unsigned) – - mode (
osg.StateAttribute.GLMode) –
Return type: int- unit (
-
:
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: - unit (
unsigned) – - mode (
osg.StateAttribute.GLMode) –
- unit (
-
:
setTextureAttribute(unsigned unit, osg.StateAttribute attrib, int val)¶ Set this
osg.StateSetto contain specified attribute and override flag.Parameters: - unit (
unsigned) – - attrib (
osg.StateAttribute) – - val (
int) –
- unit (
-
:
setTextureAttribute(unsigned unit, osg.StateAttribute attrib) Short version.
setTextureAttributecall withosg.StateAttribute.OFFas last argument;Parameters: - unit (
unsigned) – - attrib (
osg.StateAttribute) –
- unit (
-
:
getTextureAttribute(unsigned unit, osg.StateAttribute.Type type)¶ Get specified Texture related StateAttribute for specified type. Returns
nilif no type is contained within StateSet.Parameters: - unit (
unsigned) – - type (
osg.StateAttribute.Type) –
Return type: - unit (
-
:
setTextureAttributeMode(unsigned unit, osg.StateAttribute.Type attribType, int val)¶ -
Parameters: - unit (
unsigned) – - attribType (
osg.StateAttribute.Type) – - val (
int) –
- unit (
-
:
getTextureAttributeMode(unsigned unit, osg.StateAttribute.Type type)¶ -
Parameters: - unit (
unsigned) – - type (
osg.StateAttribute.Type) –
Return type: int - unit (
-
:
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: - unit (
unsigned) – - type (
osg.StateAttribute.Type) –
- unit (
-
:
setTextureAttributeAndModes(unsigned unit, osg.StateAttribute attrib, int val)¶ Set this
osg.StateSetto contain specified attribute and set the associated GLMode’s to specified value.Parameters: - unit (
unsigned) – - attrib (
osg.StateAttribute) – - val (
int) –
- unit (
-
:
setTextureAttributeAndModes(unsigned unit, osg.StateAttribute attrib) Short version.
setTextureAttributeAndModescall withosg.StateAttribute.ONas last argument;Parameters: - unit (
unsigned) – - attrib (
osg.StateAttribute) –
- unit (
-
:
clear()¶ Clear the
osg.StateSetof all modes and attributes.
-
:
merge(osg.StateSet rhs)¶ Merge this
osg.StateSetwith theosg.StateSetpassed as parameter. Every mode and attribute in thisosg.StateSetthat is marked withosg.StateAttribute.OVERRIDEis replaced with the equivalent mode or attribute fromrhs.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.RenderingHintof this StateSet.Return type: unsigned
-
:
setRenderBinDetails(int binNum, std.string binName, osg.StateSet.RenderBinMode mode)¶ Set the render bin details.
Parameters: - binNum (
int) – - binName (
std.string) – - mode (
osg.StateSet.RenderBinMode) –
- binNum (
-
:
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 argumentfalse.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.StateSetto contain specifiedosg.Uniformand override flag.Parameters: - uniform (
osg.Uniform) – - mode (
int) –
- uniform (
-
:
addUniform(osg.Uniform uniform) Short version.
addUniformcall withosg.StateAttribute.ONas last argument.Parameters: uniform ( osg.Uniform) –
-
:
setUniformMode(std.string name, int mode)¶ -
Parameters: - name (
std.string) – - mode (
int) –
- name (
-
:
getUniformMode(std.string name)¶ -
Parameters: name ( std.string) –Return type: int
-
:
removeUniform(std.string name)¶ Remove
osg.Uniformof specified name from StateSet.Parameters: name ( std.string) –
-
:
removeUniform(osg.Uniform uniform) Remove
osg.Uniformfrom StateSet.Parameters: uniform ( osg.Uniform) –
-
:
getUniform(std.string name)¶ Get
osg.Uniformfor specified name. Returnsnilif no matchingosg.Uniformis contained within StateSet.Parameters: name ( std.string) –Return type: osg.Uniform
-
:
getOrCreateUniform(std.string name, osg.Uniform.Type type, unsigned numElements)¶ Get
osg.Uniformfor specified name, if one is not available create it, add it to thisosg.StateSetand return a pointer to it.Parameters: - name (
std.string) – - type (
osg.Uniform.Type) – - numElements (
unsigned) –
Return type: - name (
-
:
getOrCreateUniform(std.string name, osg.Uniform.Type type) Short version.
getOrCreateUniformcall with1as last argument.Parameters: - name (
std.string) – - type (
osg.Uniform.Type) –
Return type: - name (
-
:
getUniformList()¶ Return the list of all Uniforms contained in this StateSet. Return value is Lua table where key is
osg.Uniformand 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: - defineName (
std.string) – - val (
int) –
- defineName (
-
:
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: - defineName (
std.string) – - defineValue (
std.string) – - val (
int) –
- defineName (
-
:
removeDefine(std.string defineName)¶ Remove define.
Parameters: defineName ( std.string) –
-