NL3D::CDriverGLStates Class Reference

Class for optimizing calls to openGL states, by caching old ones. More...

#include <driver_opengl_states.h>

List of all members.

Public Types

enum  TCullMode { CCW = 0, CW }

Public Member Functions

 CDriverGLStates ()
 Constructor. no-op.
void init (bool supportTextureCubeMap, bool supportTextureRectangle, uint maxLight)
void forceDefaults (uint nbTextureStages)
 Reset all OpenGL states of interest to default, and update caching. This don't apply to light.
void blendFunc (GLenum src, GLenum dst)
 glBlendFunc.
void depthFunc (GLenum zcomp)
 glDepthFunc.
void alphaFunc (float threshold)
 glAlphaFunc
void stencilFunc (GLenum stencilFunc, GLint ref, GLuint mask)
 glStencilFunc
void stencilOp (GLenum fail, GLenum zfail, GLenum zpass)
 glStencilOp
void stencilMask (uint mask)
 glStencilMask
void bindARBVertexBuffer (uint objectID)
void forceBindARBVertexBuffer (uint objectID)
uint getCurrBoundARBVertexBuffer () const
void setCullMode (TCullMode cullMode)
TCullMode getCullMode () const
enable if !0



void enableBlend (uint enable)
void enableFog (uint enable)
void enableCullFace (uint enable)
void enableAlphaTest (uint enable)
 enable and set good AlphaFunc.
void enableZWrite (uint enable)
void enableLighting (uint enable)
bool isLightingEnabled () const
void enableLight (uint num, uint enable)
 enable/disable specific light. num must be < "maxLight" param set in init()
bool isLightEnabled (uint num) const
void enableStencilTest (bool enable)
 enable/disable stencil test
bool isStencilTestEnabled () const
Material setting.

Each f() get an uint32 for fast comparison, and OpenGL colors.



void setEmissive (uint32 packedColor, const GLfloat color[4])
void setAmbient (uint32 packedColor, const GLfloat color[4])
void setDiffuse (uint32 packedColor, const GLfloat color[4])
void setSpecular (uint32 packedColor, const GLfloat color[4])
void setShininess (float shin)
void setVertexColorLighted (bool enable)
void setDepthRange (float znear, float zfar)
void getDepthRange (float &znear, float &zfar) const
void setZBias (float zbias)
 Set z-bias NB : this is done in window coordinate, not in world coordinate as with CMaterial.
void setTexGenMode (uint stage, GLint mode)
Vertex Array enabling.

equivalent to glEnableClientState() / glDisableClientState().

NB: Not modified by forceDefaults()



void enableVertexArray (bool enable)
void enableNormalArray (bool enable)
void enableWeightArray (bool enable)
void enableColorArray (bool enable)
void enableSecondaryColorArray (bool enable)
void clientActiveTextureARB (uint stage)
 same as glClientActiveTextureARB(). useful for enableTexCoordArray.
void enableTexCoordArray (bool enable)
 NB: caller must call correct clientActiveTextureARB() before.
void enableVertexAttribArray (uint glIndex, bool enable)
 For vertexProgram.
void enableVertexAttribArrayForEXTVertexShader (uint glIndex, bool enable, uint *variants)
 Same as enableVertexAttribArray, but for EXTVertexShader (need variant ID).
void enableVertexAttribArrayARB (uint glIndex, bool enable)

Private Types

enum  { MaxLight = 8 }

Private Member Functions

void updateDepthRange ()

Private Attributes

bool _CurBlend
bool _CurFog
bool _CurCullFace
bool _CurAlphaTest
bool _CurLighting
bool _CurZWrite
bool _CurStencilTest
GLenum _CurBlendSrc
GLenum _CurBlendDst
GLenum _CurDepthFunc
GLenum _CurStencilFunc
GLint _CurStencilRef
GLuint _CurStencilMask
GLenum _CurStencilOpFail
GLenum _CurStencilOpZFail
GLenum _CurStencilOpZPass
GLuint _CurStencilWriteMask
float _CurAlphaTestThreshold
uint32 _CurEmissive
uint32 _CurAmbient
uint32 _CurDiffuse
uint32 _CurSpecular
float _CurShininess
bool _VertexColorLighted
bool _TextureCubeMapSupported
bool _TextureRectangleSupported
uint _CurrentActiveTextureARB
TTextureMode _TextureMode [8]
bool _VertexArrayEnabled
bool _NormalArrayEnabled
bool _WeightArrayEnabled
bool _ColorArrayEnabled
bool _SecondaryColorArrayEnabled
uint _CurrentClientActiveTextureARB
bool _TexCoordArrayEnabled [8]
bool _VertexAttribArrayEnabled [CVertexBuffer::NumValue]
GLint _TexGenMode [8]
uint _CurrARBVertexBuffer
float _DepthRangeNear
float _DepthRangeFar
float _ZBias
TCullMode _CullMode
uint _MaxDriverLight
bool _CurLight [MaxLight]

