OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::GLStateCacheManager Class Reference

An in memory cache of the OpenGL state. More...

#include <OgreGLStateCacheManager.h>

+ Inheritance diagram for Ogre::GLStateCacheManager:
+ Collaboration diagram for Ogre::GLStateCacheManager:

Public Member Functions

 GLStateCacheManager (void)
 
 ~GLStateCacheManager (void)
 
bool activateGLTextureUnit (size_t unit)
 Activate an OpenGL texture unit. More...
 
void bindGLBuffer (GLenum target, GLuint buffer, bool force=false)
 Bind an OpenGL buffer of any type. More...
 
void bindGLTexture (GLenum target, GLuint texture)
 Bind an OpenGL texture of any type. More...
 
void clearCache ()
 Clears all cached values. More...
 
void deleteGLBuffer (GLenum target, GLuint buffer, bool force=false)
 Delete an OpenGL buffer of any type. More...
 
void disableTextureCoordGen (GLenum type)
 Disable the specified texture coordinate generation option for the currently active texture unit. More...
 
void enableTextureCoordGen (GLenum type)
 Enable the specified texture coordinate generation option for the currently active texture unit. More...
 
GLenum getBlendEquation (void) const
 Gets the current blend equation setting. More...
 
GLclampf getClearDepth (void) const
 Gets the clear depth in the range from [0..1]. More...
 
vector< GLboolean >::type & getColourMask (void) const
 Gets the current colour mask setting. More...
 
GLenum getCullFace (void) const
 Sets the face culling mode. More...
 
GLenum getDepthFunc (void) const
 Gets the current depth test function. More...
 
GLboolean getDepthMask (void) const
 Gets the current depth mask setting. More...
 
unsigned int getDiscardBuffers (void) const
 Gets the mask of buffers to be discarded if GL_EXT_discard_framebuffer is supported. More...
 
GLenum getPolygonMode (void) const
 Gets the current polygon rendering mode, fill, wireframe, points, etc. More...
 
GLuint getStencilMask (void) const
 Gets the current stencil mask. More...
 
void getViewport (int *array)
 
void invalidateStateForTexture (GLuint texture)
 Invalidates the state associated with a particular texture ID. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void * operator new[] (size_t sz)
 
void setBlendEquation (GLenum eq)
 Sets the current blend equation setting. More...
 
void setBlendEquation (GLenum eqRGB, GLenum eqA)
 Set the blend equation for RGB and alpha separately. More...
 
void setBlendFunc (GLenum source, GLenum dest)
 Sets the blending function. More...
 
