# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

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.

Texture Mode setting.

enum  TTextureMode { TextureDisabled, Texture2D, TextureCubeMap, TextureModeCount }
void activeTextureARB (uint stage)
 same as glActiveTextureARB(). usefull for setTextureMode. More...

void forceActiveTextureARB (uint stage)
 same as active texture arb, but with no cache check. More...

uint getActiveTextureARB () const
 get active texture. More...

void setTextureMode (TTextureMode texMode)
 change if needed the texture mode of the current active Texture ARB. More...

void resetTextureMode ()

Public Types


Public Methods

 CDriverGLStates ()
 Constructor. no-op. More...

void init (bool supportTextureCubeMap)
void forceDefaults (uint nbTextureStages)
 Reset all OpenGL states of interest to default, and update caching. More...

void blendFunc (GLenum src, GLenum dst)
 glBlendFunc. More...

void depthFunc (GLenum zcomp)
 glDepthFunc. More...

void alphaFunc (float threshold)
 glAlphaFunc. More...

enable if !0
void enableBlend (uint enable)
void enableCullFace (uint enable)
void enableAlphaTest (uint enable)
 enable and set good AlphaFunc. More...

void enableLighting (uint enable)
void enableZWrite (uint enable)
Material setting.
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 zDelta)
void enableTexGen (uint stage, bool enable)
void setTexGenMode (uint stage, GLint mode)
Vertex Array enabling.
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(). usefull for enableTexCoordArray. More...

void enableTexCoordArray (bool enable)
 NB: caller must call correct clientActiveTextureARB() before. More...

void enableVertexAttribArray (uint glIndex, bool enable)
 For vertexProgram. More...

void enableVertexAttribArrayForEXTVertexShader (uint glIndex, bool enable, uint *variants)
 Same as enableVertexAttribArray, but for EXTVertexShader (need variant ID). More...


Private Attributes

bool _CurBlend
bool _CurCullFace
bool _CurAlphaTest
bool _CurLighting
bool _CurZWrite
GLenum _CurBlendSrc
GLenum _CurBlendDst
GLenum _CurDepthFunc
float _CurAlphaTestThreshold
uint32 _CurEmissive
uint32 _CurAmbient
uint32 _CurDiffuse
uint32 _CurSpecular
float _CurShininess
bool _VertexColorLighted
bool _TextureCubeMapSupported
uint _CurrentActiveTextureARB
TTextureMode _TextureMode [8]
bool _VertexArrayEnabled
bool _NormalArrayEnabled
bool _WeightArrayEnabled
bool _ColorArrayEnabled
bool _SecondaryColorArrayEnabled
uint _CurrentClientActiveTextureARB
bool _TexCoordArrayEnabled [8]
bool _VertexAttribArrayEnabled [CVertexBuffer::NumValue]
bool _TexGen [8]
GLint _TexGenMode [8]
float _CurZRangeDelta


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:

  • glEnable() glDisable() with:
    • GL_BLEND
    • GL_CULL_FACE
    • GL_ALPHA_TEST
    • GL_LIGHTING
    • GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB.
    • GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R
    • GL_COLOR_MATERIAL
  • glActiveTextureARB()
  • glClientActiveTextureARB()
  • glEnableClientState() glDisableClientState() with:
    • GL_VERTEX_ARRAY
    • GL_NORMAL_ARRAY
    • GL_VERTEX_WEIGHTING_EXT
    • GL_COLOR_ARRAY
    • GL_SECONDARY_COLOR_ARRAY_EXT
    • GL_TEXTURE_COORD_ARRAY
    • GL_VERTEX_ATTRIB_ARRAY0_NV + i.
  • glDepthMask()
  • glAlphaFunc()
  • glBlendFunc()
  • glDepthFunc()
  • glMaterialf() and glMaterialfv() for:
    • GL_EMISSION
    • GL_AMBIENT
    • GL_DIFFUSE
    • GL_SPECULAR
    • GL_SHININESS
  • glDepthRange()
  • glColorMaterial()
  • glTexGeni()
Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 78 of file driver_opengl_states.h.


Member Enumeration Documentation

enum NL3D::CDriverGLStates::TTextureMode
 

Enumeration values:
TextureDisabled 
Texture2D 
TextureCubeMap 
TextureModeCount 

Definition at line 125 of file driver_opengl_states.h.

Referenced by setTextureMode.


Constructor & Destructor Documentation

NL3D::CDriverGLStates::CDriverGLStates  
 

Constructor. no-op.

Definition at line 37 of file driver_opengl_states.cpp.

References _TextureCubeMapSupported.


Member Function Documentation

void NL3D::CDriverGLStates::activeTextureARB uint    stage
 