Texture Mode setting.



enum  TTextureMode {
  TextureDisabled, Texture2D, TextureRect, TextureCubeMap,
  TextureModeCount
}
void activeTextureARB (uint stage)
 same as glActiveTextureARB(). useful for setTextureMode.
void forceActiveTextureARB (uint stage)
 same as active texture arb, but with no cache check
uint getActiveTextureARB () const
 get active texture
void setTextureMode (TTextureMode texMode)
 change if needed the texture mode of the current active Texture ARB.
TTextureMode getTextureMode () const
void resetTextureMode ()

Detailed Description

Class for optimizing calls to openGL states, by caching old ones.

All following call with OpenGL must be done with only one instance of this class:

Definition at line 76 of file driver_opengl_states.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
MaxLight 

Definition at line 250 of file driver_opengl_states.h.

Enumerator:
CCW 
CW 

Definition at line 190 of file driver_opengl_states.h.

Enumerator:
TextureDisabled 
Texture2D 
TextureRect 
TextureCubeMap 
TextureModeCount 

Definition at line 142 of file driver_opengl_states.h.


Constructor & Destructor Documentation

NL3D::CDriverGLStates::CDriverGLStates (  ) 

Member Function Documentation

void NL3D::CDriverGLStates::activeTextureARB ( uint  stage  ) 
void NL3D::CDriverGLStates::alphaFunc ( float  threshold  ) 

glAlphaFunc

Definition at line 395 of file driver_opengl_states.cpp.

References _CurAlphaTestThreshold, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::bindARBVertexBuffer ( uint  objectID  ) 
void NL3D::CDriverGLStates::blendFunc ( GLenum  src,
GLenum  dst 
)
void NL3D::CDriverGLStates::clientActiveTextureARB ( uint  stage  ) 
void NL3D::CDriverGLStates::depthFunc ( GLenum  zcomp  ) 

glDepthFunc.

Definition at line 378 of file driver_opengl_states.cpp.

References _CurDepthFunc, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::enableAlphaTest ( uint  enable  ) 

enable and set good AlphaFunc.

Definition at line 236 of file driver_opengl_states.cpp.

References _CurAlphaTest, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::enableBlend ( uint  enable  ) 
void NL3D::CDriverGLStates::enableColorArray ( bool  enable  ) 
void NL3D::CDriverGLStates::enableCullFace ( uint  enable  ) 

Definition at line 216 of file driver_opengl_states.cpp.

References _CurCullFace, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::enableFog ( uint  enable  ) 

Definition at line 959 of file driver_opengl_states.cpp.

References _CurFog, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::enableFog(), and NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::enableLight ( uint  num,
uint  enable 
)

enable/disable specific light. num must be < "maxLight" param set in init()

Definition at line 285 of file driver_opengl_states.cpp.

References _CurLight, _MaxDriverLight, GLenum(), and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::enableLightInternal().

void NL3D::CDriverGLStates::enableLighting ( uint  enable  ) 
void NL3D::CDriverGLStates::enableNormalArray ( bool  enable  ) 
void NL3D::CDriverGLStates::enableSecondaryColorArray ( bool  enable  ) 
void NL3D::CDriverGLStates::enableStencilTest ( bool  enable  ) 

enable/disable stencil test

Definition at line 340 of file driver_opengl_states.cpp.

References _CurStencilTest, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::enableStencilTest().

void NL3D::CDriverGLStates::enableTexCoordArray ( bool  enable  ) 
void NL3D::CDriverGLStates::enableVertexArray ( bool  enable  ) 
void NL3D::CDriverGLStates::enableVertexAttribArray ( uint  glIndex,
bool  enable 
)

For vertexProgram.

do not check if supported or not.

Definition at line 859 of file driver_opengl_states.cpp.

