osg::State Class Reference

Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings, implements lazy state updating and provides accessors for querrying the current state. More...

Inheritance diagram for osg::State:

Inheritance graph
[legend]

List of all members.

Public Types

enum  CheckForGLErrors { NEVER_CHECK_GL_ERRORS, ONCE_PER_FRAME, ONCE_PER_ATTRIBUTE }
typedef std::vector
< const StateSet * > 
StateSetStack

Public Member Functions

 State ()
void setGraphicsContext (GraphicsContext *context)
 Set the graphics context associated with that owns this State object.
GraphicsContextgetGraphicsContext ()
 Get the graphics context associated with that owns this State object.
const GraphicsContextgetGraphicsContext () const
 Get the const graphics context associated with that owns this State object.
void setContextID (unsigned int contextID)
 Set the current OpenGL context uniqueID.
unsigned int getContextID () const
 Get the current OpenGL context unique ID.
void pushStateSet (const StateSet *dstate)
 Push stateset onto state stack.
void popStateSet ()
 Pop stateset off state stack.
void popAllStateSets ()
 pop all statesets off state stack, ensuring it is empty ready for the next frame.
void insertStateSet (unsigned int pos, const StateSet *dstate)
 Insert stateset onto state stack.
void removeStateSet (unsigned int pos)
 Pop stateset off state stack.
unsigned int getStateSetStackSize ()
 Get the number of StateSet's on the StateSet stack.
void popStateSetStackToSize (unsigned int size)
 Pop StateSet's for the StateSet stack till its size equals the specified size.
StateSetStackgetStateSetStack ()
 Get the StateSet stack.
void captureCurrentState (StateSet &stateset) const
 Copy the modes and attributes which capture the current state.
void reset ()
 reset the state object to an empty stack.
const ViewportgetCurrentViewport () const
void setInitialViewMatrix (const osg::RefMatrix *matrix)
const osg::MatrixgetInitialViewMatrix () const
const osg::MatrixgetInitialInverseViewMatrix () const
void applyProjectionMatrix (const osg::RefMatrix *matrix)
const osg::MatrixgetProjectionMatrix () const
void applyModelViewMatrix (const osg::RefMatrix *matrix)
const osg::MatrixgetModelViewMatrix () const
Polytope getViewFrustum () const
void apply (const StateSet *dstate)
 Apply stateset.
void apply ()
 Updates the OpenGL state so that it matches the StateSet at the top of the stack of StateSets maintained internally by a State.
void setModeValidity (StateAttribute::GLMode mode, bool valid)
 Set whether a particular OpenGL mode is valid in the current graphics context.
bool getModeValidity (StateAttribute::GLMode mode)
 Get whether a particular OpenGL mode is valid in the current graphics context.
void setGlobalDefaultModeValue (StateAttribute::GLMode mode, bool enabled)
bool getGlobalDefaultModeValue (StateAttribute::GLMode mode)
bool applyMode (StateAttribute::GLMode mode, bool enabled)
 Apply an OpenGL mode if required.
void setGlobalDefaultTextureModeValue (unsigned int unit, StateAttribute::GLMode mode, bool enabled)
bool getGlobalDefaultTextureModeValue (unsigned int unit, StateAttribute::GLMode mode)
bool applyTextureMode (unsigned int unit, StateAttribute::GLMode mode, bool enabled)
void setGlobalDefaultAttribute (const StateAttribute *attribute)
const StateAttributegetGlobalDefaultAttribute (StateAttribute::Type type, unsigned int member=0)
bool applyAttribute (const StateAttribute *attribute)
 Apply an attribute if required.
