# 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  

driver_opengl_states.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_DRIVER_OPENGL_STATES_H
00027 #define NL_DRIVER_OPENGL_STATES_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/vertex_buffer.h"
00031 #include <GL/gl.h>
00032 
00033 
00034 namespace NL3D 
00035 {
00036 
00037 
00038 
00039 // ***************************************************************************
00078 class CDriverGLStates
00079 {
00080 public:
00081 
00083         CDriverGLStates();
00084         // init. Do it just after setDisplay()
00085         void                    init(bool supportTextureCubeMap);
00086 
00088         void                    forceDefaults(uint nbTextureStages);
00089 
00091         // @{
00092         void                    enableBlend(uint enable);
00093         void                    enableCullFace(uint enable);
00095         void                    enableAlphaTest(uint enable);
00096         void                    enableLighting(uint enable);
00097         void                    enableZWrite(uint enable);      
00098         // @}
00099 
00101         void                    blendFunc(GLenum src, GLenum dst);
00103         void                    depthFunc(GLenum zcomp);
00105         void                    alphaFunc(float threshold);
00106 
00109         // @{
00110         void                    setEmissive(uint32 packedColor, const GLfloat color[4]);
00111         void                    setAmbient(uint32 packedColor, const GLfloat color[4]);
00112         void                    setDiffuse(uint32 packedColor, const GLfloat color[4]);
00113         void                    setSpecular(uint32 packedColor, const GLfloat color[4]);
00114         void                    setShininess(float shin);
00115         void                    setVertexColorLighted(bool enable);
00116         void                    setDepthRange (float zDelta);
00117         void                    enableTexGen (uint stage, bool enable);
00118         void                    setTexGenMode (uint stage, GLint mode);
00119         // @}
00120         
00121         
00122 
00124         // @{
00125         enum                    TTextureMode {TextureDisabled, Texture2D, TextureCubeMap, TextureModeCount};
00127         void                    activeTextureARB(uint stage);
00129         void                    forceActiveTextureARB(uint stage);
00131         uint                    getActiveTextureARB() const { return _CurrentActiveTextureARB; }
00135         void                    setTextureMode(TTextureMode texMode);
00136         // reset texture mode to the default (disabled) for the current stage. It forces the state (useful after texture shaders)
00137         void                    resetTextureMode();     
00138         // @}
00139 
00142         // @{
00143         void                    enableVertexArray(bool enable);
00144         void                    enableNormalArray(bool enable);
00145         void                    enableWeightArray(bool enable);
00146         void                    enableColorArray(bool enable);
00147         void                    enableSecondaryColorArray(bool enable);
00149         void                    clientActiveTextureARB(uint stage);
00151         void                    enableTexCoordArray(bool enable);
00153         void                    enableVertexAttribArray(uint glIndex, bool enable);
00154         // @}
00155         
00156 private:
00157         bool                    _CurBlend;
00158         bool                    _CurCullFace;
00159         bool                    _CurAlphaTest;
00160         bool                    _CurLighting;
00161         bool                    _CurZWrite;     
00162 
00163         GLenum                  _CurBlendSrc;
00164         GLenum                  _CurBlendDst;
00165         GLenum                  _CurDepthFunc;
00166         float                   _CurAlphaTestThreshold;
00167 
00168         uint32                  _CurEmissive;
00169         uint32                  _CurAmbient;
00170         uint32                  _CurDiffuse;
00171         uint32                  _CurSpecular;
00172         float                   _CurShininess;
00173         bool                    _VertexColorLighted;
00174 
00175         bool                    _TextureCubeMapSupported;
00176         uint                    _CurrentActiveTextureARB;
00177         TTextureMode    _TextureMode[IDRV_MAT_MAXTEXTURES];
00178 
00179         bool                    _VertexArrayEnabled;
00180         bool                    _NormalArrayEnabled;
00181         bool                    _WeightArrayEnabled;
00182         bool                    _ColorArrayEnabled;
00183         bool                    _SecondaryColorArrayEnabled;
00184         uint                    _CurrentClientActiveTextureARB;
00185         bool                    _TexCoordArrayEnabled[IDRV_MAT_MAXTEXTURES];
00186         bool                    _VertexAttribArrayEnabled[CVertexBuffer::NumValue];     
00187 
00188         bool                    _TexGen[IDRV_MAT_MAXTEXTURES];
00189         GLint                   _TexGenMode[IDRV_MAT_MAXTEXTURES];
00190 
00191         float                   _CurZRangeDelta;
00192 };
00193 
00194 
00195 } // NL3D
00196 
00197 
00198 #endif // NL_DRIVER_OPENGL_STATES_H
00199 
00200 /* End of driver_opengl_states.h */