# osg::StateSet Class Reference

Encapsulates OpenGL state modes and attributes. More...

Inheritance diagram for osg::StateSet:

[legend]
List of all members.

## Public Types

typedef std::map< StateAttribute::GLMode, StateAttribute::GLModeValue > | ModeList
| a container to map GLModes to their respective GLModeValues.
typedef std::pair< ref_ptr< StateAttribute >, StateAttribute::OverrideValue > | RefAttributePair
| Simple pairing between an attribute and its override flag.
typedef std::map< StateAttribute::TypeMemberPair, RefAttributePair > | AttributeList
| a container to map <StateAttribyte::Types,Member> to their respective RefAttributePair.
typedef std::vector< ModeList > | TextureModeList
typedef std::vector< AttributeList > | TextureAttributeList
enum | RenderingHint { DEFAULT_BIN = 0, OPAQUE_BIN = 1, TRANSPARENT_BIN = 2 }
enum | RenderBinMode { INHERIT_RENDERBIN_DETAILS, USE_RENDERBIN_DETAILS, OVERRIDE_RENDERBIN_DETAILS, ENCLOSE_RENDERBIN_DETAILS }

## Public Member Functions

| StateSet ()
| StateSet (const StateSet &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
virtual Object * | cloneType () const
| Clone the type of an object, with Object* return type.
virtual Object * | clone (const CopyOp &copyop) const
| Clone an object, with Object* return type.
virtual bool | isSameKindAs (const Object *obj) const
virtual const char * | libraryName () const
| return the name of the object's library.
virtual const char * | className () const
| return the name of the object's class type.
int | compare (const StateSet &rhs, bool compareAttributeContents=false) const
| return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
bool | operator< (const StateSet &rhs) const
bool | operator== (const StateSet &rhs) const
bool | operator!= (const StateSet &rhs) const
void | setGlobalDefaults ()
| Set all the modes to on or off so that it defines a complete state, typically used for a default global state.
void | clear ()
| Clear the StateSet of all modes and attributes.
void | merge (const StateSet &rhs)
| merge this stateset with stateset rhs, this overrides the rhs if OVERRIDE is specified, otherwise rhs takes precedence.
void | setMode (StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
| Set this StateSet to contain specified GLMode and value.
void | removeMode (StateAttribute::GLMode mode)
| Remove mode from StateSet.
StateAttribute::GLModeValue | getMode (StateAttribute::GLMode mode) const
| Get specified GLModeValue for specified GLMode.
ModeList & | getModeList ()
| return the list of all GLModes contained in this StateSet.
const ModeList & | getModeList () const
| return the const list of all GLModes contained in this const StateSet.
void | setAttribute (StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF)
| Set this StateSet to contain specified attribute and override flag.
void | setAttributeAndModes (StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON)
| Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.
void | removeAttribute (StateAttribute::Type type, unsigned int member=0)
| remove attribute of specified type from StateSet.
void | removeAttribute (StateAttribute *attribute)
| remove attribute from StateSet.
StateAttribute * | getAttribute (StateAttribute::Type type, unsigned int member=0)
| Get specified StateAttribute for specified type.
const StateAttribute * | getAttribute (StateAttribute::Type type, unsigned int member=0) const
| Get specified const StateAttribute for specified type.
const RefAttributePair * | getAttributePair (StateAttribute::Type type, unsigned int member=0) const
| Get specified RefAttributePair for specified type.
AttributeList & | getAttributeList ()
| return the list of all StateAttributes contained in this StateSet.
const AttributeList & | getAttributeList () const
| return the const list of all StateAttributes contained in this const StateSet.
void | setTextureMode (unsigned int unit, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
| Set this StateSet to contain specified GLMode and value.
void | removeTextureMode (unsigned int unit, StateAttribute::GLMode mode)
| Remove texture mode from StateSet.
StateAttribute::GLModeValue | getTextureMode (unsigned int unit, StateAttribute::GLMode mode) const
| Get specified GLModeValue for specified GLMode.
TextureModeList & | getTextureModeList ()
| return the list of all Texture related GLModes contained in this StateSet.
const TextureModeList & | getTextureModeList () const
| return the const list of all Texture related GLModes contained in this const StateSet.
void | setTextureAttribute (unsigned int unit, StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF)
| Set this StateSet to contain specified attribute and override flag.
void | setTextureAttributeAndModes (unsigned int unit, StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON)
| Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.
void | removeTextureAttribute (unsigned int unit, StateAttribute::Type type)
| remove texture attribute of specified type from StateSet.
void | removeTextureAttribute (unsigned int unit, StateAttribute *attribute)
| remove texture attribute from StateSet.
StateAttribute * | getTextureAttribute (unsigned int unit, StateAttribute::Type type)
| Get specified Texture related StateAttribute for specified type.
const StateAttribute * | getTextureAttribute (unsigned int unit, StateAttribute::Type type) const
| Get specified Texture related const StateAttribute for specified type.
const RefAttributePair * | getTextureAttributePair (unsigned int unit, StateAttribute::Type type) const
| Get specified Texture related RefAttributePair for specified type.
TextureAttributeList & | getTextureAttributeList ()
| Return the list of all Texture related StateAttributes contained in this StateSet.
const TextureAttributeList & | getTextureAttributeList () const
| Return the const list of all Texture related StateAttributes contained in this const StateSet.
void | setAssociatedModes (const StateAttribute *attribute, StateAttribute::GLModeValue value)
void | setAssociatedTextureModes (unsigned int unit, const StateAttribute *attribute, StateAttribute::GLModeValue value)
void | setRenderingHint (int hint)
| Set the RenderingHint of the StateSet.
int | getRenderingHint () const
| Get the RenderingHint of the StateSet.
void | setRenderBinDetails (int binNum, const std::string &binName, RenderBinMode mode=USE_RENDERBIN_DETAILS)
| Set the render bin details.
void | setRenderBinToInherit ()
| Set the render bin details to inherit.
RenderBinMode | getRenderBinMode () const
| Get the render bin mode.
bool | useRenderBinDetails () const
| Get whether the render bin details are set and should be used.
int | getBinNumber () const
| Get the render bin number.
const std::string & | getBinName () const
| Get the render bin name.
void | compileGLObjects (State &state) const
| call compile on all StateAttributes contained within this StateSet.
virtual void | releaseGLObjects (State *state=0) const
| call release on all StateAttributes contained within this StateSet.

## Protected Member Functions

virtual | ~StateSet ()
StateSet & | operator= (const StateSet &)
ModeList & | getOrCreateTextureModeList (unsigned int unit)
AttributeList & | getOrCreateTextureAttributeList (unsigned int unit)
int | compareModes (const ModeList &lhs, const ModeList &rhs)
int | compareAttributePtrs (const AttributeList &lhs, const AttributeList &rhs)
int | compareAttributeContents (const AttributeList &lhs, const AttributeList &rhs)
void | setMode (ModeList &modeList, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
void | setModeToInherit (ModeList &modeList, StateAttribute::GLMode mode)
StateAttribute::GLModeValue | getMode (const ModeList &modeList, StateAttribute::GLMode mode) const
void | setAttribute (AttributeList &attributeList, StateAttribute *attribute, const StateAttribute::OverrideValue value=StateAttribute::OFF)
StateAttribute * | getAttribute (AttributeList &attributeList, const StateAttribute::Type type, unsigned int member)
const StateAttribute * | getAttribute (const AttributeList &attributeList, const StateAttribute::Type type, unsigned int member) const
const RefAttributePair * | getAttributePair (const AttributeList &attributeList, const StateAttribute::Type type, unsigned int member) const

## Protected Attributes

ModeList | _modeList
AttributeList | _attributeList
TextureModeList | _textureModeList
TextureAttributeList | _textureAttributeList
int | _renderingHint
RenderBinMode | _binMode
int | _binNum
std::string | _binName

## Detailed Description

Encapsulates OpenGL state modes and attributes.

Used to specific textures etc of osg::Drawable's which hold references to a single osg::StateSet. StateSet can be shared between Drawable's and is recommend if possible as it minimizes expensive state changes in the graphics pipeline.

## Member Typedef Documentation

typedef std::map<StateAttribute::TypeMemberPair,RefAttributePair> osg::StateSet::AttributeList

| a container to map <StateAttribyte::Types,Member> to their respective RefAttributePair.

typedef std::map<StateAttribute::GLMode,StateAttribute::GLModeValue> osg::StateSet::ModeList

| a container to map GLModes to their respective GLModeValues.

typedef std::pair<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> osg::StateSet::RefAttributePair

| Simple pairing between an attribute and its override flag.

typedef std::vector<AttributeList> osg::StateSet::TextureAttributeList

typedef std::vector<ModeList> osg::StateSet::TextureModeList

## Member Enumeration Documentation

enum osg::StateSet::RenderBinMode

Enumeration values:

  INHERIT_RENDERBIN_DETAILS |
  USE_RENDERBIN_DETAILS |
  OVERRIDE_RENDERBIN_DETAILS |
  ENCLOSE_RENDERBIN_DETAILS |

enum osg::StateSet::RenderingHint

Enumeration values:

  DEFAULT_BIN |
  OPAQUE_BIN |
  TRANSPARENT_BIN |

## Constructor & Destructor Documentation

StateSet::StateSet | ( |  | ) |

StateSet::StateSet | ( | const StateSet & | ,
|  | const CopyOp & | copyop = `CopyOp::SHALLOW_COPY`
| ) |

StateSet::~StateSet | ( |  | ) | `[protected, virtual]`

## Member Function Documentation

virtual const char* osg::StateSet::className | ( |  | ) | const`[inline, virtual]`

| return the name of the object's class type. Must be defined by derived classes. Implements osg::Object.

void StateSet::clear | ( |  | ) |

| Clear the StateSet of all modes and attributes.

virtual Object* osg::StateSet::clone | ( | const CopyOp & | copyop | ) | const`[inline, virtual]`

| Clone an object, with Object* return type. Must be defined by derived classes. Implements osg::Object.

virtual Object* osg::StateSet::cloneType | ( |  | ) | const`[inline, virtual]`

| Clone the type of an object, with Object* return type. Must be defined by derived classes. Implements osg::Object.

int StateSet::compare | ( | const StateSet & | rhs,
|  | bool | compareAttributeContents = `false`
| ) | const

| return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.

int StateSet::compareAttributeContents | ( | const AttributeList & | lhs,
|  | const AttributeList & | rhs
| ) | `[protected]`

int StateSet::compareAttributePtrs | ( | const AttributeList & | lhs,
|  | const AttributeList & | rhs
| ) | `[protected]`

int StateSet::compareModes | ( | const ModeList & | lhs,
|  | const ModeList & | rhs
| ) | `[protected]`

void StateSet::compileGLObjects | ( | State & | state | ) | const

| call compile on all StateAttributes contained within this StateSet.

const StateAttribute * StateSet::getAttribute | ( | const AttributeList & | attributeList,
|  | const StateAttribute::Type | type,
|  | unsigned int | member
| ) | const`[protected]`

StateAttribute * StateSet::getAttribute | ( | AttributeList & | attributeList,
|  | const StateAttribute::Type | type,
|  | unsigned int | member
| ) | `[protected]`

const StateAttribute * StateSet::getAttribute | ( | StateAttribute::Type | type,
|  | unsigned int | member = `0`
| ) | const

| Get specified const StateAttribute for specified type. Returns NULL if no type is contained within const StateSet.

StateAttribute * StateSet::getAttribute | ( | StateAttribute::Type | type,
|  | unsigned int | member = `0`
| ) |

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

const AttributeList& osg::StateSet::getAttributeList | ( |  | ) | const`[inline]`

| return the const list of all StateAttributes contained in this const StateSet.

AttributeList& osg::StateSet::getAttributeList | ( |  | ) | `[inline]`

| return the list of all StateAttributes contained in this StateSet.

const StateSet::RefAttributePair * StateSet::getAttributePair | ( | const AttributeList & | attributeList,
|  | const StateAttribute::Type | type,
|  | unsigned int | member
| ) | const`[protected]`

const StateSet::RefAttributePair * StateSet::getAttributePair | ( | StateAttribute::Type | type,
|  | unsigned int | member = `0`
| ) | const

| Get specified RefAttributePair for specified type. Returns NULL if no type is contained within StateSet.

const std::string& osg::StateSet::getBinName | ( |  | ) | const`[inline]`

| Get the render bin name.

int osg::StateSet::getBinNumber | ( |  | ) | const`[inline]`

| Get the render bin number.

StateAttribute::GLModeValue StateSet::getMode | ( | const ModeList & | modeList,
|  | StateAttribute::GLMode | mode
| ) | const`[protected]`

StateAttribute::GLModeValue StateSet::getMode | ( | StateAttribute::GLMode | mode | ) | const

| Get specified GLModeValue for specified GLMode. returns INHERIT if no GLModeValue is contained within StateSet.

const ModeList& osg::StateSet::getModeList | ( |  | ) | const`[inline]`

| return the const list of all GLModes contained in this const StateSet.

ModeList& osg::StateSet::getModeList | ( |  | ) | `[inline]`

| return the list of all GLModes contained in this StateSet.

AttributeList& osg::StateSet::getOrCreateTextureAttributeList | ( | unsigned int | unit | ) | `[inline, protected]`

ModeList& osg::StateSet::getOrCreateTextureModeList | ( | unsigned int | unit | ) | `[inline, protected]`

RenderBinMode osg::StateSet::getRenderBinMode | ( |  | ) | const`[inline]`

| Get the render bin mode.

int osg::StateSet::getRenderingHint | ( |  | ) | const`[inline]`

| Get the RenderingHint of the StateSet.

const StateAttribute * StateSet::getTextureAttribute | ( | unsigned int | unit,
|  | StateAttribute::Type | type
| ) | const

| Get specified Texture related const StateAttribute for specified type. Returns NULL if no type is contained within const StateSet.

StateAttribute * StateSet::getTextureAttribute | ( | unsigned int | unit,
|  | StateAttribute::Type | type
| ) |

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

const TextureAttributeList& osg::StateSet::getTextureAttributeList | ( |  | ) | const`[inline]`

| Return the const list of all Texture related StateAttributes contained in this const StateSet.

TextureAttributeList& osg::StateSet::getTextureAttributeList | ( |  | ) | `[inline]`

| Return the list of all Texture related StateAttributes contained in this StateSet.

const StateSet::RefAttributePair * StateSet::getTextureAttributePair | ( | unsigned int | unit,
|  | StateAttribute::Type | type
| ) | const

| Get specified Texture related RefAttributePair for specified type. Returns NULL if no type is contained within StateSet.

StateAttribute::GLModeValue StateSet::getTextureMode | ( | unsigned int | unit,
|  | StateAttribute::GLMode | mode
| ) | const

| Get specified GLModeValue for specified GLMode. returns INHERIT if no GLModeValue is contained within StateSet.

const TextureModeList& osg::StateSet::getTextureModeList | ( |  | ) | const`[inline]`

| return the const list of all Texture related GLModes contained in this const StateSet.

TextureModeList& osg::StateSet::getTextureModeList | ( |  | ) | `[inline]`

| return the list of all Texture related GLModes contained in this StateSet.

virtual bool osg::StateSet::isSameKindAs | ( | const Object * | obj | ) | const`[inline, virtual]`

| Reimplemented from osg::Object.

virtual const char* osg::StateSet::libraryName | ( |  | ) | const`[inline, virtual]`

| return the name of the object's library. Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name. Implements osg::Object.

void StateSet::merge | ( | const StateSet & | rhs | ) |

| merge this stateset with stateset rhs, this overrides the rhs if OVERRIDE is specified, otherwise rhs takes precedence.

bool osg::StateSet::operator!= | ( | const StateSet & | rhs | ) | const`[inline]`

bool osg::StateSet::operator< | ( | const StateSet & | rhs | ) | const`[inline]`

StateSet& osg::StateSet::operator= | ( | const StateSet & |  | ) | `[inline, protected]`

bool osg::StateSet::operator== | ( | const StateSet & | rhs | ) | const`[inline]`

void StateSet::releaseGLObjects | ( | State * | state = `0` | ) | const`[virtual]`

| call release on all StateAttributes contained within this StateSet.

void StateSet::removeAttribute | ( | StateAttribute * | attribute | ) |

| remove attribute from StateSet.

void StateSet::removeAttribute | ( | StateAttribute::Type | type,
|  | unsigned int | member = `0`
| ) |

| remove attribute of specified type from StateSet.

void StateSet::removeMode | ( | StateAttribute::GLMode | mode | ) |

| Remove mode from StateSet.

void StateSet::removeTextureAttribute | ( | unsigned int | unit,
|  | StateAttribute * | attribute
| ) |

| remove texture attribute from StateSet.

void StateSet::removeTextureAttribute | ( | unsigned int | unit,
|  | StateAttribute::Type | type
| ) |

| remove texture attribute of specified type from StateSet.

void StateSet::removeTextureMode | ( | unsigned int | unit,
|  | StateAttribute::GLMode | mode
| ) |

| Remove texture mode from StateSet.

void StateSet::setAssociatedModes | ( | const StateAttribute * | attribute,
|  | StateAttribute::GLModeValue | value
| ) |

void StateSet::setAssociatedTextureModes | ( | unsigned int | unit,
|  | const StateAttribute * | attribute,
|  | StateAttribute::GLModeValue | value
| ) |

void StateSet::setAttribute | ( | AttributeList & | attributeList,
|  | StateAttribute * | attribute,
|  | const StateAttribute::OverrideValue | value = `StateAttribute::OFF`
| ) | `[protected]`

void StateSet::setAttribute | ( | StateAttribute * | attribute,
|  | StateAttribute::OverrideValue | value = `StateAttribute::OFF`
| ) |

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

void StateSet::setAttributeAndModes | ( | StateAttribute * | attribute,
|  | StateAttribute::GLModeValue | value = `StateAttribute::ON`
| ) |

| Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.

void StateSet::setGlobalDefaults | ( |  | ) |

| Set all the modes to on or off so that it defines a complete state, typically used for a default global state.

void StateSet::setMode | ( | ModeList & | modeList,
|  | StateAttribute::GLMode | mode,
|  | StateAttribute::GLModeValue | value
| ) | `[protected]`

void StateSet::setMode | ( | StateAttribute::GLMode | mode,
|  | StateAttribute::GLModeValue | value
| ) |

| Set this StateSet to contain specified GLMode and value.

void StateSet::setModeToInherit | ( | ModeList & | modeList,
|  | StateAttribute::GLMode | mode
| ) | `[protected]`

void StateSet::setRenderBinDetails | ( | int | binNum,
|  | const std::string & | binName,
|  | RenderBinMode | mode = `USE_RENDERBIN_DETAILS`
| ) |

| Set the render bin details.

void StateSet::setRenderBinToInherit | ( |  | ) |

| Set the render bin details to inherit.

void StateSet::setRenderingHint | ( | int | hint | ) |

| Set the RenderingHint of the StateSet. RenderingHint is used by osgUtil::Renderer to determine which draw bin to drop associated osg::Drawables in. For opaque objects OPAQUE_BIN would typical used, which TRANSPARENT_BIN should be used for objects which need to be depth sorted.

void StateSet::setTextureAttribute | ( | unsigned int | unit,
|  | StateAttribute * | attribute,
|  | StateAttribute::OverrideValue | value = `StateAttribute::OFF`
| ) |

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

void StateSet::setTextureAttributeAndModes | ( | unsigned int | unit,
|  | StateAttribute * | attribute,
|  | StateAttribute::GLModeValue | value = `StateAttribute::ON`
| ) |

| Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.

void StateSet::setTextureMode | ( | unsigned int | unit,
|  | StateAttribute::GLMode | mode,
|  | StateAttribute::GLModeValue | value
| ) |

| Set this StateSet to contain specified GLMode and value.

bool osg::StateSet::useRenderBinDetails | ( |  | ) | const`[inline]`

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

## Member Data Documentation

AttributeList osg::StateSet::_attributeList `[protected]`

RenderBinMode osg::StateSet::_binMode `[protected]`

std::string osg::StateSet::_binName `[protected]`

int osg::StateSet::_binNum `[protected]`

ModeList osg::StateSet::_modeList `[protected]`

int osg::StateSet::_renderingHint `[protected]`

TextureAttributeList osg::StateSet::_textureAttributeList `[protected]`

TextureModeList osg::StateSet::_textureModeList `[protected]`

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

- StateSet
- StateSet.cpp