References _VertexAttribArrayEnabled, GL_VERTEX_ATTRIB_ARRAY0_NV, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupGlArraysForNVVertexProgram(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().

void NL3D::CDriverGLStates::enableVertexAttribArrayARB ( uint  glIndex,
bool  enable 
)
void NL3D::CDriverGLStates::enableVertexAttribArrayForEXTVertexShader ( uint  glIndex,
bool  enable,
uint variants 
)
void NL3D::CDriverGLStates::enableWeightArray ( bool  enable  ) 

Definition at line 778 of file driver_opengl_states.cpp.

References _WeightArrayEnabled, and H_AUTO_OGL.

void NL3D::CDriverGLStates::enableZWrite ( uint  enable  ) 
void NL3D::CDriverGLStates::forceActiveTextureARB ( uint  stage  ) 

same as active texture arb, but with no cache check

Definition at line 738 of file driver_opengl_states.cpp.

References _CurrentActiveTextureARB, H_AUTO_OGL, and nglActiveTextureARB.

void NL3D::CDriverGLStates::forceBindARBVertexBuffer ( uint  objectID  ) 
void NL3D::CDriverGLStates::forceDefaults ( uint  nbTextureStages  ) 
uint NL3D::CDriverGLStates::getActiveTextureARB (  )  const [inline]

get active texture

Definition at line 148 of file driver_opengl_states.h.

References _CurrentActiveTextureARB.

Referenced by NL3D::CDriverGL::checkTextureOn().

CDriverGLStates::TCullMode NL3D::CDriverGLStates::getCullMode (  )  const

Definition at line 1014 of file driver_opengl_states.cpp.

References _CullMode, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::getCullMode().

uint NL3D::CDriverGLStates::getCurrBoundARBVertexBuffer (  )  const [inline]
void NL3D::CDriverGLStates::getDepthRange ( float znear,
float zfar 
) const [inline]

Definition at line 129 of file driver_opengl_states.h.

References _DepthRangeFar, and _DepthRangeNear.

Referenced by NL3D::CDriverGL::getDepthRange().

TTextureMode NL3D::CDriverGLStates::getTextureMode (  )  const [inline]

Definition at line 153 of file driver_opengl_states.h.

References _CurrentActiveTextureARB, and _TextureMode.

Referenced by NL3D::CDriverGL::checkTextureOn().

void NL3D::CDriverGLStates::init ( bool  supportTextureCubeMap,
bool  supportTextureRectangle,
uint  maxLight 
)
bool NL3D::CDriverGLStates::isLightEnabled ( uint  num  )  const

Definition at line 308 of file driver_opengl_states.cpp.

References _CurLight, _MaxDriverLight, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::cleanLightSetup().

bool NL3D::CDriverGLStates::isLightingEnabled (  )  const [inline]

Definition at line 97 of file driver_opengl_states.h.

References _CurLighting.

bool NL3D::CDriverGLStates::isStencilTestEnabled (  )  const [inline]

Definition at line 103 of file driver_opengl_states.h.

References _CurStencilTest.

Referenced by NL3D::CDriverGL::isStencilTestEnabled().

void NL3D::CDriverGLStates::resetTextureMode (  ) 
void NL3D::CDriverGLStates::setAmbient ( uint32  packedColor,
const GLfloat  color[4] 
)
void NL3D::CDriverGLStates::setCullMode ( TCullMode  cullMode  ) 

Definition at line 1001 of file driver_opengl_states.cpp.

References _CullMode, CCW, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setCullMode().

void NL3D::CDriverGLStates::setDepthRange ( float  znear,
float  zfar 
)
void NL3D::CDriverGLStates::setDiffuse ( uint32  packedColor,
const GLfloat  color[4] 
)
void NL3D::CDriverGLStates::setEmissive ( uint32  packedColor,
const GLfloat  color[4] 
)
void NL3D::CDriverGLStates::setShininess ( float  shin  ) 

Definition at line 517 of file driver_opengl_states.cpp.

References _CurShininess, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::setSpecular ( uint32  packedColor,
const GLfloat  color[4] 
)
void NL3D::CDriverGLStates::setTexGenMode ( uint  stage,
GLint  mode 
)
void NL3D::CDriverGLStates::setTextureMode ( TTextureMode  texMode  ) 
void NL3D::CDriverGLStates::setVertexColorLighted ( bool  enable  ) 
void NL3D::CDriverGLStates::setZBias ( float  zbias  ) 

Set z-bias NB : this is done in window coordinate, not in world coordinate as with CMaterial.

Definition at line 582 of file driver_opengl_states.cpp.

References _ZBias, H_AUTO_OGL, and updateDepthRange().

Referenced by NL3D::CDriverGL::setupMaterial().

void NL3D::CDriverGLStates::stencilFunc ( GLenum  stencilFunc,
GLint  ref,
GLuint  mask 
)

glStencilFunc

Definition at line 411 of file driver_opengl_states.cpp.

References _CurStencilFunc, _CurStencilMask, _CurStencilRef, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::stencilFunc().

void NL3D::CDriverGLStates::stencilMask ( uint  mask  ) 

glStencilMask

Referenced by NL3D::CDriverGL::stencilMask().

void NL3D::CDriverGLStates::stencilOp ( GLenum  fail,
GLenum  zfail,
GLenum  zpass 
)

glStencilOp

Definition at line 430 of file driver_opengl_states.cpp.

References _CurStencilOpFail, _CurStencilOpZFail, _CurStencilOpZPass, and H_AUTO_OGL.

Referenced by NL3D::CDriverGL::stencilOp().

void NL3D::CDriverGLStates::updateDepthRange (  )  [private]

Definition at line 574 of file driver_opengl_states.cpp.

References _DepthRangeFar, _DepthRangeNear, _ZBias, and H_AUTO_OGL.

Referenced by setDepthRange(), and setZBias().


Member Data Documentation

Definition at line 230 of file driver_opengl_states.h.

Referenced by enableColorArray(), and init().

Definition at line 244 of file driver_opengl_states.h.

Referenced by CDriverGLStates(), forceDefaults(), getCullMode(), and setCullMode().

Definition at line 198 of file driver_opengl_states.h.

Referenced by enableAlphaTest(), and forceDefaults().

Definition at line 213 of file driver_opengl_states.h.

Referenced by alphaFunc(), and forceDefaults().

Definition at line 216 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setAmbient().

Definition at line 195 of file driver_opengl_states.h.

Referenced by enableBlend(), and forceDefaults().

Definition at line 204 of file driver_opengl_states.h.

Referenced by blendFunc(), and forceDefaults().

Definition at line 203 of file driver_opengl_states.h.

Referenced by blendFunc(), and forceDefaults().

Definition at line 197 of file driver_opengl_states.h.

Referenced by enableCullFace(), and forceDefaults().

Definition at line 205 of file driver_opengl_states.h.

Referenced by depthFunc(), and forceDefaults().

Definition at line 217 of file driver_opengl_states.h.

Referenced by forceDefaults(), setDiffuse(), and setVertexColorLighted().

Definition at line 215 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setEmissive().

Definition at line 196 of file driver_opengl_states.h.

Referenced by enableFog(), and forceDefaults().

Definition at line 252 of file driver_opengl_states.h.

Referenced by enableLight(), init(), and isLightEnabled().

Definition at line 199 of file driver_opengl_states.h.

Referenced by enableLighting(), forceDefaults(), and isLightingEnabled().

Definition at line 219 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setShininess().

Definition at line 218 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setSpecular().

Definition at line 206 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilFunc().

Definition at line 208 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilFunc().

Definition at line 209 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilOp().

Definition at line 210 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilOp().

Definition at line 211 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilOp().

Definition at line 207 of file driver_opengl_states.h.

Referenced by forceDefaults(), and stencilFunc().

Definition at line 201 of file driver_opengl_states.h.

Referenced by enableStencilTest(), forceDefaults(), and isStencilTestEnabled().

Definition at line 212 of file driver_opengl_states.h.

Referenced by forceDefaults().

Definition at line 200 of file driver_opengl_states.h.

Referenced by enableZWrite(), and forceDefaults().

Definition at line 251 of file driver_opengl_states.h.

Referenced by CDriverGLStates(), enableLight(), init(), and isLightEnabled().

Definition at line 228 of file driver_opengl_states.h.

Referenced by enableNormalArray(), and init().

Definition at line 231 of file driver_opengl_states.h.

Referenced by enableSecondaryColorArray(), and init().

Definition at line 233 of file driver_opengl_states.h.

Referenced by enableTexCoordArray(), and init().

Definition at line 236 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setTexGenMode().

Definition at line 223 of file driver_opengl_states.h.

Referenced by forceDefaults(), init(), resetTextureMode(), and setTextureMode().

Definition at line 227 of file driver_opengl_states.h.

Referenced by enableVertexArray(), and init().

bool NL3D::CDriverGLStates::_VertexAttribArrayEnabled[CVertexBuffer::NumValue] [private]

Definition at line 220 of file driver_opengl_states.h.

Referenced by forceDefaults(), and setVertexColorLighted().

Definition at line 229 of file driver_opengl_states.h.

Referenced by enableWeightArray(), and init().


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

Generated on Thu Jan 7 08:30:15 2010 for NeL by  doxygen 1.6.1