same as glActiveTextureARB(). usefull for setTextureMode.

Definition at line 504 of file driver_opengl_states.cpp.

References _CurrentActiveTextureARB, and nglActiveTextureARB.

void NL3D::CDriverGLStates::alphaFunc float    threshold
 

glAlphaFunc.

Definition at line 285 of file driver_opengl_states.cpp.

References _CurAlphaTestThreshold.

void NL3D::CDriverGLStates::blendFunc GLenum    src,
GLenum    dst
 

glBlendFunc.

Definition at line 253 of file driver_opengl_states.cpp.

References _CurBlendDst, _CurBlendSrc, and src.

void NL3D::CDriverGLStates::clientActiveTextureARB uint    stage
 

same as glClientActiveTextureARB(). usefull for enableTexCoordArray.

Definition at line 585 of file driver_opengl_states.cpp.

References _CurrentClientActiveTextureARB, and nglClientActiveTextureARB.

Referenced by enableVertexAttribArrayForEXTVertexShader.

void NL3D::CDriverGLStates::depthFunc GLenum    zcomp
 

glDepthFunc.

Definition at line 269 of file driver_opengl_states.cpp.

References _CurDepthFunc.

void NL3D::CDriverGLStates::enableAlphaTest uint    enable
 

enable and set good AlphaFunc.

Definition at line 189 of file driver_opengl_states.cpp.

References _CurAlphaTest.

void NL3D::CDriverGLStates::enableBlend uint    enable
 

Definition at line 151 of file driver_opengl_states.cpp.

References _CurBlend.

void NL3D::CDriverGLStates::enableColorArray bool    enable
 

Definition at line 558 of file driver_opengl_states.cpp.

References _ColorArrayEnabled.

Referenced by enableVertexAttribArrayForEXTVertexShader.

void NL3D::CDriverGLStates::enableCullFace uint    enable
 

Definition at line 170 of file driver_opengl_states.cpp.

References _CurCullFace.

void NL3D::CDriverGLStates::enableLighting uint    enable
 

Definition at line 213 of file driver_opengl_states.cpp.

References _CurLighting.

void NL3D::CDriverGLStates::enableNormalArray bool    enable
 

Definition at line 534 of file driver_opengl_states.cpp.

References _NormalArrayEnabled.

Referenced by enableVertexAttribArrayForEXTVertexShader.

void NL3D::CDriverGLStates::enableSecondaryColorArray bool    enable
 

Definition at line 572 of file driver_opengl_states.cpp.

References _SecondaryColorArrayEnabled.

void NL3D::CDriverGLStates::enableTexCoordArray bool    enable
 

NB: caller must call correct clientActiveTextureARB() before.

Definition at line 595 of file driver_opengl_states.cpp.

References _CurrentClientActiveTextureARB, and _TexCoordArrayEnabled.

Referenced by enableVertexAttribArrayForEXTVertexShader.

void NL3D::CDriverGLStates::enableTexGen uint    stage,
bool    enable
 

Definition at line 415 of file driver_opengl_states.cpp.

References _TexGen.

void NL3D::CDriverGLStates::enableVertexArray bool    enable
 

Definition at line 522 of file driver_opengl_states.cpp.

References _VertexArrayEnabled.

Referenced by enableVertexAttribArrayForEXTVertexShader.

void NL3D::CDriverGLStates::enableVertexAttribArray uint    glIndex,
bool    enable
 

For vertexProgram.

do not check if supported or not.

Definition at line 608 of file driver_opengl_states.cpp.

References _VertexAttribArrayEnabled, and GL_VERTEX_ATTRIB_ARRAY0_NV.

void NL3D::CDriverGLStates::enableVertexAttribArrayForEXTVertexShader uint    glIndex,
bool    enable,
uint   variants
 

Same as enableVertexAttribArray, but for EXTVertexShader (need variant ID).

Parameters:
firstVariantSymbol  the first variant symbol

Definition at line 622 of file driver_opengl_states.cpp.

References _VertexAttribArrayEnabled, clientActiveTextureARB, enableColorArray, enableNormalArray, enableTexCoordArray, enableVertexArray, nglDisableVariantClientStateEXT, nglEnableVariantClientStateEXT, and nlstop.

void NL3D::CDriverGLStates::enableWeightArray bool    enable
 

Definition at line 546 of file driver_opengl_states.cpp.

References _WeightArrayEnabled.

void NL3D::CDriverGLStates::enableZWrite uint    enable
 

Definition at line 232 of file driver_opengl_states.cpp.

References _CurZWrite.

void NL3D::CDriverGLStates::forceActiveTextureARB uint    stage
 