void setClearColour (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 Sets the color to clear to. More...
 
void setClearDepth (GLclampf depth)
 Sets the clear depth in the range from [0..1]. More...
 
void setColourMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
 Sets the current colour mask. More...
 
void setCullFace (GLenum face)
 Sets the face culling setting. More...
 
void setDepthFunc (GLenum func)
 Sets the current depth test function. More...
 
void setDepthMask (GLboolean mask)
 Sets the current depth mask setting. More...
 
void setDiscardBuffers (unsigned int flags)
 Sets the mask of buffers to be discarded if GL_EXT_discard_framebuffer is supported. More...
 
void setEnabled (GLenum flag, bool enabled)
 Enables a piece of OpenGL functionality. More...
 
void setLightAmbient (GLfloat r, GLfloat g, GLfloat b)
 
void setMaterialAmbient (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 
void setMaterialDiffuse (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 
void setMaterialEmissive (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 
void setMaterialShininess (GLfloat shininess)
 
void setMaterialSpecular (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 
void setPointParameters (GLfloat *attenuation, float minSize, float maxSize)
 
void setPointSize (GLfloat size)
 
void setPolygonMode (GLenum mode)
 Sets the current polygon rendering mode. More...
 
void setShadeModel (GLenum model)
 
void setStencilMask (GLuint mask)
 Sets the stencil mask. More...
 
void setTexParameteri (GLenum target, GLenum pname, GLint param)
 Sets an integer parameter value per texture target. More...
 
void setViewport (GLint x, GLint y, GLsizei width, GLsizei height)
 
void switchContext (intptr_t id)
 
void unregisterContext (intptr_t id)
 GL state is tracked per context, so call this function to drop all recorded state for a given context before you destroy it. More...
 

Private Types

typedef map< intptr_t,
GLStateCacheManagerImp * >
::type 
CachesMap
 
typedef MapIterator< CachesMapCachesMapIterator
 

Private Attributes

CachesMap mCaches
 
GLStateCacheManagerImpmImp
 

Detailed Description

An in memory cache of the OpenGL state.

Remarks
State changes can be particularly expensive time wise. This is because a change requires OpenGL to re-evaluate and update the state machine. Because of the general purpose nature of OGRE we often set the state for a specific texture, material, buffer, etc. But this may be the same as the current status of the state machine and is therefore redundant and causes unnecessary work to be performed by OpenGL.
Instead we are caching the state so that we can check whether it actually does need to be updated. This leads to improved performance all around and can be somewhat dramatic in some cases.

Definition at line 55 of file OgreGLStateCacheManager.h.

Member Typedef Documentation

Definition at line 59 of file OgreGLStateCacheManager.h.

Constructor & Destructor Documentation

Ogre::GLStateCacheManager::GLStateCacheManager ( void  )
Ogre::GLStateCacheManager::~GLStateCacheManager ( void  )

Member Function Documentation

bool Ogre::GLStateCacheManager::activateGLTextureUnit ( size_t  unit)

Activate an OpenGL texture unit.

Parameters
unitThe texture unit to activate.
Returns
Whether or not the texture unit was successfully activated.
void Ogre::GLStateCacheManager::bindGLBuffer ( GLenum  target,
GLuint  buffer,
bool  force = false 
)

Bind an OpenGL buffer of any type.

Parameters
targetThe buffer target.
bufferThe buffer ID.
forceOptional parameter to force an update.
void Ogre::GLStateCacheManager::bindGLTexture ( GLenum  target,
GLuint  texture 
)

Bind an OpenGL texture of any type.

Parameters
targetThe texture target.
textureThe texture ID.
void Ogre::GLStateCacheManager::clearCache ( )

Clears all cached values.

void Ogre::GLStateCacheManager::deleteGLBuffer ( GLenum  target,
GLuint  buffer,
bool  force = false 
)

Delete an OpenGL buffer of any type.

Parameters
targetThe buffer target.
bufferThe buffer ID.
forceOptional parameter to force an update.
void Ogre::GLStateCacheManager::disableTextureCoordGen ( GLenum  type)

Disable the specified texture coordinate generation option for the currently active texture unit.

void Ogre::GLStateCacheManager::enableTextureCoordGen ( GLenum  type)

Enable the specified texture coordinate generation option for the currently active texture unit.

GLenum Ogre::GLStateCacheManager::getBlendEquation ( void  ) const

Gets the current blend equation setting.

Returns
The blend equation.
GLclampf Ogre::GLStateCacheManager::getClearDepth ( void  ) const

Gets the clear depth in the range from [0..1].

Returns
The current clearing depth.
vector<GLboolean>::type& Ogre::GLStateCacheManager::getColourMask ( void  ) const

Gets the current colour mask setting.

Returns
An array containing the mask in RGBA order.
GLenum Ogre::GLStateCacheManager::getCullFace ( void  ) const

Sets the face culling mode.

Returns
The current face culling mode
GLenum Ogre::GLStateCacheManager::getDepthFunc ( void  ) const

Gets the current depth test function.

Returns
The current depth test function.
GLboolean Ogre::GLStateCacheManager::getDepthMask ( void  ) const

Gets the current depth mask setting.

Returns
The current depth mask.
unsigned int Ogre::GLStateCacheManager::getDiscardBuffers ( void  ) const

Gets the mask of buffers to be discarded if GL_EXT_discard_framebuffer is supported.

Returns
The buffer mask.
GLenum Ogre::GLStateCacheManager::getPolygonMode ( void  ) const

Gets the current polygon rendering mode, fill, wireframe, points, etc.

Returns
The current polygon rendering mode.
GLuint Ogre::GLStateCacheManager::getStencilMask ( void  ) const

Gets the current stencil mask.

Returns
The stencil mask.
void Ogre::GLStateCacheManager::getViewport ( int *  array)
void Ogre::GLStateCacheManager::invalidateStateForTexture ( GLuint  texture)

Invalidates the state associated with a particular texture ID.

Parameters
textureThe texture ID.
template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

void Ogre::GLStateCacheManager::setBlendEquation ( GLenum  eq)

Sets the current blend equation setting.

Parameters
eqThe blend equation to use.
void Ogre::GLStateCacheManager::setBlendEquation ( GLenum  eqRGB,
GLenum  eqA 
)

Set the blend equation for RGB and alpha separately.

void Ogre::GLStateCacheManager::setBlendFunc ( GLenum  source,
GLenum  dest 
)

Sets the blending function.

Parameters
sourceThe blend mode for the source.
destThe blend mode for the destination
void Ogre::GLStateCacheManager::setClearColour ( GLclampf  red,
GLclampf  green,
GLclampf  blue,
GLclampf  alpha 
)

Sets the color to clear to.

Parameters
redThe red component.
greenThe green component.
blueThe blue component.
alphaThe alpha component.
void Ogre::GLStateCacheManager::setClearDepth ( GLclampf  depth)

Sets the clear depth in the range from [0..1].

Parameters
depthThe clear depth to use.
void Ogre::GLStateCacheManager::setColourMask ( GLboolean  red,
GLboolean  green,
GLboolean  blue,
GLboolean  alpha 
)

Sets the current colour mask.

Parameters
redThe red component.
greenThe green component.
blueThe blue component.
alphaThe alpha component.
void Ogre::GLStateCacheManager::setCullFace ( GLenum  face)

Sets the face culling setting.

Parameters
faceThe face culling mode to use.
void Ogre::GLStateCacheManager::setDepthFunc ( GLenum  func)

Sets the current depth test function.

Parameters
funcThe depth test function to use.
void Ogre::GLStateCacheManager::setDepthMask ( GLboolean  mask)

Sets the current depth mask setting.

Parameters
maskThe depth mask to use.
void Ogre::GLStateCacheManager::setDiscardBuffers ( unsigned int  flags)

Sets the mask of buffers to be discarded if GL_EXT_discard_framebuffer is supported.

Parameters
flagsThe bit mask of buffers to be discarded. Stored as Ogre::FrameBufferType.
void Ogre::GLStateCacheManager::setEnabled ( GLenum  flag,
bool  enabled 
)

Enables a piece of OpenGL functionality.

Parameters
flagThe function to enable.
void Ogre::GLStateCacheManager::setLightAmbient ( GLfloat  r,
GLfloat  g,
GLfloat  b 
)
void Ogre::GLStateCacheManager::setMaterialAmbient ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)
void Ogre::GLStateCacheManager::setMaterialDiffuse ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)
void Ogre::GLStateCacheManager::setMaterialEmissive ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)
void Ogre::GLStateCacheManager::setMaterialShininess ( GLfloat  shininess)
void Ogre::GLStateCacheManager::setMaterialSpecular ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)
void Ogre::GLStateCacheManager::setPointParameters ( GLfloat *  attenuation,
float  minSize,
float  maxSize 
)
void Ogre::GLStateCacheManager::setPointSize ( GLfloat  size)
void Ogre::GLStateCacheManager::setPolygonMode ( GLenum  mode)

Sets the current polygon rendering mode.

Parameters
modeThe polygon mode to use.
void Ogre::GLStateCacheManager::setShadeModel ( GLenum  model)
void Ogre::GLStateCacheManager::setStencilMask ( GLuint  mask)

Sets the stencil mask.

Parameters
maskThe stencil mask to use
void Ogre::GLStateCacheManager::setTexParameteri ( GLenum  target,
GLenum  pname,
GLint  param 
)

Sets an integer parameter value per texture target.

Parameters
targetThe texture target.
pnameThe parameter name.
paramThe parameter value.
void Ogre::GLStateCacheManager::setViewport ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
)
void Ogre::GLStateCacheManager::switchContext ( intptr_t  id)
Parameters
idnew context to switch to for state tracking
void Ogre::GLStateCacheManager::unregisterContext ( intptr_t  id)

GL state is tracked per context, so call this function to drop all recorded state for a given context before you destroy it.

Member Data Documentation

CachesMap Ogre::GLStateCacheManager::mCaches
private

Definition at line 62 of file OgreGLStateCacheManager.h.

GLStateCacheManagerImp* Ogre::GLStateCacheManager::mImp
private

Definition at line 58 of file OgreGLStateCacheManager.h.


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