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.

Параметры
:setAttribute(osg.StateAttribute attrib)

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

Параметры

attrib (osg.StateAttribute) –

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

Helper function setting mode for specified attribute.

Параметры
:getAttributeMode(osg.StateAttribute.Type type)

Helper function getting mode for specified attribute.

Параметры

type (osg.StateAttribute.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.

Параметры
:removeAttribute(osg.StateAttribute attrib)

Remove attribute from StateSet.

Параметры

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.

Параметры
Тип результата

osg.StateAttribute

:getAttribute(osg.StateAttribute.Type type)

Short version. getAttribute call with 0 as second argument;

Параметры

type (osg.StateAttribute.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.

Параметры
:setMode(GLenum.Value mode, int val)

Параметры
: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.

Параметры

mode (osg.StateAttribute.GLMode) – The osg.StateAttribute.GLMode whose value is desired.

Тип результата

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.

Параметры

mode (osg.StateAttribute.GLMode) –

:setAttributeAndModes(osg.StateAttribute attrib)

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

Параметры

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.

Параметры
:setTextureMode(unsigned unit, osg.StateAttribute.GLMode mode, int val)

Параметры
  • 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.

Параметры
Тип результата

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.

Параметры
:setTextureAttribute(unsigned unit, osg.StateAttribute attrib, int val)

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

Параметры
:setTextureAttribute(unsigned unit, osg.StateAttribute attrib)

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

Параметры
:getTextureAttribute(unsigned unit, osg.StateAttribute.Type type)

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

Параметры
Тип результата

osg.StateAttribute

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

Параметры
:getTextureAttributeMode(unsigned unit, osg.StateAttribute.Type 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.

Параметры
: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.

Параметры
:setTextureAttributeAndModes(unsigned unit, osg.StateAttribute attrib)

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

Параметры
: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.

Параметры

rhs (osg.StateSet) –

:getNumParents()

Get the number of parents of this StateSet.

Тип результата

unsigned

:getParent(unsigned index)

Get a single const parent of this StateSet.

Параметры

index (unsigned) – index of the parent to get.

Тип результата

osg.Object

:setRenderingHint(unsigned hint)

Параметры

hint (unsigned) –

:getRenderingHint()

Get the osg.StateSet.RenderingHint of this StateSet.

Тип результата

unsigned

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

Set the render bin details.

Параметры
:setRenderBinToInherit()

Set the render bin details to inherit.

:useRenderBinDetails()

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

Тип результата

bool

:setRenderBinMode(osg.StateSet.RenderBinMode mode)

Set the render bin mode.

Параметры

mode (osg.StateSet.RenderBinMode) –

:getRenderBinMode()

Get the render bin mode.

Тип результата

osg.StateSet.RenderBinMode

:setBinNumber(int num)

Set the render bin number.

Параметры

num (int) –

:getBinNumber()

Get the render bin number.

Тип результата

int

:setBinName(std.string name)

Set the render bin name.

Параметры

name (std.string) –

:getBinName()

Get the render bin name.

Тип результата

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.

Параметры

b (bool) –

:getNestRenderBins()

Get whether associated RenderBin should be nested within parents RenderBin.

Тип результата

bool

:addUniform(osg.Uniform uniform, int mode)

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

Параметры
:addUniform(osg.Uniform uniform)

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

Параметры

uniform (osg.Uniform) –

:setUniformMode(std.string name, int mode)

Параметры
:getUniformMode(std.string name)

Параметры

name (std.string) –

Тип результата

int

:removeUniform(std.string name)

Remove osg.Uniform of specified name from StateSet.

Параметры

name (std.string) –

:removeUniform(osg.Uniform uniform)

Remove osg.Uniform from StateSet.

Параметры

uniform (osg.Uniform) –

:getUniform(std.string name)

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

Параметры

name (std.string) –

Тип результата

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.

Параметры
Тип результата

osg.Uniform

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

Short version. getOrCreateUniform call with 1 as last argument.

Параметры
Тип результата

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(..).

Параметры
: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(..).

Параметры
:removeDefine(std.string defineName)

Remove define.

Параметры

defineName (std.string) –