same as active texture arb, but with no cache check.

Definition at line 514 of file driver_opengl_states.cpp.

References _CurrentActiveTextureARB, and nglActiveTextureARB.

void NL3D::CDriverGLStates::forceDefaults uint    nbTextureStages
 

Reset all OpenGL states of interest to default, and update caching.

Definition at line 67 of file driver_opengl_states.cpp.

References _CurAlphaTest, _CurAlphaTestThreshold, _CurAmbient, _CurBlend, _CurBlendDst, _CurBlendSrc, _CurCullFace, _CurDepthFunc, _CurDiffuse, _CurEmissive, _CurLighting, _CurrentActiveTextureARB, _CurrentClientActiveTextureARB, _CurShininess, _CurSpecular, _CurZRangeDelta, _CurZWrite, _TexGen, _TexGenMode, _TextureMode, _VertexColorLighted, nglActiveTextureARB, nglClientActiveTextureARB, and TextureDisabled.

uint NL3D::CDriverGLStates::getActiveTextureARB   const [inline]
 

get active texture.

Definition at line 131 of file driver_opengl_states.h.

References _CurrentActiveTextureARB.

void NL3D::CDriverGLStates::init bool    supportTextureCubeMap
 

Definition at line 44 of file driver_opengl_states.cpp.

References _ColorArrayEnabled, _NormalArrayEnabled, _SecondaryColorArrayEnabled, _TexCoordArrayEnabled, _TextureCubeMapSupported, _VertexArrayEnabled, _VertexAttribArrayEnabled, _WeightArrayEnabled, and NL3D::IDRV_MAT_MAXTEXTURES.

void NL3D::CDriverGLStates::resetTextureMode  
 

Definition at line 458 of file driver_opengl_states.cpp.

References _CurrentActiveTextureARB, _TextureMode, and TextureDisabled.

void NL3D::CDriverGLStates::setAmbient uint32    packedColor,
const GLfloat    color[4]
 

Definition at line 312 of file driver_opengl_states.cpp.

References _CurAmbient.

void NL3D::CDriverGLStates::setDepthRange float    zDelta
 

Definition at line 401 of file driver_opengl_states.cpp.

References _CurZRangeDelta.

void NL3D::CDriverGLStates::setDiffuse uint32    packedColor,
const GLfloat    color[4]
 

Definition at line 324 of file driver_opengl_states.cpp.

References _CurDiffuse.

void NL3D::CDriverGLStates::setEmissive uint32    packedColor,
const GLfloat    color[4]
 

Definition at line 300 of file driver_opengl_states.cpp.

References _CurEmissive.

void NL3D::CDriverGLStates::setShininess float    shin
 

Definition at line 348 of file driver_opengl_states.cpp.

References _CurShininess.

void NL3D::CDriverGLStates::setSpecular uint32    packedColor,
const GLfloat    color[4]
 

Definition at line 336 of file driver_opengl_states.cpp.

References _CurSpecular.

void NL3D::CDriverGLStates::setTexGenMode uint    stage,
GLint    mode
 

Definition at line 440 of file driver_opengl_states.cpp.

References _TexGenMode.

void NL3D::CDriverGLStates::setTextureMode TTextureMode    texMode
 

change if needed the texture mode of the current active Texture ARB.

NB: if CubeMap extension not supported, TextureCubeMap <=> TextureDisabled.

Definition at line 470 of file driver_opengl_states.cpp.

References _CurrentActiveTextureARB, _TextureMode, Texture2D, TextureCubeMap, and TTextureMode.

void NL3D::CDriverGLStates::setVertexColorLighted bool    enable
 

Definition at line 371 of file driver_opengl_states.cpp.

References _CurDiffuse, _VertexColorLighted, and NL3D::convColor.


Member Data Documentation

bool NL3D::CDriverGLStates::_ColorArrayEnabled [private]
 

Definition at line 189 of file driver_opengl_states.h.

Referenced by enableColorArray, and init.

bool NL3D::CDriverGLStates::_CurAlphaTest [private]
 

Definition at line 166 of file driver_opengl_states.h.

Referenced by enableAlphaTest, and forceDefaults.

float NL3D::CDriverGLStates::_CurAlphaTestThreshold [private]
 

Definition at line 173 of file driver_opengl_states.h.

Referenced by alphaFunc, and forceDefaults.

uint32 NL3D::CDriverGLStates::_CurAmbient [private]
 

Definition at line 176 of file driver_opengl_states.h.

Referenced by forceDefaults, and setAmbient.

bool NL3D::CDriverGLStates::_CurBlend [private]
 

Definition at line 164 of file driver_opengl_states.h.

Referenced by enableBlend, and forceDefaults.

