#include <driver_opengl_states.h>
Nevrax France
Definition at line 79 of file driver_opengl_states.h.
Texture Mode setting. | |
enum | TTextureMode { TextureDisabled, Texture2D, TextureCubeMap, TextureModeCount } |
void | activeTextureARB (uint stage) |
same as glActiveTextureARB(). usefull for setTextureMode. | |
void | forceActiveTextureARB (uint stage) |
same as active texture arb, but with no cache check | |
uint | getActiveTextureARB () const |
get active texture | |
void | resetTextureMode () |
void | setTextureMode (TTextureMode texMode) |
Public Types | |
Public Member Functions | |
void | alphaFunc (float threshold) |
glAlphaFunc | |
void | blendFunc (GLenum src, GLenum dst) |
glBlendFunc. | |
CDriverGLStates () | |
Constructor. no-op. | |
void | depthFunc (GLenum zcomp) |
glDepthFunc. | |
void | forceDefaults (uint nbTextureStages) |
Reset all OpenGL states of interest to default, and update caching. | |
void | init (bool supportTextureCubeMap) |
Vertex Array enabling. | |
equivalent to glEnableClientState() / glDisableClientState(). NB: Not modified by forceDefaults() | |
void | clientActiveTextureARB (uint stage) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
void | enableColorArray (bool enable) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
void | enableNormalArray (bool enable) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
void | enableSecondaryColorArray (bool enable) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
void | enableTexCoordArray (bool enable) |
NB: caller must call correct clientActiveTextureARB() before. | |
void | enableVertexArray (bool enable) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
void | enableVertexAttribArray (uint glIndex, bool enable) |
void | enableVertexAttribArrayForEXTVertexShader (uint glIndex, bool enable, uint *variants) |
void | enableWeightArray (bool enable) |
same as glClientActiveTextureARB(). usefull for enableTexCoordArray. | |
enable if !0 | |
void | enableAlphaTest (uint enable) |
enable and set good AlphaFunc. | |
void | enableBlend (uint enable) |
enable and set good AlphaFunc. | |
void | enableCullFace (uint enable) |
enable and set good AlphaFunc. | |
void | enableFog (uint enable) |
enable and set good AlphaFunc. | |
void | enableLighting (uint enable) |
enable and set good AlphaFunc. | |
void | enableZWrite (uint enable) |
enable and set good AlphaFunc. | |
Material setting. | |
Each f() get an uint32 for fast comparison, and OpenGL colors. | |
void | setAmbient (uint32 packedColor, const GLfloat color[4]) |
void | setDepthRange (float zDelta) |
void | setDiffuse (uint32 packedColor, const GLfloat color[4]) |
void | setEmissive (uint32 packedColor, const GLfloat color[4]) |
void | setShininess (float shin) |
void | setSpecular (uint32 packedColor, const GLfloat color[4]) |
void | setTexGenMode (uint stage, GLint mode) |
void | setVertexColorLighted (bool enable) |
Private Attributes | |
bool | _ColorArrayEnabled |
bool | _CurAlphaTest |
float | _CurAlphaTestThreshold |
uint32 | _CurAmbient |
bool | _CurBlend |
GLenum | _CurBlendDst |
GLenum | _CurBlendSrc |
bool | _CurCullFace |
GLenum | _CurDepthFunc |
uint32 | _CurDiffuse |
uint32 | _CurEmissive |
bool | _CurFog |
bool | _CurLighting |
uint | _CurrentActiveTextureARB |
uint | _CurrentClientActiveTextureARB |
float | _CurShininess |
uint32 | _CurSpecular |
float | _CurZRangeDelta |
bool | _CurZWrite |
bool | _NormalArrayEnabled |
bool | _SecondaryColorArrayEnabled |
bool | _TexCoordArrayEnabled [8] |
GLint | _TexGenMode [8] |
bool | _TextureCubeMapSupported |
TTextureMode | _TextureMode [8] |
bool | _VertexArrayEnabled |
bool | _VertexAttribArrayEnabled [CVertexBuffer::NumValue] |
bool | _VertexColorLighted |
bool | _WeightArrayEnabled |
|
Definition at line 127 of file driver_opengl_states.h. Referenced by setTextureMode().
00127 {TextureDisabled, Texture2D, TextureCubeMap, TextureModeCount}; |
|
Constructor. no-op.
Definition at line 37 of file driver_opengl_states.cpp. References _TextureCubeMapSupported.
00038 { 00039 _TextureCubeMapSupported= false; 00040 } |
|
|
glAlphaFunc
Definition at line 284 of file driver_opengl_states.cpp. References _CurAlphaTestThreshold. Referenced by NL3D::CDriverGL::setupMaterial().
00285 { 00286 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00287 if(threshold != _CurAlphaTestThreshold) 00288 #endif 00289 { 00290 // new state 00291 _CurAlphaTestThreshold= threshold; 00292 // setup function. 00293 glAlphaFunc(GL_GREATER, _CurAlphaTestThreshold); 00294 } 00295 } |
|
glBlendFunc.
Definition at line 252 of file driver_opengl_states.cpp. References _CurBlendDst, _CurBlendSrc, and src. Referenced by NL3D::CDriverGL::setupLightMapPass(), NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupSpecularPass().
00253 { 00254 // If different from current setup, update. 00255 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00256 if( src!= _CurBlendSrc || dst!=_CurBlendDst ) 00257 #endif 00258 { 00259 // new state. 00260 _CurBlendSrc= src; 00261 _CurBlendDst= dst; 00262 // Setup GLState. 00263 glBlendFunc(_CurBlendSrc, _CurBlendDst); 00264 } 00265 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 594 of file driver_opengl_states.cpp. References _CurrentClientActiveTextureARB, nglClientActiveTextureARB, and uint. Referenced by enableVertexAttribArrayForEXTVertexShader(), NL3D::CDriverGL::setupGlArraysForEXTVertexShader(), NL3D::CDriverGL::setupUVPtr(), NL3D::CDriverGL::toggleGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00595 { 00596 if( _CurrentClientActiveTextureARB != stage ) 00597 { 00598 nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage); 00599 _CurrentClientActiveTextureARB= stage; 00600 } 00601 } |
|
glDepthFunc.
Definition at line 268 of file driver_opengl_states.cpp. References _CurDepthFunc. Referenced by NL3D::CDriverGL::setupMaterial().
00269 { 00270 // If different from current setup, update. 00271 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00272 if( zcomp != _CurDepthFunc ) 00273 #endif 00274 { 00275 // new state. 00276 _CurDepthFunc= zcomp; 00277 // Setup GLState. 00278 glDepthFunc(_CurDepthFunc); 00279 } 00280 } |
|
enable and set good AlphaFunc.
Definition at line 188 of file driver_opengl_states.cpp. References _CurAlphaTest, and uint. Referenced by NL3D::CDriverGL::setupMaterial().
00189 { 00190 // If different from current setup, update. 00191 bool enabled= (enable!=0); 00192 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00193 if( enabled != _CurAlphaTest ) 00194 #endif 00195 { 00196 // new state. 00197 _CurAlphaTest= enabled; 00198 00199 // Setup GLState. 00200 if(_CurAlphaTest) 00201 { 00202 glEnable(GL_ALPHA_TEST); 00203 } 00204 else 00205 { 00206 glDisable(GL_ALPHA_TEST); 00207 } 00208 } 00209 } |
|
enable and set good AlphaFunc.
Definition at line 150 of file driver_opengl_states.cpp. References _CurBlend, and uint. Referenced by NL3D::CDriverGL::setupLightMapPass(), NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupSpecularPass().
00151 { 00152 // If different from current setup, update. 00153 bool enabled= (enable!=0); 00154 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00155 if( enabled != _CurBlend ) 00156 #endif 00157 { 00158 // new state. 00159 _CurBlend= enabled; 00160 // Setup GLState. 00161 if(_CurBlend) 00162 glEnable(GL_BLEND); 00163 else 00164 glDisable(GL_BLEND); 00165 } 00166 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 561 of file driver_opengl_states.cpp. References _ColorArrayEnabled. Referenced by NL3D::CDriverGL::beginLightMapMultiPass(), enableVertexAttribArrayForEXTVertexShader(), NL3D::CDriverGL::resetLightMapVertexSetup(), NL3D::CDriverGL::setupGlArraysForNVVertexProgram(), NL3D::CDriverGL::setupGlArraysStd(), NL3D::CDriverGL::toggleGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00562 { 00563 if(_ColorArrayEnabled != enable) 00564 { 00565 if(enable) 00566 glEnableClientState(GL_COLOR_ARRAY); 00567 else 00568 glDisableClientState(GL_COLOR_ARRAY); 00569 _ColorArrayEnabled= enable; 00570 } 00571 } |
|
enable and set good AlphaFunc.
Definition at line 169 of file driver_opengl_states.cpp. References _CurCullFace, and uint. Referenced by NL3D::CDriverGL::setupMaterial().
00170 { 00171 // If different from current setup, update. 00172 bool enabled= (enable!=0); 00173 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00174 if( enabled != _CurCullFace ) 00175 #endif 00176 { 00177 // new state. 00178 _CurCullFace= enabled; 00179 // Setup GLState. 00180 if(_CurCullFace) 00181 glEnable(GL_CULL_FACE); 00182 else 00183 glDisable(GL_CULL_FACE); 00184 } 00185 } |
|
enable and set good AlphaFunc.
Definition at line 695 of file driver_opengl_states.cpp. Referenced by NL3D::CDriverGL::enableFog(), and NL3D::CDriverGL::setupMaterial().
00696 { 00697 // If different from current setup, update. 00698 bool enabled= (enable!=0); 00699 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00700 if( enabled != _CurFog ) 00701 #endif 00702 { 00703 // new state. 00704 _CurFog= enabled; 00705 // Setup GLState. 00706 if(_CurFog) 00707 glEnable(GL_FOG); 00708 else 00709 glDisable(GL_FOG); 00710 } 00711 } |
|
enable and set good AlphaFunc.
Definition at line 212 of file driver_opengl_states.cpp. References _CurLighting, and uint. Referenced by NL3D::CDriverGL::beginLightMapMultiPass(), and NL3D::CDriverGL::setupMaterial().
00213 { 00214 // If different from current setup, update. 00215 bool enabled= (enable!=0); 00216 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00217 if( enabled != _CurLighting ) 00218 #endif 00219 { 00220 // new state. 00221 _CurLighting= enabled; 00222 // Setup GLState. 00223 if(_CurLighting) 00224 glEnable(GL_LIGHTING); 00225 else 00226 glDisable(GL_LIGHTING); 00227 } 00228 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 537 of file driver_opengl_states.cpp. References _NormalArrayEnabled. Referenced by enableVertexAttribArrayForEXTVertexShader(), NL3D::CDriverGL::setupGlArraysStd(), NL3D::CDriverGL::toggleGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00538 { 00539 if(_NormalArrayEnabled != enable) 00540 { 00541 if(enable) 00542 glEnableClientState(GL_NORMAL_ARRAY); 00543 else 00544 glDisableClientState(GL_NORMAL_ARRAY); 00545 _NormalArrayEnabled= enable; 00546 } 00547 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 575 of file driver_opengl_states.cpp. References _SecondaryColorArrayEnabled, and nglSecondaryColor3ubEXT. Referenced by NL3D::CDriverGL::setupGlArraysForNVVertexProgram(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00576 { 00577 if(_SecondaryColorArrayEnabled != enable) 00578 { 00579 if(enable) 00580 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); 00581 else 00582 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); 00583 _SecondaryColorArrayEnabled= enable; 00584 // If disable 00585 if(!enable) 00586 { 00587 // GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs 00588 nglSecondaryColor3ubEXT(0,0,0); 00589 } 00590 } 00591 } |
|
NB: caller must call correct clientActiveTextureARB() before.
Definition at line 604 of file driver_opengl_states.cpp. References _CurrentClientActiveTextureARB, and _TexCoordArrayEnabled. Referenced by enableVertexAttribArrayForEXTVertexShader(), NL3D::CDriverGL::setupUVPtr(), NL3D::CDriverGL::toggleGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00605 { 00606 if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable) 00607 { 00608 if(enable) 00609 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 00610 else 00611 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 00612 _TexCoordArrayEnabled[_CurrentClientActiveTextureARB]= enable; 00613 } 00614 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 525 of file driver_opengl_states.cpp. References _VertexArrayEnabled. Referenced by enableVertexAttribArrayForEXTVertexShader(), NL3D::CDriverGL::setupGlArraysStd(), NL3D::CDriverGL::toggleGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00526 { 00527 if(_VertexArrayEnabled != enable) 00528 { 00529 if(enable) 00530 glEnableClientState(GL_VERTEX_ARRAY); 00531 else 00532 glDisableClientState(GL_VERTEX_ARRAY); 00533 _VertexArrayEnabled= enable; 00534 } 00535 } |
|
For vertexProgram. do not check if supported or not. Definition at line 617 of file driver_opengl_states.cpp. References _VertexAttribArrayEnabled, GL_VERTEX_ATTRIB_ARRAY0_NV, and uint. Referenced by NL3D::CDriverGL::setupGlArraysForNVVertexProgram(), and NL3D::CDriverGL::toggleGlArraysForNVVertexProgram().
00618 { 00619 if(_VertexAttribArrayEnabled[glIndex] != enable) 00620 { 00621 if(enable) 00622 glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); 00623 else 00624 glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); 00625 _VertexAttribArrayEnabled[glIndex]= enable; 00626 } 00627 } |
|
Same as enableVertexAttribArray, but for EXTVertexShader (need variant ID)
Definition at line 631 of file driver_opengl_states.cpp. References _VertexAttribArrayEnabled, clientActiveTextureARB(), enableColorArray(), enableNormalArray(), enableTexCoordArray(), enableVertexArray(), nglDisableVariantClientStateEXT, nglEnableVariantClientStateEXT, nlstop, and uint. Referenced by NL3D::CDriverGL::setupGlArraysForEXTVertexShader(), and NL3D::CDriverGL::toggleGlArraysForEXTVertexShader().
00632 { 00633 if(_VertexAttribArrayEnabled[glIndex] != enable) 00634 { 00635 switch(glIndex) 00636 { 00637 case 0: // position 00638 enableVertexArray(enable); 00639 break; 00640 case 1: // skin weight 00641 if(enable) 00642 nglEnableVariantClientStateEXT(variants[CDriverGL::EVSSkinWeightVariant]); 00643 else 00644 nglDisableVariantClientStateEXT(variants[CDriverGL::EVSSkinWeightVariant]); 00645 break; 00646 case 2: // normal 00647 enableNormalArray(enable); 00648 break; 00649 case 3: // color 00650 enableColorArray(enable); 00651 break; 00652 case 4: // secondary color 00653 if(enable) 00654 nglEnableVariantClientStateEXT(variants[CDriverGL::EVSSecondaryColorVariant]); 00655 else 00656 nglDisableVariantClientStateEXT(variants[CDriverGL::EVSSecondaryColorVariant]); 00657 break; 00658 case 5: // fog coordinate 00659 if(enable) 00660 nglEnableVariantClientStateEXT(variants[CDriverGL::EVSFogCoordsVariant]); 00661 else 00662 nglDisableVariantClientStateEXT(variants[CDriverGL::EVSFogCoordsVariant]); 00663 break; 00664 case 6: // palette skin 00665 if(enable) 00666 nglEnableVariantClientStateEXT(variants[CDriverGL::EVSPaletteSkinVariant]); 00667 else 00668 nglDisableVariantClientStateEXT(variants[CDriverGL::EVSPaletteSkinVariant]); 00669 break; 00670 case 7: // empty 00671 nlstop 00672 break; 00673 case 8: 00674 case 9: 00675 case 10: 00676 case 11: 00677 case 12: 00678 case 13: 00679 case 14: 00680 case 15: 00681 clientActiveTextureARB(glIndex - 8); 00682 enableTexCoordArray(enable); 00683 break; 00684 default: 00685 nlstop; // invalid value 00686 break; 00687 } 00688 _VertexAttribArrayEnabled[glIndex]= enable; 00689 } 00690 } |
|
same as glClientActiveTextureARB(). usefull for enableTexCoordArray.
Definition at line 549 of file driver_opengl_states.cpp. References _WeightArrayEnabled.
00550 { 00551 if(_WeightArrayEnabled != enable) 00552 { 00553 if(enable) 00554 glEnableClientState(GL_VERTEX_WEIGHTING_EXT); 00555 else 00556 glDisableClientState(GL_VERTEX_WEIGHTING_EXT); 00557 _WeightArrayEnabled= enable; 00558 } 00559 } |
|
enable and set good AlphaFunc.
Definition at line 231 of file driver_opengl_states.cpp. References _CurZWrite, and uint. Referenced by NL3D::CDriverGL::clearZBuffer(), and NL3D::CDriverGL::setupMaterial().
00232 { 00233 // If different from current setup, update. 00234 bool enabled= (enable!=0); 00235 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00236 if( enabled != _CurZWrite ) 00237 #endif 00238 { 00239 // new state. 00240 _CurZWrite= enabled; 00241 // Setup GLState. 00242 if(_CurZWrite) 00243 glDepthMask(GL_TRUE); 00244 else 00245 glDepthMask(GL_FALSE); 00246 } 00247 } |
|
same as active texture arb, but with no cache check
Definition at line 517 of file driver_opengl_states.cpp. References _CurrentActiveTextureARB, nglActiveTextureARB, and uint.
00518 { 00519 nglActiveTextureARB(GL_TEXTURE0_ARB+stage); 00520 _CurrentActiveTextureARB= stage; 00521 } |
|
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, _CurFog, _CurLighting, _CurrentActiveTextureARB, _CurrentClientActiveTextureARB, _CurShininess, _CurSpecular, _CurZRangeDelta, _CurZWrite, _TexGenMode, _TextureCubeMapSupported, _TextureMode, _VertexColorLighted, nglActiveTextureARB, nglClientActiveTextureARB, TextureDisabled, uint, and uint32. Referenced by NL3D::CDriverGL::swapBuffers().
00068 { 00069 // Enable / disable. 00070 _CurFog= false; 00071 _CurBlend= false; 00072 _CurCullFace= true; 00073 _CurAlphaTest= false; 00074 _CurLighting= false; 00075 _CurZWrite= true; 00076 // setup GLStates. 00077 glDisable(GL_FOG); 00078 glDisable(GL_BLEND); 00079 glEnable(GL_CULL_FACE); 00080 glDisable(GL_ALPHA_TEST); 00081 glDisable(GL_LIGHTING); 00082 glDepthMask(GL_TRUE); 00083 00084 // Func. 00085 _CurBlendSrc= GL_SRC_ALPHA; 00086 _CurBlendDst= GL_ONE_MINUS_SRC_ALPHA; 00087 _CurDepthFunc= GL_LEQUAL; 00088 _CurAlphaTestThreshold= 0.5f; 00089 // setup GLStates. 00090 glBlendFunc(_CurBlendSrc, _CurBlendDst); 00091 glDepthFunc(_CurDepthFunc); 00092 glAlphaFunc(GL_GREATER, _CurAlphaTestThreshold); 00093 00094 // Materials. 00095 uint32 packedOne= (CRGBA(255,255,255,255)).getPacked(); 00096 uint32 packedZero= (CRGBA(0,0,0,255)).getPacked(); 00097 _CurEmissive= packedZero; 00098 _CurAmbient= packedOne; 00099 _CurDiffuse= packedOne; 00100 _CurSpecular= packedZero; 00101 _CurShininess= 1; 00102 00103 // Lighted vertex color 00104 _VertexColorLighted=false; 00105 glDisable(GL_COLOR_MATERIAL); 00106 00107 // setup GLStates. 00108 static const GLfloat one[4]= {1,1,1,1}; 00109 static const GLfloat zero[4]= {0,0,0,1}; 00110 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, zero); 00111 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, one); 00112 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, one); 00113 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero); 00114 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, _CurShininess); 00115 00116 00117 // TexModes 00118 uint stage; 00119 for(stage=0;stage<nbStages; stage++) 00120 { 00121 // disable texturing. 00122 nglActiveTextureARB(GL_TEXTURE0_ARB+stage); 00123 glDisable(GL_TEXTURE_2D); 00124 if(_TextureCubeMapSupported) 00125 glDisable(GL_TEXTURE_CUBE_MAP_ARB); 00126 _TextureMode[stage]= TextureDisabled; 00127 00128 // Tex gen init 00129 _TexGenMode[stage] = 0; 00130 glDisable( GL_TEXTURE_GEN_S ); 00131 glDisable( GL_TEXTURE_GEN_T ); 00132 glDisable( GL_TEXTURE_GEN_R ); 00133 glDisable( GL_TEXTURE_GEN_Q ); 00134 } 00135 00136 // ActiveTexture current texture to 0. 00137 nglActiveTextureARB(GL_TEXTURE0_ARB); 00138 _CurrentActiveTextureARB= 0; 00139 nglClientActiveTextureARB(GL_TEXTURE0_ARB); 00140 _CurrentClientActiveTextureARB= 0; 00141 00142 // Depth range 00143 _CurZRangeDelta = 0; 00144 glDepthRange (0, 1); 00145 } |
|
get active texture
Definition at line 133 of file driver_opengl_states.h. References _CurrentActiveTextureARB, and uint.
00133 { return _CurrentActiveTextureARB; } |
|
Definition at line 44 of file driver_opengl_states.cpp. References _ColorArrayEnabled, _NormalArrayEnabled, _SecondaryColorArrayEnabled, _TexCoordArrayEnabled, _TextureCubeMapSupported, _VertexArrayEnabled, _VertexAttribArrayEnabled, _WeightArrayEnabled, NL3D::IDRV_MAT_MAXTEXTURES, and uint.
00045 { 00046 _TextureCubeMapSupported= supportTextureCubeMap; 00047 00048 // By default all arrays are disabled. 00049 _VertexArrayEnabled= false; 00050 _NormalArrayEnabled= false; 00051 _WeightArrayEnabled= false; 00052 _ColorArrayEnabled= false; 00053 _SecondaryColorArrayEnabled= false; 00054 uint i; 00055 for(i=0; i<IDRV_MAT_MAXTEXTURES; i++) 00056 { 00057 _TexCoordArrayEnabled[i]= false; 00058 } 00059 for(i=0; i<CVertexBuffer::NumValue; i++) 00060 { 00061 _VertexAttribArrayEnabled[i]= false; 00062 } 00063 } |
|
Definition at line 461 of file driver_opengl_states.cpp. References _CurrentActiveTextureARB, _TextureCubeMapSupported, _TextureMode, and TextureDisabled.
00462 { 00463 glDisable(GL_TEXTURE_2D); 00464 if (_TextureCubeMapSupported) 00465 { 00466 glDisable(GL_TEXTURE_CUBE_MAP_ARB); 00467 } 00468 _TextureMode[_CurrentActiveTextureARB]= TextureDisabled; 00469 } |
|
Definition at line 311 of file driver_opengl_states.cpp. References _CurAmbient, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00312 { 00313 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00314 if( packedColor!=_CurAmbient ) 00315 #endif 00316 { 00317 _CurAmbient= packedColor; 00318 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); 00319 } 00320 } |
|
Definition at line 400 of file driver_opengl_states.cpp. References _CurZRangeDelta. Referenced by NL3D::CDriverGL::setupMaterial().
00401 { 00402 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00403 if (zDelta != _CurZRangeDelta) 00404 #endif 00405 { 00406 _CurZRangeDelta = zDelta; 00407 00408 // Setup the range 00409 glDepthRange (zDelta, 1+zDelta); 00410 } 00411 } |
|
Definition at line 323 of file driver_opengl_states.cpp. References _CurDiffuse, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00324 { 00325 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00326 if( packedColor!=_CurDiffuse ) 00327 #endif 00328 { 00329 _CurDiffuse= packedColor; 00330 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); 00331 } 00332 } |
|
Definition at line 299 of file driver_opengl_states.cpp. References _CurEmissive, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00300 { 00301 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00302 if( packedColor!=_CurEmissive ) 00303 #endif 00304 { 00305 _CurEmissive= packedColor; 00306 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); 00307 } 00308 } |
|
Definition at line 347 of file driver_opengl_states.cpp. References _CurShininess. Referenced by NL3D::CDriverGL::setupMaterial().
00348 { 00349 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00350 if( shin != _CurShininess ) 00351 #endif 00352 { 00353 _CurShininess= shin; 00354 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shin); 00355 } 00356 } |
|
Definition at line 335 of file driver_opengl_states.cpp. References _CurSpecular, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00336 { 00337 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00338 if( packedColor!=_CurSpecular ) 00339 #endif 00340 { 00341 _CurSpecular= packedColor; 00342 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); 00343 } 00344 } |
|
Definition at line 414 of file driver_opengl_states.cpp. References _TexGenMode, and uint. Referenced by NL3D::CDriverGL::setTextureEnvFunction(), NL3D::CDriverGL::setupLightMapPass(), NL3D::CDriverGL::setupSpecularBegin(), and NL3D::CDriverGL::setupSpecularEnd().
00415 { 00416 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00417 if (mode != _TexGenMode[stage]) 00418 #endif 00419 { 00420 _TexGenMode[stage] = mode; 00421 00422 if(mode==0) 00423 { 00424 glDisable( GL_TEXTURE_GEN_S ); 00425 glDisable( GL_TEXTURE_GEN_T ); 00426 glDisable( GL_TEXTURE_GEN_R ); 00427 glDisable( GL_TEXTURE_GEN_Q ); 00428 } 00429 else 00430 { 00431 glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode); 00432 glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode); 00433 glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, mode); 00434 /* Object or Eye Space ? => enable W generation. VERY IMPORTANT because 00435 was a bug with VegetableRender and ShadowRender: 00436 - Vegetable use the TexCoord1.w in his VertexProgram 00437 - Shadow Render don't use any TexCoord in VB (since projected) 00438 => TexCoord1.w dirty!! 00439 */ 00440 if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR) 00441 { 00442 glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, mode); 00443 } 00444 else 00445 { 00446 glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); 00447 } 00448 // Enable All. 00449 glEnable( GL_TEXTURE_GEN_S ); 00450 glEnable( GL_TEXTURE_GEN_T ); 00451 glEnable( GL_TEXTURE_GEN_R ); 00452 glEnable( GL_TEXTURE_GEN_Q ); 00453 } 00454 } 00455 } |
|
change if needed the texture mode of the current active Texture ARB. NB: if CubeMap extension not supported, TextureCubeMap <=> TextureDisabled. Definition at line 473 of file driver_opengl_states.cpp. References _CurrentActiveTextureARB, _TextureCubeMapSupported, _TextureMode, Texture2D, TextureCubeMap, and TTextureMode. Referenced by NL3D::CDriverGL::activateTexture(), NL3D::CDriverGL::copyFrameBufferToTexture(), NL3D::CDriverGL::setupSpecularPass(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().
00474 { 00475 TTextureMode oldTexMode = _TextureMode[_CurrentActiveTextureARB]; 00476 if(oldTexMode != texMode) 00477 { 00478 // Disable first old mode. 00479 if(oldTexMode == Texture2D) 00480 glDisable(GL_TEXTURE_2D); 00481 else if(oldTexMode == TextureCubeMap) 00482 { 00483 if(_TextureCubeMapSupported) 00484 glDisable(GL_TEXTURE_CUBE_MAP_ARB); 00485 else 00486 glDisable(GL_TEXTURE_2D); 00487 } 00488 00489 // Enable new mode. 00490 if(texMode == Texture2D) 00491 glEnable(GL_TEXTURE_2D); 00492 else if(texMode == TextureCubeMap) 00493 { 00494 if(_TextureCubeMapSupported) 00495 glEnable(GL_TEXTURE_CUBE_MAP_ARB); 00496 else 00497 glDisable(GL_TEXTURE_2D); 00498 } 00499 00500 // new mode. 00501 _TextureMode[_CurrentActiveTextureARB]= texMode; 00502 } 00503 } |
|
Definition at line 370 of file driver_opengl_states.cpp. References _CurDiffuse, _VertexColorLighted, NLMISC::CRGBA::A, NLMISC::CRGBA::B, NL3D::convColor(), NLMISC::CRGBA::G, NLMISC::CRGBA::R, and uint8. Referenced by NL3D::CDriverGL::setupMaterial().
00371 { 00372 #ifndef NL3D_GLSTATE_DISABLE_CACHE 00373 if( enable != _VertexColorLighted) 00374 #endif 00375 { 00376 _VertexColorLighted= enable; 00377 00378 if (_VertexColorLighted) 00379 { 00380 glEnable (GL_COLOR_MATERIAL); 00381 glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); 00382 } 00383 else 00384 { 00385 glDisable (GL_COLOR_MATERIAL); 00386 // Since we leave glColorMaterial mode, GL diffuse is now scracth. reset him to current value. 00387 CRGBA diffCol; 00388 diffCol.R= (uint8)((_CurDiffuse >> 24) & 255); 00389 diffCol.G= (uint8)((_CurDiffuse >> 16) & 255); 00390 diffCol.B= (uint8)((_CurDiffuse >> 8) & 255); 00391 diffCol.A= (uint8)((_CurDiffuse ) & 255); 00392 GLfloat glColor[4]; 00393 convColor(diffCol, glColor); 00394 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, glColor); 00395 } 00396 } 00397 } |
|
Definition at line 192 of file driver_opengl_states.h. Referenced by enableColorArray(), and init(). |
|
Definition at line 169 of file driver_opengl_states.h. Referenced by enableAlphaTest(), and forceDefaults(). |
|
Definition at line 176 of file driver_opengl_states.h. Referenced by alphaFunc(), and forceDefaults(). |
|
Definition at line 179 of file driver_opengl_states.h. Referenced by forceDefaults(), and setAmbient(). |
|
Definition at line 166 of file driver_opengl_states.h. Referenced by enableBlend(), and forceDefaults(). |
|
Definition at line 174 of file driver_opengl_states.h. Referenced by blendFunc(), and forceDefaults(). |
|
Definition at line 173 of file driver_opengl_states.h. Referenced by blendFunc(), and forceDefaults(). |
|
Definition at line 168 of file driver_opengl_states.h. Referenced by enableCullFace(), and forceDefaults(). |
|
Definition at line 175 of file driver_opengl_states.h. Referenced by depthFunc(), and forceDefaults(). |
|
Definition at line 180 of file driver_opengl_states.h. Referenced by forceDefaults(), setDiffuse(), and setVertexColorLighted(). |
|
Definition at line 178 of file driver_opengl_states.h. Referenced by forceDefaults(), and setEmissive(). |
|
Definition at line 167 of file driver_opengl_states.h. Referenced by enableFog(), and forceDefaults(). |
|
Definition at line 170 of file driver_opengl_states.h. Referenced by enableLighting(), and forceDefaults(). |
|
Definition at line 186 of file driver_opengl_states.h. Referenced by activeTextureARB(), forceActiveTextureARB(), forceDefaults(), getActiveTextureARB(), resetTextureMode(), and setTextureMode(). |
|
Definition at line 194 of file driver_opengl_states.h. Referenced by clientActiveTextureARB(), enableTexCoordArray(), and forceDefaults(). |
|
Definition at line 182 of file driver_opengl_states.h. Referenced by forceDefaults(), and setShininess(). |
|
Definition at line 181 of file driver_opengl_states.h. Referenced by forceDefaults(), and setSpecular(). |
|
Definition at line 200 of file driver_opengl_states.h. Referenced by forceDefaults(), and setDepthRange(). |
|
Definition at line 171 of file driver_opengl_states.h. Referenced by enableZWrite(), and forceDefaults(). |
|
Definition at line 190 of file driver_opengl_states.h. Referenced by enableNormalArray(), and init(). |
|
Definition at line 193 of file driver_opengl_states.h. Referenced by enableSecondaryColorArray(), and init(). |
|
Definition at line 195 of file driver_opengl_states.h. Referenced by enableTexCoordArray(), and init(). |
|
Definition at line 198 of file driver_opengl_states.h. Referenced by forceDefaults(), and setTexGenMode(). |
|
Definition at line 185 of file driver_opengl_states.h. Referenced by CDriverGLStates(), forceDefaults(), init(), resetTextureMode(), and setTextureMode(). |
|
Definition at line 187 of file driver_opengl_states.h. Referenced by forceDefaults(), resetTextureMode(), and setTextureMode(). |
|
Definition at line 189 of file driver_opengl_states.h. Referenced by enableVertexArray(), and init(). |
|
Definition at line 196 of file driver_opengl_states.h. Referenced by enableVertexAttribArray(), enableVertexAttribArrayForEXTVertexShader(), and init(). |
|
Definition at line 183 of file driver_opengl_states.h. Referenced by forceDefaults(), and setVertexColorLighted(). |
|
Definition at line 191 of file driver_opengl_states.h. Referenced by enableWeightArray(), and init(). |