void setGlobalDefaultTextureAttribute (unsigned int unit, const StateAttribute *attribute)
const StateAttributegetGlobalDefaultTextureAttribute (unsigned int unit, StateAttribute::Type type, unsigned int member=0)
bool applyTextureAttribute (unsigned int unit, const StateAttribute *attribute)
void haveAppliedMode (StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
 Mode has been set externally, update state to reflect this setting.
void haveAppliedMode (StateAttribute::GLMode mode)
 Mode has been set externally, therefore dirty the associated mode in osg::State so it is applied on next call to osg::State::apply(.
void haveAppliedAttribute (const StateAttribute *attribute)
 Attribute has been applied externally, update state to reflect this setting.
void haveAppliedAttribute (StateAttribute::Type type, unsigned int member=0)
 Attribute has been applied externally, and therefore this attribute type has been dirtied and will need to be re-applied on next osg::State.apply(.
bool getLastAppliedMode (StateAttribute::GLMode mode) const
 Get whether the current specified mode is enabled (true) or disabled (false).
const StateAttributegetLastAppliedAttribute (StateAttribute::Type type, unsigned int member=0) const
 Get the current specified attribute, return NULL if one has not yet been applied.
void haveAppliedTextureMode (unsigned int unit, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
 texture Mode has been set externally, update state to reflect this setting.
void haveAppliedTextureMode (unsigned int unit, StateAttribute::GLMode mode)
 texture Mode has been set externally, therefore dirty the associated mode in osg::State so it is applied on next call to osg::State::apply(.
void haveAppliedTextureAttribute (unsigned int unit, const StateAttribute *attribute)
 texture Attribute has been applied externally, update state to reflect this setting.
void haveAppliedTextureAttribute (unsigned int unit, StateAttribute::Type type, unsigned int member=0)
 texture Attribute has been applied externally, and therefore this attribute type has been dirtied and will need to be re-appplied on next osg::State.apply(.
bool getLastAppliedTextureMode (unsigned int unit, StateAttribute::GLMode mode) const
 Get whether the current specified texture mode is enabled (true) or disabled (false).
const StateAttributegetLastAppliedTextureAttribute (unsigned int unit, StateAttribute::Type type, unsigned int member=0) const
 Get the current specified texture attribute, return NULL if one has not yet been applied.
void dirtyAllModes ()
 Dirty the modes previously applied in osg::State.
void dirtyAllAttributes ()
 Dirty the modes attributes previously applied in osg::State.
void disableAllVertexArrays ()
 disable the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.
void dirtyAllVertexArrays ()
 dirty the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.
void setCurrentVertexBufferObject (osg::VertexBufferObject *vbo)
const
VertexBufferObject
getCurrentVertexBufferObject ()
void bindVertexBufferObject (const osg::VertexBufferObject *vbo)
void unbindVertexBufferObject ()
void setCurrentElementBufferObject (osg::ElementBufferObject *ebo)
const
ElementBufferObject
getCurrentElementBufferObject ()
void bindElementBufferObject (const osg::ElementBufferObject *ebo)
void unbindElementBufferObject ()
void setCurrentPixelBufferObject (osg::PixelBufferObject *pbo)
const PixelBufferObjectgetCurrentPixelBufferObject ()
void bindPixelBufferObject (const osg::PixelBufferObject *pbo)
void unbindPixelBufferObject ()
void setInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer)
 Wrapper around glInterleavedArrays(.
void setVertexPointer (const Array *array)
 Set the vertex pointer using an osg::Array, and manage any VBO that are required.
void setVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(.
void disableVertexPointer ()
 wrapper around glDisableClientState(GL_VERTEX_ARRAY).
void dirtyVertexPointer ()
void setNormalPointer (const Array *array)
 Set the normal pointer using an osg::Array, and manage any VBO that are required.
void setNormalPointer (GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(.
void disableNormalPointer ()
 wrapper around glDisableClientState(GL_NORMAL_ARRAY); note, only updates values that change.
void dirtyNormalPointer ()
void setColorPointer (const Array *array)
 Set the color pointer using an osg::Array, and manage any VBO that are required.
void setColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(.
void disableColorPointer ()
 wrapper around glDisableClientState(GL_COLOR_ARRAY); note, only updates values that change.
void dirtyColorPointer ()
bool isSecondaryColorSupported () const
void setSecondaryColorPointer (const Array *array)
 Set the secondary color pointer using an osg::Array, and manage any VBO that are required.
void setSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(.
void disableSecondaryColorPointer ()
 wrapper around glDisableClientState(GL_SECONDARY_COLOR_ARRAY); note, only updates values that change.
void dirtySecondaryColorPointer ()
void setIndexPointer (GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(.
void disableIndexPointer ()
 wrapper around glDisableClientState(GL_INDEX_ARRAY); note, only updates values that change.
void dirtyIndexPointer ()
bool isFogCoordSupported () const
void setFogCoordPointer (const Array *array)
 Set the fog coord pointer using an osg::Array, and manage any VBO that are required.
void setFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(.
void disableFogCoordPointer ()
 wrapper around glDisableClientState(GL_FOG_COORDINATE_ARRAY); note, only updates values that change.
void dirtyFogCoordPointer ()
void setTexCoordPointer (unsigned int unit, const Array *array)
 Set the tex coord pointer using an osg::Array, and manage any VBO that are required.
void setTexCoordPointer (unsigned int unit, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(.
void disableTexCoordPointer (unsigned int unit)
 wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY); note, only updates values that change.
void dirtyTexCoordPointer (unsigned int unit)
void disableTexCoordPointersAboveAndIncluding (unsigned int unit)
void dirtyTexCoordPointersAboveAndIncluding (unsigned int unit)
bool setActiveTextureUnit (unsigned int unit)
 Set the current texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
unsigned int getActiveTextureUnit () const
 Get the current texture unit.
bool setClientActiveTextureUnit (unsigned int unit)
 Set the current tex coord array texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
unsigned int getClientActiveTextureUnit () const
 Get the current tex coord array texture unit.
void setVertexAttribPointer (unsigned int unit, const Array *array, GLboolean normalized)
 Set the vertex attrib pointer using an osg::Array, and manage any VBO that are required.
void setVertexAttribPointer (unsigned int index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *ptr)
 wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(.
void disableVertexAttribPointer (unsigned int index)
 wrapper around DisableVertexAttribArrayARB(index); note, only updates values that change.
void disableVertexAttribPointersAboveAndIncluding (unsigned int index)
void dirtyVertexAttribPointersAboveAndIncluding (unsigned int index)
bool isVertexBufferObjectSupported () const
void setLastAppliedProgramObject (const Program::PerContextProgram *program)
const
Program::PerContextProgram
getLastAppliedProgramObject () const
GLint getUniformLocation (const std::string &name) const
GLint getAttribLocation (const std::string &name) const
void setFrameStamp (FrameStamp *fs)
 Set the frame stamp for the current frame.
FrameStampgetFrameStamp ()
 Get the frame stamp for the current frame.
const FrameStampgetFrameStamp () const
 Get the const frame stamp for the current frame.
void setDisplaySettings (DisplaySettings *vs)
 Set the DisplaySettings.
const DisplaySettingsgetDisplaySettings () const
 Get the DisplaySettings.
void setAbortRenderingPtr (bool *abortPtr)
 Set flag for early termination of the draw traversal.
bool getAbortRendering () const
 Get flag for early termination of the draw traversal, if true steps should be taken to complete rendering early.
void setDynamicObjectRenderingCompletedCallback (DynamicObjectRenderingCompletedCallback *cb)
 Set the callback to be called when the dynamic object count hits 0.
DynamicObjectRenderingCompletedCallbackgetDynamicObjectRenderingCompletedCallback ()
 Get the callback to be called when the dynamic object count hits 0.
void setDynamicObjectCount (unsigned int count, bool callCallbackOnZero=false)
 Set the number of dynamic objects that will be rendered in this graphics context this frame.
unsigned int getDynamicObjectCount () const
 Get the number of dynamic objects that will be rendered in this graphics context this frame.
void decrementDynamicObjectCount ()
 Decrement the number of dynamic objects left to render this frame, and once the count goes to zero call the DynamicObjectRenderingCompletedCallback to inform of completion.
void setCheckForGLErrors (CheckForGLErrors check)
 Set whether and how often OpenGL errors should be checked for.
CheckForGLErrors getCheckForGLErrors () const
 Get whether and how often OpenGL errors should be checked for.
bool checkGLErrors (const char *str) const
bool checkGLErrors (StateAttribute::GLMode mode) const
bool checkGLErrors (const StateAttribute *attribute) const
void initializeExtensionProcs ()
 Initialize extension used by osg:State.

Protected Types

typedef std::map
< StateAttribute::GLMode,
ModeStack
ModeMap
typedef std::vector
< ModeMap
TextureModeMapList
typedef std::map
< StateAttribute::TypeMemberPair,
AttributeStack
AttributeMap
typedef std::vector
< AttributeMap
TextureAttributeMapList
typedef std::map
< std::string,
UniformStack
UniformMap
typedef std::vector
< ref_ptr< const
Matrix > > 
MatrixStack
typedef std::set
< osg::ref_ptr
< const
Program::PerContextProgram > > 
AppliedProgramObjectSet
typedef std::vector
< EnabledArrayPair
EnabledTexCoordArrayList
typedef std::vector
< EnabledArrayPair
EnabledVertexAttribArrayList
typedef GLsizei stride
typedef GLsizei
const GLvoid * 
pointer
typedef GLenum type
typedef GLenum GLsizei stride
typedef GLenum
GLsizei const GLvoid * 
pointer
typedef GLboolean normalized
typedef GLboolean GLsizei stride
typedef GLboolean
GLsizei const GLvoid * 
pointer
typedef GLuint buffer

Protected Member Functions

virtual ~State ()
bool applyMode (StateAttribute::GLMode mode, bool enabled, ModeStack &ms)
 Apply an OpenGL mode if required, passing in mode, enable flag and appropriate mode stack.
bool applyAttribute (const StateAttribute *attribute, AttributeStack &as)
 apply an attribute if required, passing in attribute and appropriate attribute stack
bool applyGlobalDefaultAttribute (AttributeStack &as)
ModeMapgetOrCreateTextureModeMap (unsigned int unit)
AttributeMapgetOrCreateTextureAttributeMap (unsigned int unit)
void pushModeList (ModeMap &modeMap, const StateSet::ModeList &modeList)
void pushAttributeList (AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
void pushUniformList (UniformMap &uniformMap, const StateSet::UniformList &uniformList)
void popModeList (ModeMap &modeMap, const StateSet::ModeList &modeList)
void popAttributeList (AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
void popUniformList (UniformMap &uniformMap, const StateSet::UniformList &uniformList)
void applyModeList (ModeMap &modeMap, const StateSet::ModeList &modeList)
void applyAttributeList (AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
void applyUniformList (UniformMap &uniformMap, const StateSet::UniformList &uniformList)
void applyModeMap (ModeMap &modeMap)
void applyAttributeMap (AttributeMap &attributeMap)
void applyUniformMap (UniformMap &uniformMap)
void haveAppliedMode (ModeMap &modeMap, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
void haveAppliedMode (ModeMap &modeMap, StateAttribute::GLMode mode)
void haveAppliedAttribute (AttributeMap &attributeMap, const StateAttribute *attribute)
void haveAppliedAttribute (AttributeMap &attributeMap, StateAttribute::Type type, unsigned int member)
bool getLastAppliedMode (const ModeMap &modeMap, StateAttribute::GLMode mode) const
const StateAttributegetLastAppliedAttribute (const AttributeMap &attributeMap, StateAttribute::Type type, unsigned int member) const
bool computeSecondaryColorSupported () const
bool computeFogCoordSupported () const
bool computeVertexBufferObjectSupported () const
typedef void (APIENTRY *ActiveTextureProc)(GLenum texture)
typedef void (APIENTRY *FogCoordPointerProc)(GLenum type
typedef void (APIENTRY *SecondaryColorPointerProc)(GLint size
typedef void (APIENTRY *VertexAttribPointerProc)(unsigned int
typedef void (APIENTRY *EnableVertexAttribProc)(unsigned int)
typedef void (APIENTRY *DisableVertexAttribProc)(unsigned int)
typedef void (APIENTRY *BindBufferProc)(GLenum target

Protected Attributes

GraphicsContext_graphicsContext
unsigned int _contextID
ref_ptr< FrameStamp_frameStamp
ref_ptr< const
RefMatrix
_identity
ref_ptr< const
RefMatrix
_initialViewMatrix
ref_ptr< const
RefMatrix
_projection
ref_ptr< const
RefMatrix
_modelView
Matrix _initialInverseViewMatrix
ref_ptr
< DisplaySettings
_displaySettings
bool * _abortRenderingPtr
CheckForGLErrors _checkGLErrors
ModeMap _modeMap
AttributeMap _attributeMap
UniformMap _uniformMap
TextureModeMapList _textureModeMapList
TextureAttributeMapList _textureAttributeMapList
AppliedProgramObjectSet _appliedProgramObjectSet
const
Program::PerContextProgram
_lastAppliedProgramObject
StateSetStack _stateStateStack
EnabledArrayPair _vertexArray
EnabledArrayPair _normalArray
EnabledArrayPair _colorArray
EnabledArrayPair _secondaryColorArray
EnabledArrayPair _indexArray
EnabledArrayPair _fogArray
EnabledTexCoordArrayList _texCoordArrayList
EnabledVertexAttribArrayList _vertexAttribArrayList
unsigned int _currentActiveTextureUnit
unsigned int _currentClientActiveTextureUnit
const
VertexBufferObject
_currentVBO
const
ElementBufferObject
_currentEBO
const PixelBufferObject_currentPBO
bool _isSecondaryColorSupportResolved
bool _isSecondaryColorSupported
bool _isFogCoordSupportResolved
bool _isFogCoordSupported
bool _isVertexBufferObjectSupportResolved
bool _isVertexBufferObjectSupported
typedef GLint
typedef GLenum
bool _extensionProcsInitialized
GLint _glMaxTextureCoords
GLint _glMaxTextureUnits
ActiveTextureProc _glClientActiveTexture
ActiveTextureProc _glActiveTexture
FogCoordPointerProc _glFogCoordPointer
SecondaryColorPointerProc _glSecondaryColorPointer
VertexAttribPointerProc _glVertexAttribPointer
EnableVertexAttribProc _glEnableVertexAttribArray
DisableVertexAttribProc _glDisableVertexAttribArray
BindBufferProc _glBindBuffer
unsigned int _dynamicObjectCount
osg::ref_ptr
< DynamicObjectRenderingCompletedCallback
_completeDynamicObjectRenderingCallback

Classes

struct  AttributeStack
struct  DynamicObjectRenderingCompletedCallback
struct  EnabledArrayPair
struct  ModeStack
struct  UniformStack


Detailed Description

Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings, implements lazy state updating and provides accessors for querrying the current state.

. The venerable Red Book says that "OpenGL is a state machine", and this class represents the OpenGL state in OSG. Furthermore, State also has other important features:


Member Typedef Documentation

typedef std::vector<const StateSet*> osg::State::StateSetStack

typedef std::map<StateAttribute::GLMode,ModeStack> osg::State::ModeMap [protected]

typedef std::vector<ModeMap> osg::State::TextureModeMapList [protected]

typedef std::map<StateAttribute::TypeMemberPair,AttributeStack> osg::State::AttributeMap [protected]

typedef std::vector<AttributeMap> osg::State::TextureAttributeMapList [protected]

typedef std::map<std::string,UniformStack> osg::State::UniformMap [protected]

typedef std::vector<ref_ptr<const Matrix> > osg::State::MatrixStack [protected]

typedef std::set<osg::ref_ptr<const Program::PerContextProgram> > osg::State::AppliedProgramObjectSet [protected]

typedef std::vector<EnabledArrayPair> osg::State::EnabledTexCoordArrayList [protected]

typedef std::vector<EnabledArrayPair> osg::State::EnabledVertexAttribArrayList [protected]

typedef GLsizei osg::State::stride [protected]

typedef GLsizei const GLvoid* osg::State::pointer [protected]

typedef GLenum osg::State::type [protected]

typedef GLenum GLsizei osg::State::stride [protected]

typedef GLenum GLsizei const GLvoid* osg::State::pointer [protected]

typedef GLboolean osg::State::normalized [protected]

typedef GLboolean GLsizei osg::State::stride [protected]

typedef GLboolean GLsizei const GLvoid* osg::State::pointer [protected]

typedef GLuint osg::State::buffer [protected]


Member Enumeration Documentation

enum osg::State::CheckForGLErrors

Enumerator:
NEVER_CHECK_GL_ERRORS  NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this is the fastest option since checking for errors does incurr a small overhead.

ONCE_PER_FRAME  ONCE_PER_FRAME means that OpenGl errors will be checked for once per frame, the overhead is still small, but at least OpenGL errors that are occurring will be caught, the reporting isn't fine grained enough for debugging purposes.

ONCE_PER_ATTRIBUTE  ONCE_PER_ATTRIBUTE means that OpenGL errors will be checked for after every attribute is applied, allow errors to be directly associated with particular operations which makes debugging much easier.


Constructor & Destructor Documentation

osg::State::State (  ) 

virtual osg::State::~State (  )  [protected, virtual]


Member Function Documentation

void osg::State::setGraphicsContext ( GraphicsContext context  )  [inline]

Set the graphics context associated with that owns this State object.

GraphicsContext* osg::State::getGraphicsContext (  )  [inline]

Get the graphics context associated with that owns this State object.

const GraphicsContext* osg::State::getGraphicsContext (  )  const [inline]

Get the const graphics context associated with that owns this State object.

void osg::State::setContextID ( unsigned int  contextID  )  [inline]

Set the current OpenGL context uniqueID.

Note, it is the application developers responsibility to set up unique ID for each OpenGL context. This value is then used by osg::StateAttribute's and osg::Drawable's to help manage OpenGL display list and texture binds appropriate for each context, the contextID simply acts as an index in local arrays that they maintain for the purpose. Typical settings for contextID are 0,1,2,3... up to the maximum number of graphics contexts you have set up. By default contextID is 0.

unsigned int osg::State::getContextID (  )  const [inline]

Get the current OpenGL context unique ID.

void osg::State::pushStateSet ( const StateSet dstate  ) 

Push stateset onto state stack.

void osg::State::popStateSet (  ) 

Pop stateset off state stack.

void osg::State::popAllStateSets (  ) 

pop all statesets off state stack, ensuring it is empty ready for the next frame.

Note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().

void osg::State::insertStateSet ( unsigned int  pos,
const StateSet dstate 
)

Insert stateset onto state stack.

void osg::State::removeStateSet ( unsigned int  pos  ) 

Pop stateset off state stack.

unsigned int osg::State::getStateSetStackSize (  )  [inline]

Get the number of StateSet's on the StateSet stack.

void osg::State::popStateSetStackToSize ( unsigned int  size  )  [inline]

Pop StateSet's for the StateSet stack till its size equals the specified size.

StateSetStack& osg::State::getStateSetStack (  )  [inline]

Get the StateSet stack.

void osg::State::captureCurrentState ( StateSet stateset  )  const

Copy the modes and attributes which capture the current state.

void osg::State::reset (  ) 

reset the state object to an empty stack.

const Viewport* osg::State::getCurrentViewport (  )  const [inline]

void osg::State::setInitialViewMatrix ( const osg::RefMatrix matrix  ) 

const osg::Matrix& osg::State::getInitialViewMatrix (  )  const [inline]

const osg::Matrix& osg::State::getInitialInverseViewMatrix (  )  const [inline]

void osg::State::applyProjectionMatrix ( const osg::RefMatrix matrix  )  [inline]

const osg::Matrix& osg::State::getProjectionMatrix (  )  const [inline]

void osg::State::applyModelViewMatrix ( const osg::RefMatrix matrix  )  [inline]

const osg::Matrix& osg::State::getModelViewMatrix (  )  const [inline]

Polytope osg::State::getViewFrustum (  )  const

void osg::State::apply ( const StateSet dstate  ) 

Apply stateset.

void osg::State::apply (  ) 

Updates the OpenGL state so that it matches the StateSet at the top of the stack of StateSets maintained internally by a State.

void osg::State::setModeValidity ( StateAttribute::GLMode  mode,
bool  valid 
) [inline]

Set whether a particular OpenGL mode is valid in the current graphics context.

Use to disable OpenGL modes that are not supported by current graphics drivers/context.

bool osg::State::getModeValidity ( StateAttribute::GLMode  mode  )  [inline]

Get whether a particular OpenGL mode is valid in the current graphics context.

Use to disable OpenGL modes that are not supported by current graphics drivers/context.

void osg::State::setGlobalDefaultModeValue ( StateAttribute::GLMode  mode,
bool  enabled 
) [inline]

bool osg::State::getGlobalDefaultModeValue ( StateAttribute::GLMode  mode  )  [inline]

bool osg::State::applyMode ( StateAttribute::GLMode  mode,
bool  enabled 
) [inline]

Apply an OpenGL mode if required.

This is a wrapper around glEnable() and glDisable(), that just actually calls these functions if the enabled flag is different than the current state.

Returns:
true if the state was actually changed. false otherwise. Notice that a false return does not indicate an error, it just means that the mode was already set to the same value as the enabled parameter.

void osg::State::setGlobalDefaultTextureModeValue ( unsigned int  unit,
StateAttribute::GLMode  mode,
bool  enabled 
) [inline]

bool osg::State::getGlobalDefaultTextureModeValue ( unsigned int  unit,
StateAttribute::GLMode  mode 
) [inline]

bool osg::State::applyTextureMode ( unsigned int  unit,
StateAttribute::GLMode  mode,
bool  enabled 
) [inline]

void osg::State::setGlobalDefaultAttribute ( const StateAttribute attribute  )  [inline]

const StateAttribute* osg::State::getGlobalDefaultAttribute ( StateAttribute::Type  type,
unsigned int  member = 0 
) [inline]

bool osg::State::applyAttribute ( const StateAttribute attribute  )  [inline]

Apply an attribute if required.

void osg::State::setGlobalDefaultTextureAttribute ( unsigned int  unit,
const StateAttribute attribute 
) [inline]

const StateAttribute* osg::State::getGlobalDefaultTextureAttribute ( unsigned int  unit,
StateAttribute::Type  type,
unsigned int  member = 0 
) [inline]

bool osg::State::applyTextureAttribute ( unsigned int  unit,
const StateAttribute attribute 
) [inline]

void osg::State::haveAppliedMode ( StateAttribute::GLMode  mode,
StateAttribute::GLModeValue  value 
)

Mode has been set externally, update state to reflect this setting.

void osg::State::haveAppliedMode ( StateAttribute::GLMode  mode  ) 

Mode has been set externally, therefore dirty the associated mode in osg::State so it is applied on next call to osg::State::apply(.

.)

void osg::State::haveAppliedAttribute ( const StateAttribute attribute  ) 

Attribute has been applied externally, update state to reflect this setting.

void osg::State::haveAppliedAttribute ( StateAttribute::Type  type,
unsigned int  member = 0 
)

Attribute has been applied externally, and therefore this attribute type has been dirtied and will need to be re-applied on next osg::State.apply(.

.). note, if you have an osg::StateAttribute which you have applied externally then use the have_applied(attribute) method as this will cause the osg::State to track the current state more accurately and enable lazy state updating such that only changed state will be applied.

bool osg::State::getLastAppliedMode ( StateAttribute::GLMode  mode  )  const

Get whether the current specified mode is enabled (true) or disabled (false).

const StateAttribute* osg::State::getLastAppliedAttribute ( StateAttribute::Type  type,
unsigned int  member = 0 
) const

Get the current specified attribute, return NULL if one has not yet been applied.

void osg::State::haveAppliedTextureMode ( unsigned int  unit,
StateAttribute::GLMode  mode,
StateAttribute::GLModeValue  value 
)

texture Mode has been set externally, update state to reflect this setting.

void osg::State::haveAppliedTextureMode ( unsigned int  unit,
StateAttribute::GLMode  mode 
)

texture Mode has been set externally, therefore dirty the associated mode in osg::State so it is applied on next call to osg::State::apply(.

.)

void osg::State::haveAppliedTextureAttribute ( unsigned int  unit,
const StateAttribute attribute 
)

texture Attribute has been applied externally, update state to reflect this setting.

void osg::State::haveAppliedTextureAttribute ( unsigned int  unit,
StateAttribute::Type  type,
unsigned int  member = 0 
)

texture Attribute has been applied externally, and therefore this attribute type has been dirtied and will need to be re-appplied on next osg::State.apply(.

.). note, if you have an osg::StateAttribute which you have applied externally then use the have_applied(attribute) method as this will the osg::State to track the current state more accurately and enable lazy state updating such that only changed state will be applied.

bool osg::State::getLastAppliedTextureMode ( unsigned int  unit,
StateAttribute::GLMode  mode 
) const

Get whether the current specified texture mode is enabled (true) or disabled (false).

const StateAttribute* osg::State::getLastAppliedTextureAttribute ( unsigned int  unit,
StateAttribute::Type  type,
unsigned int  member = 0 
) const

Get the current specified texture attribute, return NULL if one has not yet been applied.

void osg::State::dirtyAllModes (  ) 

Dirty the modes previously applied in osg::State.

void osg::State::dirtyAllAttributes (  ) 

Dirty the modes attributes previously applied in osg::State.

void osg::State::disableAllVertexArrays (  ) 

disable the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.

void osg::State::dirtyAllVertexArrays (  ) 

dirty the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.

void osg::State::setCurrentVertexBufferObject ( osg::VertexBufferObject vbo  )  [inline]

const VertexBufferObject* osg::State::getCurrentVertexBufferObject (  )  [inline]

void osg::State::bindVertexBufferObject ( const osg::VertexBufferObject vbo  )  [inline]

void osg::State::unbindVertexBufferObject (  )  [inline]

void osg::State::setCurrentElementBufferObject ( osg::ElementBufferObject ebo  )  [inline]

const ElementBufferObject* osg::State::getCurrentElementBufferObject (  )  [inline]

void osg::State::bindElementBufferObject ( const osg::ElementBufferObject ebo  )  [inline]

void osg::State::unbindElementBufferObject (  )  [inline]

void osg::State::setCurrentPixelBufferObject ( osg::PixelBufferObject pbo  )  [inline]

const PixelBufferObject* osg::State::getCurrentPixelBufferObject (  )  [inline]

void osg::State::bindPixelBufferObject ( const osg::PixelBufferObject pbo  )  [inline]

void osg::State::unbindPixelBufferObject (  )  [inline]

void osg::State::setInterleavedArrays ( GLenum  format,
GLsizei  stride,
const GLvoid *  pointer 
)

Wrapper around glInterleavedArrays(.

.). also resets the internal array points and modes within osg::State to keep the other vertex array operations consistent.

void osg::State::setVertexPointer ( const Array array  )  [inline]

Set the vertex pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setVertexPointer ( GLint  size,
GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
) [inline]

wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(.

.); note, only updates values that change.

void osg::State::disableVertexPointer (  )  [inline]

wrapper around glDisableClientState(GL_VERTEX_ARRAY).

note, only updates values that change.

void osg::State::dirtyVertexPointer (  )  [inline]

void osg::State::setNormalPointer ( const Array array  )  [inline]

Set the normal pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setNormalPointer ( GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
) [inline]

wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(.

.); note, only updates values that change.

void osg::State::disableNormalPointer (  )  [inline]

wrapper around glDisableClientState(GL_NORMAL_ARRAY); note, only updates values that change.

void osg::State::dirtyNormalPointer (  )  [inline]

void osg::State::setColorPointer ( const Array array  )  [inline]

Set the color pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setColorPointer ( GLint  size,
GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
) [inline]

wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(.

.); note, only updates values that change.

void osg::State::disableColorPointer (  )  [inline]

wrapper around glDisableClientState(GL_COLOR_ARRAY); note, only updates values that change.

void osg::State::dirtyColorPointer (  )  [inline]

bool osg::State::isSecondaryColorSupported (  )  const [inline]

void osg::State::setSecondaryColorPointer ( const Array array  )  [inline]

Set the secondary color pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setSecondaryColorPointer ( GLint  size,
GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
)

wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(.

.); note, only updates values that change.

void osg::State::disableSecondaryColorPointer (  )  [inline]

wrapper around glDisableClientState(GL_SECONDARY_COLOR_ARRAY); note, only updates values that change.

void osg::State::dirtySecondaryColorPointer (  )  [inline]

void osg::State::setIndexPointer ( GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
) [inline]

wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(.

.); note, only updates values that change.

void osg::State::disableIndexPointer (  )  [inline]

wrapper around glDisableClientState(GL_INDEX_ARRAY); note, only updates values that change.

void osg::State::dirtyIndexPointer (  )  [inline]

bool osg::State::isFogCoordSupported (  )  const [inline]

void osg::State::setFogCoordPointer ( const Array array  )  [inline]

Set the fog coord pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setFogCoordPointer ( GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
)

wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(.

.); note, only updates values that change.

void osg::State::disableFogCoordPointer (  )  [inline]

wrapper around glDisableClientState(GL_FOG_COORDINATE_ARRAY); note, only updates values that change.

void osg::State::dirtyFogCoordPointer (  )  [inline]

void osg::State::setTexCoordPointer ( unsigned int  unit,
const Array array 
) [inline]

Set the tex coord pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setTexCoordPointer ( unsigned int  unit,
GLint  size,
GLenum  type,
GLsizei  stride,
const GLvoid *  ptr 
) [inline]

wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(.

.); note, only updates values that change.

void osg::State::disableTexCoordPointer ( unsigned int  unit  )  [inline]

wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY); note, only updates values that change.

void osg::State::dirtyTexCoordPointer ( unsigned int  unit  )  [inline]

void osg::State::disableTexCoordPointersAboveAndIncluding ( unsigned int  unit  )  [inline]

void osg::State::dirtyTexCoordPointersAboveAndIncluding ( unsigned int  unit  )  [inline]

bool osg::State::setActiveTextureUnit ( unsigned int  unit  ) 

Set the current texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.

note, only updates values that change.

unsigned int osg::State::getActiveTextureUnit (  )  const [inline]

Get the current texture unit.

bool osg::State::setClientActiveTextureUnit ( unsigned int  unit  ) 

Set the current tex coord array texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.

note, only updates values that change.

unsigned int osg::State::getClientActiveTextureUnit (  )  const [inline]

Get the current tex coord array texture unit.

void osg::State::setVertexAttribPointer ( unsigned int  unit,
const Array array,
GLboolean  normalized 
) [inline]

Set the vertex attrib pointer using an osg::Array, and manage any VBO that are required.

void osg::State::setVertexAttribPointer ( unsigned int  index,
GLint  size,
GLenum  type,
GLboolean  normalized,
GLsizei  stride,
const GLvoid *  ptr 
)

wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(.

.); note, only updates values that change.

void osg::State::disableVertexAttribPointer ( unsigned int  index  ) 

wrapper around DisableVertexAttribArrayARB(index); note, only updates values that change.

void osg::State::disableVertexAttribPointersAboveAndIncluding ( unsigned int  index  ) 

void osg::State::dirtyVertexAttribPointersAboveAndIncluding ( unsigned int  index  )  [inline]

bool osg::State::isVertexBufferObjectSupported (  )  const [inline]

void osg::State::setLastAppliedProgramObject ( const Program::PerContextProgram program  )  [inline]

const Program::PerContextProgram* osg::State::getLastAppliedProgramObject (  )  const [inline]

GLint osg::State::getUniformLocation ( const std::string &  name  )  const [inline]

GLint osg::State::getAttribLocation ( const std::string &  name  )  const [inline]

void osg::State::setFrameStamp ( FrameStamp fs  )  [inline]

Set the frame stamp for the current frame.

FrameStamp* osg::State::getFrameStamp (  )  [inline]

Get the frame stamp for the current frame.

const FrameStamp* osg::State::getFrameStamp (  )  const [inline]

Get the const frame stamp for the current frame.

void osg::State::setDisplaySettings ( DisplaySettings vs  )  [inline]

Set the DisplaySettings.

Note, nothing is applied, the visual settings are just used in the State object to pass the current visual settings to Drawables during rendering.

const DisplaySettings* osg::State::getDisplaySettings (  )  const [inline]

Get the DisplaySettings.

void osg::State::setAbortRenderingPtr ( bool *  abortPtr  )  [inline]

Set flag for early termination of the draw traversal.

bool osg::State::getAbortRendering (  )  const [inline]

Get flag for early termination of the draw traversal, if true steps should be taken to complete rendering early.

void osg::State::setDynamicObjectRenderingCompletedCallback ( DynamicObjectRenderingCompletedCallback cb  )  [inline]

Set the callback to be called when the dynamic object count hits 0.

DynamicObjectRenderingCompletedCallback* osg::State::getDynamicObjectRenderingCompletedCallback (  )  [inline]

Get the callback to be called when the dynamic object count hits 0.

void osg::State::setDynamicObjectCount ( unsigned int  count,
bool  callCallbackOnZero = false 
) [inline]

Set the number of dynamic objects that will be rendered in this graphics context this frame.

unsigned int osg::State::getDynamicObjectCount (  )  const [inline]

Get the number of dynamic objects that will be rendered in this graphics context this frame.

void osg::State::decrementDynamicObjectCount (  )  [inline]

Decrement the number of dynamic objects left to render this frame, and once the count goes to zero call the DynamicObjectRenderingCompletedCallback to inform of completion.

void osg::State::setCheckForGLErrors ( CheckForGLErrors  check  )  [inline]

Set whether and how often OpenGL errors should be checked for.

CheckForGLErrors osg::State::getCheckForGLErrors (  )  const [inline]

Get whether and how often OpenGL errors should be checked for.

bool osg::State::checkGLErrors ( const char *  str  )  const

bool osg::State::checkGLErrors ( StateAttribute::GLMode  mode  )  const

bool osg::State::checkGLErrors ( const StateAttribute attribute  )  const

void osg::State::initializeExtensionProcs (  ) 

Initialize extension used by osg:State.

bool osg::State::applyMode ( StateAttribute::GLMode  mode,
bool  enabled,
ModeStack ms 
) [inline, protected]

Apply an OpenGL mode if required, passing in mode, enable flag and appropriate mode stack.

This is a wrapper around glEnable() and glDisable(), that just actually calls these functions if the enabled flag is different than the current state.

Returns:
true if the state was actually changed. false otherwise. Notice that a false return does not indicate an error, it just means that the mode was already set to the same value as the enabled parameter.

bool osg::State::applyAttribute ( const StateAttribute attribute,
AttributeStack as 
) [inline, protected]

apply an attribute if required, passing in attribute and appropriate attribute stack

bool osg::State::applyGlobalDefaultAttribute ( AttributeStack as  )  [inline, protected]

ModeMap& osg::State::getOrCreateTextureModeMap ( unsigned int  unit  )  [inline, protected]

AttributeMap& osg::State::getOrCreateTextureAttributeMap ( unsigned int  unit  )  [inline, protected]

void osg::State::pushModeList ( ModeMap modeMap,
const StateSet::ModeList modeList 
) [inline, protected]

void osg::State::pushAttributeList ( AttributeMap attributeMap,
const StateSet::AttributeList attributeList 
) [inline, protected]

void osg::State::pushUniformList ( UniformMap uniformMap,
const StateSet::UniformList uniformList 
) [inline, protected]

void osg::State::popModeList ( ModeMap modeMap,
const StateSet::ModeList modeList 
) [inline, protected]

void osg::State::popAttributeList ( AttributeMap attributeMap,
const StateSet::AttributeList attributeList 
) [inline, protected]

void osg::State::popUniformList ( UniformMap uniformMap,
const StateSet::UniformList uniformList 
) [inline, protected]

void osg::State::applyModeList ( ModeMap modeMap,
const StateSet::ModeList modeList 
) [inline, protected]

void osg::State::applyAttributeList ( AttributeMap attributeMap,
const StateSet::AttributeList attributeList 
) [inline, protected]

void osg::State::applyUniformList ( UniformMap uniformMap,
const StateSet::UniformList uniformList 
) [inline, protected]

void osg::State::applyModeMap ( ModeMap modeMap  )  [inline, protected]

void osg::State::applyAttributeMap ( AttributeMap attributeMap  )  [inline, protected]

void osg::State::applyUniformMap ( UniformMap uniformMap  )  [inline, protected]

void osg::State::haveAppliedMode ( ModeMap modeMap,
StateAttribute::GLMode  mode,
StateAttribute::GLModeValue  value 
) [protected]

void osg::State::haveAppliedMode ( ModeMap modeMap,
StateAttribute::GLMode  mode 
) [protected]

void osg::State::haveAppliedAttribute ( AttributeMap attributeMap,
const StateAttribute attribute 
) [protected]

void osg::State::haveAppliedAttribute ( AttributeMap attributeMap,
StateAttribute::Type  type,
unsigned int  member 
) [protected]

bool osg::State::getLastAppliedMode ( const ModeMap modeMap,
StateAttribute::GLMode  mode 
) const [protected]

const StateAttribute* osg::State::getLastAppliedAttribute ( const AttributeMap attributeMap,
StateAttribute::Type  type,
unsigned int  member 
) const [protected]

bool osg::State::computeSecondaryColorSupported (  )  const [protected]

bool osg::State::computeFogCoordSupported (  )  const [protected]

bool osg::State::computeVertexBufferObjectSupported (  )  const [protected]

typedef osg::State::void ( APIENTRY *  ActiveTextureProc  )  [protected]

typedef osg::State::void ( APIENTRY *  FogCoordPointerProc  )  [protected]

typedef osg::State::void ( APIENTRY *  SecondaryColorPointerProc  )  [protected]

typedef osg::State::void ( APIENTRY *  VertexAttribPointerProc  )  [protected]

typedef osg::State::void ( APIENTRY *  EnableVertexAttribProc  )  [protected]

typedef osg::State::void ( APIENTRY *  DisableVertexAttribProc  )  [protected]

typedef osg::State::void ( APIENTRY *  BindBufferProc  )  [protected]


Member Data Documentation

GraphicsContext* osg::State::_graphicsContext [protected]

unsigned int osg::State::_contextID [protected]

ref_ptr<FrameStamp> osg::State::_frameStamp [protected]

ref_ptr<const RefMatrix> osg::State::_identity [protected]

ref_ptr<const RefMatrix> osg::State::_initialViewMatrix [protected]

ref_ptr<const RefMatrix> osg::State::_projection [protected]

ref_ptr<const RefMatrix> osg::State::_modelView [protected]

Matrix osg::State::_initialInverseViewMatrix [protected]

ref_ptr<DisplaySettings> osg::State::_displaySettings [protected]

bool* osg::State::_abortRenderingPtr [protected]

CheckForGLErrors osg::State::_checkGLErrors [protected]

ModeMap osg::State::_modeMap [protected]

AttributeMap osg::State::_attributeMap [protected]

UniformMap osg::State::_uniformMap [protected]

TextureModeMapList osg::State::_textureModeMapList [protected]

TextureAttributeMapList osg::State::_textureAttributeMapList [protected]

AppliedProgramObjectSet osg::State::_appliedProgramObjectSet [protected]

const Program::PerContextProgram* osg::State::_lastAppliedProgramObject [protected]

StateSetStack osg::State::_stateStateStack [protected]

EnabledArrayPair osg::State::_vertexArray [protected]

EnabledArrayPair osg::State::_normalArray [protected]

EnabledArrayPair osg::State::_colorArray [protected]

EnabledArrayPair osg::State::_secondaryColorArray [protected]

EnabledArrayPair osg::State::_indexArray [protected]

EnabledArrayPair osg::State::_fogArray [protected]

EnabledTexCoordArrayList osg::State::_texCoordArrayList [protected]

EnabledVertexAttribArrayList osg::State::_vertexAttribArrayList [protected]

unsigned int osg::State::_currentActiveTextureUnit [protected]

unsigned int osg::State::_currentClientActiveTextureUnit [protected]

const VertexBufferObject* osg::State::_currentVBO [protected]

const ElementBufferObject* osg::State::_currentEBO [protected]

const PixelBufferObject* osg::State::_currentPBO [protected]

bool osg::State::_isSecondaryColorSupportResolved [mutable, protected]

bool osg::State::_isSecondaryColorSupported [mutable, protected]

bool osg::State::_isFogCoordSupportResolved [mutable, protected]

bool osg::State::_isFogCoordSupported [mutable, protected]

bool osg::State::_isVertexBufferObjectSupportResolved [mutable, protected]

bool osg::State::_isVertexBufferObjectSupported [mutable, protected]

typedef osg::State::GLint [protected]

typedef osg::State::GLenum [protected]

bool osg::State::_extensionProcsInitialized [protected]

GLint osg::State::_glMaxTextureCoords [protected]

GLint osg::State::_glMaxTextureUnits [protected]

ActiveTextureProc osg::State::_glClientActiveTexture [protected]

ActiveTextureProc osg::State::_glActiveTexture [protected]

FogCoordPointerProc osg::State::_glFogCoordPointer [protected]

SecondaryColorPointerProc osg::State::_glSecondaryColorPointer [protected]

VertexAttribPointerProc osg::State::_glVertexAttribPointer [protected]

EnableVertexAttribProc osg::State::_glEnableVertexAttribArray [protected]

DisableVertexAttribProc osg::State::_glDisableVertexAttribArray [protected]

BindBufferProc osg::State::_glBindBuffer [protected]

unsigned int osg::State::_dynamicObjectCount [protected]

osg::ref_ptr<DynamicObjectRenderingCompletedCallback> osg::State::_completeDynamicObjectRenderingCallback [protected]


The documentation for this class was generated from the following file:
Generated at Sun Oct 14 02:12:16 2007 for the OpenSceneGraph by doxygen 1.5.3.