GLenum NL3D::CDriverGLStates::_CurBlendDst [private]
 

Definition at line 171 of file driver_opengl_states.h.

Referenced by blendFunc, and forceDefaults.

GLenum NL3D::CDriverGLStates::_CurBlendSrc [private]
 

Definition at line 170 of file driver_opengl_states.h.

Referenced by blendFunc, and forceDefaults.

bool NL3D::CDriverGLStates::_CurCullFace [private]
 

Definition at line 165 of file driver_opengl_states.h.

Referenced by enableCullFace, and forceDefaults.

GLenum NL3D::CDriverGLStates::_CurDepthFunc [private]
 

Definition at line 172 of file driver_opengl_states.h.

Referenced by depthFunc, and forceDefaults.

uint32 NL3D::CDriverGLStates::_CurDiffuse [private]
 

Definition at line 177 of file driver_opengl_states.h.

Referenced by forceDefaults, setDiffuse, and setVertexColorLighted.

uint32 NL3D::CDriverGLStates::_CurEmissive [private]
 

Definition at line 175 of file driver_opengl_states.h.

Referenced by forceDefaults, and setEmissive.

bool NL3D::CDriverGLStates::_CurLighting [private]
 

Definition at line 167 of file driver_opengl_states.h.

Referenced by enableLighting, and forceDefaults.

uint NL3D::CDriverGLStates::_CurrentActiveTextureARB [private]
 

Definition at line 183 of file driver_opengl_states.h.

Referenced by activeTextureARB, forceActiveTextureARB, forceDefaults, getActiveTextureARB, resetTextureMode, and setTextureMode.

uint NL3D::CDriverGLStates::_CurrentClientActiveTextureARB [private]
 

Definition at line 191 of file driver_opengl_states.h.

Referenced by clientActiveTextureARB, enableTexCoordArray, and forceDefaults.

float NL3D::CDriverGLStates::_CurShininess [private]
 

Definition at line 179 of file driver_opengl_states.h.

Referenced by forceDefaults, and setShininess.

uint32 NL3D::CDriverGLStates::_CurSpecular [private]
 

Definition at line 178 of file driver_opengl_states.h.

Referenced by forceDefaults, and setSpecular.

float NL3D::CDriverGLStates::_CurZRangeDelta [private]
 

Definition at line 198 of file driver_opengl_states.h.

Referenced by forceDefaults, and setDepthRange.

bool NL3D::CDriverGLStates::_CurZWrite [private]
 

Definition at line 168 of file driver_opengl_states.h.

Referenced by enableZWrite, and forceDefaults.

bool NL3D::CDriverGLStates::_NormalArrayEnabled [private]
 

Definition at line 187 of file driver_opengl_states.h.

Referenced by enableNormalArray, and init.

bool NL3D::CDriverGLStates::_SecondaryColorArrayEnabled [private]
 

Definition at line 190 of file driver_opengl_states.h.

Referenced by enableSecondaryColorArray, and init.

bool NL3D::CDriverGLStates::_TexCoordArrayEnabled[8] [private]
 

Definition at line 192 of file driver_opengl_states.h.

Referenced by enableTexCoordArray, and init.

bool NL3D::CDriverGLStates::_TexGen[8] [private]
 

Definition at line 195 of file driver_opengl_states.h.

Referenced by enableTexGen, and forceDefaults.

GLint NL3D::CDriverGLStates::_TexGenMode[8] [private]
 

Definition at line 196 of file driver_opengl_states.h.

Referenced by forceDefaults, and setTexGenMode.

bool NL3D::CDriverGLStates::_TextureCubeMapSupported [private]
 

Definition at line 182 of file driver_opengl_states.h.

Referenced by CDriverGLStates, and init.

TTextureMode NL3D::CDriverGLStates::_TextureMode[8] [private]
 

Definition at line 184 of file driver_opengl_states.h.

Referenced by forceDefaults, resetTextureMode, and setTextureMode.

bool NL3D::CDriverGLStates::_VertexArrayEnabled [private]
 

Definition at line 186 of file driver_opengl_states.h.

Referenced by enableVertexArray, and init.

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

Definition at line 193 of file driver_opengl_states.h.

Referenced by enableVertexAttribArray, enableVertexAttribArrayForEXTVertexShader, and init.

bool NL3D::CDriverGLStates::_VertexColorLighted [private]
 

Definition at line 180 of file driver_opengl_states.h.

Referenced by forceDefaults, and setVertexColorLighted.

bool NL3D::CDriverGLStates::_WeightArrayEnabled [private]
 

Definition at line 188 of file driver_opengl_states.h.

Referenced by enableWeightArray, and init.


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