Some cleanup, most of the old OpenGL stuff should be gone.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 5326324b56
commit 7b5aaf7e0f

@ -232,13 +232,7 @@ CDriverGL3::CDriverGL3()
_RenderTargetFBO = false; _RenderTargetFBO = false;
_LightSetupDirty= false;
_ModelViewMatrixDirty= false;
_RenderSetupDirty= false;
// All lights default pos.
uint i; uint i;
for(i=0;i<MaxLight;i++)
_LightDirty[i]= false;
_CurrentGlNormalize= false; _CurrentGlNormalize= false;
_ForceNormalize= false; _ForceNormalize= false;
@ -273,9 +267,6 @@ CDriverGL3::CDriverGL3()
#endif #endif
} }
for( i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
_UserTexMatDirty[ i ] = false;
for( i = 0; i < IDRV_MAT_MAXTEXTURES; i++ ) for( i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
_UserTexMat[ i ].identity(); _UserTexMat[ i ].identity();
@ -292,8 +283,6 @@ CDriverGL3::CDriverGL3()
_LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture; _LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture;
_LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha; _LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha;
_ProjMatDirty = true;
std::fill(_StageSupportEMBM, _StageSupportEMBM + IDRV_MAT_MAXTEXTURES, false); std::fill(_StageSupportEMBM, _StageSupportEMBM + IDRV_MAT_MAXTEXTURES, false);
ATIWaterShaderHandleNoDiffuseMap = 0; ATIWaterShaderHandleNoDiffuseMap = 0;
@ -335,7 +324,6 @@ CDriverGL3::CDriverGL3()
_TextureTargetCubeFace = 0; _TextureTargetCubeFace = 0;
_TextureTargetUpload = false; _TextureTargetUpload = false;
#ifdef GLSL
currentProgram = NULL; currentProgram = NULL;
dynMatProgram = NULL; dynMatProgram = NULL;
@ -346,8 +334,6 @@ CDriverGL3::CDriverGL3()
loader.setManager( usrShaderManager ); loader.setManager( usrShaderManager );
loader.loadShaders( "./shaders" ); loader.loadShaders( "./shaders" );
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -357,7 +343,6 @@ CDriverGL3::~CDriverGL3()
release(); release();
#ifdef GLSL
currentProgram = NULL; currentProgram = NULL;
if( dynMatProgram != NULL ) if( dynMatProgram != NULL )
@ -368,7 +353,6 @@ CDriverGL3::~CDriverGL3()
shaderGenerator = NULL; shaderGenerator = NULL;
delete usrShaderManager; delete usrShaderManager;
usrShaderManager = NULL; usrShaderManager = NULL;
#endif
#if defined(NL_OS_MAC) #if defined(NL_OS_MAC)
[_autoreleasePool release]; [_autoreleasePool release];
@ -427,13 +411,6 @@ bool CDriverGL3::setupDisplay()
// Init OpenGL/Driver defaults. // Init OpenGL/Driver defaults.
//============================= //=============================
glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height); glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height);
#ifndef GLSL
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
#endif
glDisable(GL_AUTO_NORMAL); glDisable(GL_AUTO_NORMAL);
glDisable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_MATERIAL);
glEnable(GL_DITHER); glEnable(GL_DITHER);
@ -456,19 +433,8 @@ bool CDriverGL3::setupDisplay()
// Be always in EXTSeparateSpecularColor. // Be always in EXTSeparateSpecularColor.
if(_Extensions.EXTSeparateSpecularColor) if(_Extensions.EXTSeparateSpecularColor)
{ {
#ifndef GLSL
glLightModeli((GLenum)GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);
#endif
} }
#ifndef GLSL
_VertexProgramEnabled= false;
#else
_VertexProgramEnabled = true;
#endif
_LastSetupGLArrayVertexProgram= false;
// Init VertexArrayRange according to supported extenstion. // Init VertexArrayRange according to supported extenstion.
_SlowUnlockVBHard= false; _SlowUnlockVBHard= false;
@ -503,10 +469,6 @@ bool CDriverGL3::setupDisplay()
// init default env. // init default env.
CMaterial::CTexEnv env; // envmode init to default. CMaterial::CTexEnv env; // envmode init to default.
env.ConstantColor.set(255,255,255,255); env.ConstantColor.set(255,255,255,255);
#ifndef GLSL
forceActivateTexEnvMode(stage, env);
forceActivateTexEnvColor(stage, env);
#endif
// Not special TexEnv. // Not special TexEnv.
_CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled; _CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled;
@ -514,21 +476,6 @@ bool CDriverGL3::setupDisplay()
// set All TexGen by default to identity matrix (prefer use the textureMatrix scheme) // set All TexGen by default to identity matrix (prefer use the textureMatrix scheme)
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
#ifndef GLSL
GLfloat params[4];
params[0]=1; params[1]=0; params[2]=0; params[3]=0;
glTexGenfv(GL_S, GL_OBJECT_PLANE, params);
glTexGenfv(GL_S, GL_EYE_PLANE, params);
params[0]=0; params[1]=1; params[2]=0; params[3]=0;
glTexGenfv(GL_T, GL_OBJECT_PLANE, params);
glTexGenfv(GL_T, GL_EYE_PLANE, params);
params[0]=0; params[1]=0; params[2]=1; params[3]=0;
glTexGenfv(GL_R, GL_OBJECT_PLANE, params);
glTexGenfv(GL_R, GL_EYE_PLANE, params);
params[0]=0; params[1]=0; params[2]=0; params[3]=1;
glTexGenfv(GL_Q, GL_OBJECT_PLANE, params);
glTexGenfv(GL_Q, GL_EYE_PLANE, params);
#endif
} }
_PPLExponent = 1.f; _PPLExponent = 1.f;

@ -279,10 +279,8 @@ public:
void setupIndexBuffer(CIndexBuffer &vb); void setupIndexBuffer(CIndexBuffer &vb);
}; };
#ifdef GLSL
class CGLSLShaderGenerator; class CGLSLShaderGenerator;
class CUsrShaderManager; class CUsrShaderManager;
#endif
// *************************************************************************** // ***************************************************************************
class CDriverGL3 : public IDriver class CDriverGL3 : public IDriver
@ -834,21 +832,9 @@ private:
// The forceNormalize() state. // The forceNormalize() state.
bool _ForceNormalize; bool _ForceNormalize;
// To know if light setup has been changed from last render() ( any call to setupViewMatrix() or setLight() ).
bool _LightSetupDirty;
// To know if the modelview matrix setup has been changed from last render() (any call to setupViewMatrix() / setupModelMatrix() ).
bool _ModelViewMatrixDirty;
// To know if the projection matrix has been changed
bool _ProjMatDirty;
// Mirror the gl projection matrix when _ProjMatDirty = false // Mirror the gl projection matrix when _ProjMatDirty = false
NLMISC::CMatrix _GLProjMat; NLMISC::CMatrix _GLProjMat;
// Ored of _LightSetupDirty and _ModelViewMatrixDirty
bool _RenderSetupDirty;
// Backup znear and zfar // Backup znear and zfar
float _OODeltaZ; float _OODeltaZ;
@ -891,16 +877,14 @@ private:
uint _LightMode[MaxLight]; // Light mode. uint _LightMode[MaxLight]; // Light mode.
CVector _WorldLightPos[MaxLight]; // World position of the lights. CVector _WorldLightPos[MaxLight]; // World position of the lights.
CVector _WorldLightDirection[MaxLight]; // World direction of the lights. CVector _WorldLightDirection[MaxLight]; // World direction of the lights.
bool _LightDirty[MaxLight]; // Light that need a View position setup in refreshRenderSetup().
// For Lightmap Dynamic Lighting // For Lightmap Dynamic Lighting
CLight _LightMapDynamicLight; CLight _LightMapDynamicLight;
bool _LightMapDynamicLightEnabled; bool _LightMapDynamicLightEnabled;
bool _LightMapDynamicLightDirty; bool _LightMapDynamicLightDirty;
// this is the backup of standard lighting (cause GL states may be modified by Lightmap Dynamic Lighting) // this is the backup of standard lighting (cause GL states may be modified by Lightmap Dynamic Lighting)
CLight _UserLight0; CLight _UserLight0;
#ifdef GLSL
CLight _UserLight[MaxLight]; CLight _UserLight[MaxLight];
#endif
bool _UserLightEnable[MaxLight]; bool _UserLightEnable[MaxLight];
//\name description of the per pixel light //\name description of the per pixel light
@ -1016,30 +1000,19 @@ private:
// Force Activate Texture Environnement. no caching here. TexEnvSpecial is disabled. // Force Activate Texture Environnement. no caching here. TexEnvSpecial is disabled.
void forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &env); void forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &env);
void activateTexEnvColor(uint stage, NLMISC::CRGBA col); void activateTexEnvColor(uint stage, NLMISC::CRGBA col);
void forceActivateTexEnvColor(uint stage, NLMISC::CRGBA col) void forceActivateTexEnvColor(uint stage, NLMISC::CRGBA col)
{ {
static const float OO255= 1.0f/255; static const float OO255= 1.0f/255;
_CurrentTexEnv[stage].ConstantColor= col; _CurrentTexEnv[stage].ConstantColor= col;
#ifndef GLSL
// Setup the gl cte color.
_DriverGLStates.activeTextureARB(stage);
GLfloat glcol[4];
glcol[0]= col.R*OO255;
glcol[1]= col.G*OO255;
glcol[2]= col.B*OO255;
glcol[3]= col.A*OO255;
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glcol);
#endif
} }
void forceActivateTexEnvColor(uint stage, const CMaterial::CTexEnv &env) void forceActivateTexEnvColor(uint stage, const CMaterial::CTexEnv &env)
{ {
H_AUTO_OGL(CDriverGL3_forceActivateTexEnvColor) H_AUTO_OGL(CDriverGL3_forceActivateTexEnvColor)
forceActivateTexEnvColor(stage, env.ConstantColor); forceActivateTexEnvColor(stage, env.ConstantColor);
} }
// Called by doRefreshRenderSetup(). set _LightSetupDirty to false
void cleanLightSetup ();
// According to extensions, retrieve GL tex format of the texture. // According to extensions, retrieve GL tex format of the texture.
GLint getGlTextureFormat(ITexture& tex, bool &compressed); GLint getGlTextureFormat(ITexture& tex, bool &compressed);
@ -1193,18 +1166,6 @@ private:
} }
} }
// refresh matrixes and lights.
void refreshRenderSetup()
{
// check if something to change.
if(_RenderSetupDirty)
{
doRefreshRenderSetup();
}
}
void doRefreshRenderSetup();
void refreshTexMatrices();
void setLightInternal(uint8 num, const CLight& light); void setLightInternal(uint8 num, const CLight& light);
void enableLightInternal(uint8 num, bool enable); void enableLightInternal(uint8 num, bool enable);
void setupLightMapDynamicLighting(bool enable); void setupLightMapDynamicLighting(bool enable);
@ -1276,7 +1237,7 @@ private:
bool isVertexProgramSupported () const{ return true; } bool isVertexProgramSupported () const{ return true; }
bool isVertexProgramEmulated () const{ return false; } bool isVertexProgramEmulated () const{ return false; }
bool activeVertexProgram (CVertexProgram *program); bool activeVertexProgram (CVertexProgram *program){ return true; };
bool activeProgramObject( IProgramObject *program ); bool activeProgramObject( IProgramObject *program );
IProgramObject* createProgramObject() const; IProgramObject* createProgramObject() const;
IProgram* createVertexProgram() const; IProgram* createVertexProgram() const;
@ -1295,29 +1256,20 @@ private:
void setUniformMatrix3fv( uint index, uint count, bool transpose, const float *values ); void setUniformMatrix3fv( uint index, uint count, bool transpose, const float *values );
void setUniformMatrix4fv( uint index, uint count, bool transpose, const float *values ); void setUniformMatrix4fv( uint index, uint count, bool transpose, const float *values );
void setConstant (uint index, float, float, float, float); void setConstant (uint index, float, float, float, float){}
void setConstant (uint index, double, double, double, double); void setConstant (uint index, double, double, double, double){}
void setConstant (uint indexStart, const NLMISC::CVector& value); void setConstant (uint indexStart, const NLMISC::CVector& value){}
void setConstant (uint indexStart, const NLMISC::CVectorD& value); void setConstant (uint indexStart, const NLMISC::CVectorD& value){}
void setConstant (uint index, uint num, const float *src); void setConstant (uint index, uint num, const float *src){}
void setConstant (uint index, uint num, const double *src); void setConstant (uint index, uint num, const double *src){}
void setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver::TTransform transform); void setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver::TTransform transform){}
void setConstantFog (uint index); void setConstantFog (uint index){}
void enableVertexProgramDoubleSidedColor(bool doubleSided); void enableVertexProgramDoubleSidedColor(bool doubleSided);
bool supportVertexProgramDoubleSidedColor() const{ return true; }; bool supportVertexProgramDoubleSidedColor() const{ return true; };
virtual bool supportMADOperator() const ; virtual bool supportMADOperator() const ;
// @}
/// \name Vertex program implementation
// @{
bool activeARBVertexProgram (CVertexProgram *program);
//@}
/// \fallback for material shaders /// \fallback for material shaders
// @{ // @{
/// test whether the given shader is supported, and gives back a supported shader /// test whether the given shader is supported, and gives back a supported shader
@ -1326,15 +1278,9 @@ private:
bool isVertexProgramEnabled () const bool isVertexProgramEnabled () const
{ {
// Don't use glIsEnabled, too slow. return true;
return _VertexProgramEnabled;
} }
// Track state of activeVertexProgram()
bool _VertexProgramEnabled;
// Say if last setupGlArrays() was a VertexProgram setup.
bool _LastSetupGLArrayVertexProgram;
// The last vertex program that was setupped // The last vertex program that was setupped
NLMISC::CRefPtr<CVertexProgram> _LastSetuppedVP; NLMISC::CRefPtr<CVertexProgram> _LastSetuppedVP;
@ -1347,7 +1293,6 @@ private:
// user texture matrix // user texture matrix
NLMISC::CMatrix _UserTexMat[IDRV_MAT_MAXTEXTURES]; NLMISC::CMatrix _UserTexMat[IDRV_MAT_MAXTEXTURES];
bool _UserTexMatDirty[IDRV_MAT_MAXTEXTURES];
uint _UserTexMatEnabled; // bitm ask for user texture coords uint _UserTexMatEnabled; // bitm ask for user texture coords
// Static const // Static const
@ -1372,7 +1317,6 @@ private:
private: private:
#ifdef GLSL
CGLSLShaderGenerator *shaderGenerator; CGLSLShaderGenerator *shaderGenerator;
CUsrShaderManager *usrShaderManager; CUsrShaderManager *usrShaderManager;
@ -1381,9 +1325,6 @@ private:
/// The current user shader program /// The current user shader program
IProgramObject *dynMatProgram; IProgramObject *dynMatProgram;
#endif
bool setupARBVertexProgram (const CVPParser::TProgram &parsedProgram, GLuint id, bool &specularWritten);
// init EMBM settings (set each stage to modify the next) // init EMBM settings (set each stage to modify the next)
void initEMBM(); void initEMBM();
@ -1477,20 +1418,6 @@ public:
}; };
// ***************************************************************************
class CVertexProgamDrvInfosGL3 : public IVertexProgramDrvInfos
{
public:
// The GL Id.
GLuint ID;
// ARB_vertex_program specific -> must know if specular part is written
bool SpecularWritten;
// The gl id is auto created here.
CVertexProgamDrvInfosGL3 (CDriverGL3 *drv, ItVtxPrgDrvInfoPtrList it);
};
#ifdef NL_STATIC #ifdef NL_STATIC
} // NLDRIVERGL/ES } // NLDRIVERGL/ES
#endif #endif

@ -69,54 +69,7 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
// Copy the mode // Copy the mode
_LightMode[num]=mode; _LightMode[num]=mode;
#ifdef GLSL
_UserLight[num] = light; _UserLight[num] = light;
#endif
#ifndef GLSL
// Set the ambiant color
GLfloat colorGL[4];
CRGBA colorNeL=light.getAmbiant ();
colorGL[0]=(float)colorNeL.R/255.f;
colorGL[1]=(float)colorNeL.G/255.f;
colorGL[2]=(float)colorNeL.B/255.f;
colorGL[3]=1.f;
glLightfv (lightNum, GL_AMBIENT, colorGL);
// Set the diffuse color
colorNeL=light.getDiffuse ();
colorGL[0]=(float)colorNeL.R/255.f;
colorGL[1]=(float)colorNeL.G/255.f;
colorGL[2]=(float)colorNeL.B/255.f;
colorGL[3]=1.f;
glLightfv (lightNum, GL_DIFFUSE, colorGL);
// Set the specular color
colorNeL=light.getSpecular ();
// don't know why, but with ATI cards, specular of 0 causes incorrect rendering (random specular is added)
if (_Extensions.ATITextureEnvCombine3)
{
// special case for ATI (there will be some specular, but there's a bug otherwise)
colorGL[0]=std::max(1.f / 1024.f, (float)colorNeL.R/255.f);
colorGL[1]=std::max(1.f / 1024.f, (float)colorNeL.G/255.f);
colorGL[2]=std::max(1.f / 1024.f, (float)colorNeL.B/255.f);
colorGL[3]=1.f;
}
else
{
colorGL[0]=(float)colorNeL.R/255.f;
colorGL[1]=(float)colorNeL.G/255.f;
colorGL[2]=(float)colorNeL.B/255.f;
colorGL[3]=1.f;
}
glLightfv (lightNum, GL_SPECULAR, colorGL);
// Set light attenuation
glLightf (lightNum, GL_CONSTANT_ATTENUATION, light.getConstantAttenuation());
glLightf (lightNum, GL_LINEAR_ATTENUATION, light.getLinearAttenuation());
glLightf (lightNum, GL_QUADRATIC_ATTENUATION, light.getQuadraticAttenuation());
#endif
// Set the position // Set the position
if ((mode==CLight::DirectionalLight)||(mode==CLight::SpotLight)) if ((mode==CLight::DirectionalLight)||(mode==CLight::SpotLight))
@ -136,35 +89,11 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
// Get the exponent of the spot // Get the exponent of the spot
float exponent=light.getExponent (); float exponent=light.getExponent ();
#ifndef GLSL
// Set it
glLightf (lightNum, GL_SPOT_EXPONENT, exponent);
#endif
// Get the cutoff of the spot // Get the cutoff of the spot
float cutoff=180.f*(light.getCutoff ()/(float)NLMISC::Pi); float cutoff=180.f*(light.getCutoff ()/(float)NLMISC::Pi);
#ifndef GLSL
// Set it
glLightf (lightNum, GL_SPOT_CUTOFF, cutoff);
#endif
}
else
{
#ifndef GLSL
// Disable spot properties
glLighti (lightNum, GL_SPOT_CUTOFF, 180);
glLighti (lightNum, GL_SPOT_EXPONENT, 0);
#endif
} }
// Flag this light as dirt.
_LightDirty[num]= true;
// dirt the lightSetup and hence the render setup
_LightSetupDirty= true;
_RenderSetupDirty=true;
} }
} }
@ -198,12 +127,6 @@ void CDriverGL3::enableLightInternal(uint8 num, bool enable)
{ {
_DriverGLStates.enableLight(num, enable); _DriverGLStates.enableLight(num, enable);
// If this light is dirty, and reenabled, then it must be refresh at next render => set the global flag.
if (enable && _LightDirty[num])
{
_LightSetupDirty= true;
_RenderSetupDirty= true;
}
} }
} }
@ -214,112 +137,6 @@ void CDriverGL3::setAmbientColor (CRGBA color)
{ {
H_AUTO_OGL(CDriverGL3_setAmbientColor ) H_AUTO_OGL(CDriverGL3_setAmbientColor )
#ifndef GLSL
// Gl array
GLfloat array[4];
array[0]=(float)color.R/255.f;
array[1]=(float)color.G/255.f;
array[2]=(float)color.B/255.f;
array[3]=1.f;
// Set the color
glLightModelfv (GL_LIGHT_MODEL_AMBIENT, array);
#endif
}
// ***************************************************************************
void CDriverGL3::cleanLightSetup ()
{
H_AUTO_OGL(CDriverGL3_cleanLightSetup )
// Should be dirty
nlassert (_LightSetupDirty);
#ifndef GLSL
// First light
bool first=true;
// For each lights
for (uint i=0; i<_MaxDriverLight; i++)
{
// Is this light enabled and dirty?
if (_DriverGLStates.isLightEnabled(i) && _LightDirty[i])
{
// If first light
if (first)
{
first=false;
// Push the matrix
glPushMatrix ();
// Load the view matrix
glLoadMatrixf (_ViewMtx.get());
}
// Light is directionnal ?
if (_LightMode[i]==(uint)CLight::DirectionalLight)
{
// GL vector
GLfloat vectorGL[4];
// Set the GL array
vectorGL[0]=-_WorldLightDirection[i].x;
vectorGL[1]=-_WorldLightDirection[i].y;
vectorGL[2]=-_WorldLightDirection[i].z;
vectorGL[3]=0.f;
// Set it
glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_POSITION, vectorGL);
}
// Spotlight ?
if (_LightMode[i]==(uint)CLight::SpotLight)
{
// GL vector
GLfloat vectorGL[4];
// Set the GL array
vectorGL[0]=_WorldLightDirection[i].x;
vectorGL[1]=_WorldLightDirection[i].y;
vectorGL[2]=_WorldLightDirection[i].z;
// Set it
glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_SPOT_DIRECTION, vectorGL);
}
// Position
if (_LightMode[i]!=(uint)CLight::DirectionalLight)
{
// GL vector
GLfloat vectorGL[4];
// Set the GL array
// Must Substract CameraPos, because ViewMtx may not be the exact view.
vectorGL[0]=_WorldLightPos[i].x - _PZBCameraPos.x;
vectorGL[1]=_WorldLightPos[i].y - _PZBCameraPos.y;
vectorGL[2]=_WorldLightPos[i].z - _PZBCameraPos.z;
vectorGL[3]=1.f;
// Set it
glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_POSITION, vectorGL);
}
// Cleaned!
_LightDirty[i]= false;
}
}
// Pop old matrix
if (!first)
glPopMatrix ();
#endif
// Clean flag
_LightSetupDirty=false;
} }
@ -371,9 +188,6 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
for(uint i=0;i<_MaxDriverLight;i++) for(uint i=0;i<_MaxDriverLight;i++)
enableLightInternal(i, _UserLightEnable[i]); enableLightInternal(i, _UserLightEnable[i]);
} }
// in all case, must refresh render setup, cause lighting may be modified
refreshRenderSetup();
} }
#ifdef NL_STATIC #ifdef NL_STATIC

@ -176,7 +176,6 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
if (newMask & shiftMask) // user matrix for this stage if (newMask & shiftMask) // user matrix for this stage
{ {
_UserTexMat[ k ] = mat.getUserTexMat( k ); _UserTexMat[ k ] = mat.getUserTexMat( k );
_UserTexMatDirty[ k ] = true;
_UserTexMatEnabled |= shiftMask; _UserTexMatEnabled |= shiftMask;
} }
else else
@ -187,7 +186,6 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
) )
{ {
_UserTexMat[ k ].identity(); _UserTexMat[ k ].identity();
_UserTexMatDirty[ k ] = true;
_UserTexMatEnabled &= ~shiftMask; _UserTexMatEnabled &= ~shiftMask;
} }
} }
@ -207,7 +205,6 @@ void CDriverGL3::disableUserTextureMatrix()
if (_UserTexMatEnabled & (1 << k)) // user matrix for this stage if (_UserTexMatEnabled & (1 << k)) // user matrix for this stage
{ {
_UserTexMat[ k ].identity(); _UserTexMat[ k ].identity();
_UserTexMatDirty[ k ] = true;
_UserTexMatEnabled &= ~ (1 << k); _UserTexMatEnabled &= ~ (1 << k);
} }
++k; ++k;
@ -236,16 +233,12 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
{ {
H_AUTO_OGL(CDriverGL3_setupMaterial) H_AUTO_OGL(CDriverGL3_setupMaterial)
#ifdef GLSL
if( mat.getDynMat() != NULL ) if( mat.getDynMat() != NULL )
{ {
_CurrentMaterial = &mat; _CurrentMaterial = &mat;
return true; return true;
} }
#endif
CShaderGL3* pShader; CShaderGL3* pShader;
GLenum glenum = GL_ZERO; GLenum glenum = GL_ZERO;
uint32 touched = mat.getTouched(); uint32 touched = mat.getTouched();
@ -390,11 +383,6 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// activate the texture, or disable texturing if NULL. // activate the texture, or disable texturing if NULL.
activateTexture(stage,text); activateTexture(stage,text);
#ifndef GLSL
// If texture not NULL, Change texture env function.
//==================================================
setTextureEnvFunction(stage, mat);
#endif
} }
} }
@ -458,12 +446,6 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
} }
else else
{ {
#ifndef GLSL
// Color unlit part.
CRGBA col= mat.getColor();
glColor4ub(col.R, col.G, col.B, col.A);
#endif
_DriverGLStates.setVertexColorLighted(false); _DriverGLStates.setVertexColorLighted(false);
} }
@ -510,10 +492,8 @@ sint CDriverGL3::beginMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_beginMultiPass) H_AUTO_OGL(CDriverGL3_beginMultiPass)
#ifdef GLSL
if( _CurrentMaterial->getDynMat() != NULL ) if( _CurrentMaterial->getDynMat() != NULL )
return _CurrentMaterial->getDynMat()->getPassCount(); return _CurrentMaterial->getDynMat()->getPassCount();
#endif
// Depending on material type and hardware, return number of pass required to draw this material. // Depending on material type and hardware, return number of pass required to draw this material.
switch(_CurrentMaterialSupportedShader) switch(_CurrentMaterialSupportedShader)
@ -543,12 +523,9 @@ bool CDriverGL3::setupPass(uint pass)
{ {
H_AUTO_OGL(CDriverGL3_setupPass) H_AUTO_OGL(CDriverGL3_setupPass)
#ifdef GLSL
if( _CurrentMaterial->getDynMat() != NULL ) if( _CurrentMaterial->getDynMat() != NULL )
return setupDynMatPass( pass ); return setupDynMatPass( pass );
#endif
switch(_CurrentMaterialSupportedShader) switch(_CurrentMaterialSupportedShader)
{ {
case CMaterial::Normal: case CMaterial::Normal:
@ -585,10 +562,8 @@ void CDriverGL3::endMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_endMultiPass) H_AUTO_OGL(CDriverGL3_endMultiPass)
#ifdef GLSL
if( _CurrentMaterial->getDynMat() != NULL ) if( _CurrentMaterial->getDynMat() != NULL )
return; return;
#endif
switch(_CurrentMaterialSupportedShader) switch(_CurrentMaterialSupportedShader)
{ {
@ -620,7 +595,6 @@ void CDriverGL3::endMultiPass()
bool CDriverGL3::setupDynMatPass( uint pass ) bool CDriverGL3::setupDynMatPass( uint pass )
{ {
#ifdef GLSL
if( !setupDynMatProgram( *_CurrentMaterial, pass ) ) if( !setupDynMatProgram( *_CurrentMaterial, pass ) )
return false; return false;
@ -705,7 +679,6 @@ bool CDriverGL3::setupDynMatPass( uint pass )
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
return true; return true;
} }
@ -913,7 +886,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
// setup constant color with Lightmap factor. // setup constant color with Lightmap factor.
stdEnv.ConstantColor=lmapFactor; stdEnv.ConstantColor=lmapFactor;
#ifdef GLSL
int cl = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Constant0 + stage ) ); int cl = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Constant0 + stage ) );
if( cl != -1 ) if( cl != -1 )
{ {
@ -927,7 +900,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
{ {
setUniform1i( tl, stage ); setUniform1i( tl, stage );
} }
#endif
activateTexEnvColor(stage, stdEnv); activateTexEnvColor(stage, stdEnv);
// Setup env for texture stage. // Setup env for texture stage.
@ -939,26 +912,6 @@ void CDriverGL3::setupLightMapPass(uint pass)
{ {
// TexEnv is special. // TexEnv is special.
_CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap; _CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap;
#ifndef GLSL
{
// ATI EnvCombine3
// What we want to setup is Texture*Constant + Previous.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
// Operator.
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATI);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
}
#endif
} }
} }
@ -990,13 +943,11 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
_DriverGLStates.setTexGenMode(stage, 0); _DriverGLStates.setTexGenMode(stage, 0);
#ifdef GLSL
int tl = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Sampler0 + stage ) ); int tl = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Sampler0 + stage ) );
if( tl != -1 ) if( tl != -1 )
{ {
setUniform1i( tl, stage ); setUniform1i( tl, stage );
} }
#endif
// setup UV, with UV0. Only if needed (cached) // setup UV, with UV0. Only if needed (cached)
if( !_LastVertexSetupIsLightMap || _LightMapUVMap[stage]!=0 ) if( !_LastVertexSetupIsLightMap || _LightMapUVMap[stage]!=0 )
@ -1005,14 +956,6 @@ void CDriverGL3::setupLightMapPass(uint pass)
_LightMapUVMap[stage]= 0; _LightMapUVMap[stage]= 0;
} }
#ifndef GLSL
if (mat._LightMapsMulx2)
{
// Multiply x 2
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
}
#endif
} }
} }
else else
@ -1028,13 +971,6 @@ void CDriverGL3::setupLightMapPass(uint pass)
/* If multi-pass, then must setup a black Fog color for 1+ pass (just do it for the pass 1). /* If multi-pass, then must setup a black Fog color for 1+ pass (just do it for the pass 1).
This is because Transparency ONE/ONE is used. This is because Transparency ONE/ONE is used.
*/ */
#ifndef GLSL
if(pass==1 && _FogEnabled)
{
static GLfloat blackFog[4]= {0,0,0,0};
glFogfv(GL_FOG_COLOR, blackFog);
}
#endif
// Blend is different if the material is blended or not // Blend is different if the material is blended or not
if( !mat.getBlend() ) if( !mat.getBlend() )
@ -1106,29 +1042,10 @@ void CDriverGL3::endLightMapMultiPass()
if(_NLightMaps!=0) if(_NLightMaps!=0)
_LastVertexSetupIsLightMap= true; _LastVertexSetupIsLightMap= true;
// If multi-pass, then must reset the fog color
if(_NLightMapPass>=2 && _FogEnabled)
{
#ifndef GLSL
glFogfv(GL_FOG_COLOR, _CurrentFogColor);
#endif
}
// nothing to do with blending/lighting, since always setuped in activeMaterial(). // nothing to do with blending/lighting, since always setuped in activeMaterial().
// If material is the same, then it is still a lightmap material (if changed => touched => different!) // If material is the same, then it is still a lightmap material (if changed => touched => different!)
// So no need to reset blending/lighting here. // So no need to reset blending/lighting here.
// Clean up all stage for Multiply x 2
if (_CurrentMaterial->_LightMapsMulx2)
{
#ifndef GLSL
for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i)
{
_DriverGLStates.activeTextureARB(i);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
}
#endif
}
} }
// *************************************************************************** // ***************************************************************************
@ -1198,15 +1115,8 @@ void CDriverGL3::setupSpecularBegin()
// For all cases, setup the TexCoord gen for stage1 // For all cases, setup the TexCoord gen for stage1
_DriverGLStates.activeTextureARB(1); _DriverGLStates.activeTextureARB(1);
#ifndef GLSL
// todo hulud remove
// _DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap);
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
#endif
// setup the good matrix for stage 1. // setup the good matrix for stage 1.
_UserTexMat[ 1 ] = _SpecularTexMtx; _UserTexMat[ 1 ] = _SpecularTexMtx;
_UserTexMatDirty[ 1 ] = true;
} }
@ -1220,7 +1130,6 @@ void CDriverGL3::setupSpecularEnd()
// Happiness !!! we have already enabled the stage 1 // Happiness !!! we have already enabled the stage 1
_UserTexMat[ 1 ].identity(); _UserTexMat[ 1 ].identity();
_UserTexMatDirty[ 1 ] = true;
} }
// *************************************************************************** // ***************************************************************************
@ -1268,8 +1177,6 @@ void CDriverGL3::setupSpecularPass(uint pass)
return; return;
} }
#ifdef GLSL
int sl0 = currentProgram->getUniformIndex( IProgramObject::Sampler0 ); int sl0 = currentProgram->getUniformIndex( IProgramObject::Sampler0 );
if( sl0 != -1 ) if( sl0 != -1 )
{ {
@ -1288,8 +1195,6 @@ void CDriverGL3::setupSpecularPass(uint pass)
setUniformMatrix4fv( tml, 1, false, _UserTexMat[ 1 ].get() ); setUniformMatrix4fv( tml, 1, false, _UserTexMat[ 1 ].get() );
} }
#endif
{ {
// Ok we can do it in a single pass // Ok we can do it in a single pass
@ -1308,42 +1213,6 @@ void CDriverGL3::setupSpecularPass(uint pass)
_DriverGLStates.activeTextureARB(1); _DriverGLStates.activeTextureARB(1);
#ifndef GLSL
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
// Operator Add (Arg0*Arg2+Arg1)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI );
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATI );
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
// Arg2.
if( newEnvStage1 == TexEnvSpecialSpecularStage1NoText )
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
}
else
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA );
}
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR );
// Result : Texture*Previous.Alpha+Previous
// Setup Alpha Diffuse Copy
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA );
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
#endif
} }
} }
} }

@ -33,7 +33,6 @@ void CDriverGL3::setFrustum(float left, float right, float bottom, float top, fl
else else
_GLProjMat.ortho( left, right, bottom, top, znear, zfar ); _GLProjMat.ortho( left, right, bottom, top, znear, zfar );
_ProjMatDirty = true;
_OODeltaZ = 1 / ( zfar - znear ); _OODeltaZ = 1 / ( zfar - znear );
} }
@ -45,8 +44,6 @@ void CDriverGL3::setFrustumMatrix(CMatrix &frustumMatrix)
H_AUTO_OGL(CDriverGL3_setFrustum) H_AUTO_OGL(CDriverGL3_setFrustum)
_GLProjMat = frustumMatrix; _GLProjMat = frustumMatrix;
_ProjMatDirty = true;
} }
// *************************************************************************** // ***************************************************************************
@ -77,14 +74,6 @@ void CDriverGL3::setupViewMatrixEx(const CMatrix& mtx, const CVector &cameraPos)
_ViewMtx.setPos(CVector::Null); _ViewMtx.setPos(CVector::Null);
_PZBCameraPos= cameraPos; _PZBCameraPos= cameraPos;
// Anything that depend on the view martix must be updated.
_LightSetupDirty= true;
_ModelViewMatrixDirty= true;
_RenderSetupDirty= true;
// All lights must be refresh.
for(uint i=0;i<MaxLight;i++)
_LightDirty[i]= true;
_SpecularTexMtx = _ViewMtx; _SpecularTexMtx = _ViewMtx;
_SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f)); _SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
_SpecularTexMtx.invert(); _SpecularTexMtx.invert();
@ -110,14 +99,6 @@ void CDriverGL3::setupViewMatrix(const CMatrix& mtx)
// Just set the PZBCameraPos to 0. // Just set the PZBCameraPos to 0.
_PZBCameraPos= CVector::Null; _PZBCameraPos= CVector::Null;
// Anything that depend on the view martix must be updated.
_LightSetupDirty= true;
_ModelViewMatrixDirty= true;
_RenderSetupDirty= true;
// All lights must be refresh.
for(uint i=0;i<MaxLight;i++)
_LightDirty[i]= true;
_SpecularTexMtx = _ViewMtx; _SpecularTexMtx = _ViewMtx;
_SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f)); _SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
_SpecularTexMtx.invert(); _SpecularTexMtx.invert();
@ -139,12 +120,6 @@ void CDriverGL3::setupModelMatrix(const CMatrix& mtx)
// profiling // profiling
_NbSetupModelMatrixCall++; _NbSetupModelMatrixCall++;
// Dirt flags.
_ModelViewMatrixDirty= true;
_RenderSetupDirty= true;
// Put the matrix in the opengl eye space, and store it. // Put the matrix in the opengl eye space, and store it.
CMatrix mat= mtx; CMatrix mat= mtx;
// remove first the _PZBCameraPos // remove first the _PZBCameraPos
@ -152,63 +127,6 @@ void CDriverGL3::setupModelMatrix(const CMatrix& mtx)
_ModelViewMatrix= _ViewMtx*mat; _ModelViewMatrix= _ViewMtx*mat;
} }
// ***************************************************************************
void CDriverGL3::doRefreshRenderSetup()
{
H_AUTO_OGL(CDriverGL3_doRefreshRenderSetup)
// Check if the light setup has been modified first
if (_LightSetupDirty)
// Recompute light setup
cleanLightSetup ();
// Check light setup is good
nlassert (_LightSetupDirty==false);
if( _ProjMatDirty )
{
#ifndef GLSL
glMatrixMode( GL_PROJECTION );
glLoadMatrixf( _GLProjMat.get() );
glMatrixMode( GL_MODELVIEW );
#endif
_ProjMatDirty = false;
}
// Check if must update the modelViewMatrix
if( _ModelViewMatrixDirty )
{
#ifndef GLSL
// By default, the first model matrix is active
glLoadMatrixf( _ModelViewMatrix.get() );
// enable normalize if matrix has scale.
enableGlNormalize( _ModelViewMatrix.hasScalePart() || _ForceNormalize );
// clear.
#endif
_ModelViewMatrixDirty= false;
}
// render setup is cleaned.
_RenderSetupDirty= false;
}
void CDriverGL3::refreshTexMatrices()
{
#ifndef GLSL
glMatrixMode( GL_TEXTURE );
for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
{
if( _UserTexMatDirty[ i ] )
{
_DriverGLStates.activeTextureARB( i );
glLoadMatrixf( _UserTexMat[ i ].get() );
_UserTexMatDirty[ i ] = false;
}
}
glMatrixMode( GL_MODELVIEW );
#endif
}
#ifdef NL_STATIC #ifdef NL_STATIC
} // NLDRIVERGL/ES } // NLDRIVERGL/ES
#endif #endif

@ -44,9 +44,6 @@ namespace NL3D
{ {
if( !program ) if( !program )
{ {
#ifndef GLSL
_VertexProgramEnabled = false;
#endif
currentProgram = NULL; currentProgram = NULL;
return true; return true;
} }
@ -60,7 +57,6 @@ namespace NL3D
if( error != GL_NO_ERROR ) if( error != GL_NO_ERROR )
return false; return false;
_VertexProgramEnabled = true;
currentProgram = program; currentProgram = program;
return true; return true;
@ -354,9 +350,6 @@ namespace NL3D
void CDriverGL3::setupUniforms( CMaterial& mat ) void CDriverGL3::setupUniforms( CMaterial& mat )
{ {
#ifdef GLSL
int mvpIndex = currentProgram->getUniformIndex( IProgramObject::MVPMatrix ); int mvpIndex = currentProgram->getUniformIndex( IProgramObject::MVPMatrix );
if( mvpIndex != -1 ) if( mvpIndex != -1 )
{ {
@ -542,7 +535,6 @@ namespace NL3D
} }
#endif
} }
} }

@ -120,11 +120,6 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
glStencilFunc(_CurStencilFunc, _CurStencilRef, _CurStencilMask); glStencilFunc(_CurStencilFunc, _CurStencilRef, _CurStencilMask);
glStencilOp(_CurStencilOpFail, _CurStencilOpZFail, _CurStencilOpZPass); glStencilOp(_CurStencilOpFail, _CurStencilOpZFail, _CurStencilOpZPass);
glStencilMask(_CurStencilWriteMask); glStencilMask(_CurStencilWriteMask);
#ifndef GLSL
glAlphaFunc(GL_GREATER, _CurAlphaTestThreshold);
#endif
// Materials. // Materials.
uint32 packedOne= (CRGBA(255,255,255,255)).getPacked(); uint32 packedOne= (CRGBA(255,255,255,255)).getPacked();
@ -142,13 +137,6 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
// setup GLStates. // setup GLStates.
static const GLfloat one[4]= {1,1,1,1}; static const GLfloat one[4]= {1,1,1,1};
static const GLfloat zero[4]= {0,0,0,1}; static const GLfloat zero[4]= {0,0,0,1};
#ifndef GLSL
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, zero);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, one);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, one);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, _CurShininess);
#endif
// TexModes // TexModes
uint stage; uint stage;
@ -298,13 +286,6 @@ void CDriverGLStates3::enableLight(uint num, uint enable)
{ {
// new state. // new state.
_CurLight[num]= enabled; _CurLight[num]= enabled;
// Setup GLState.
#ifndef GLSL
if(_CurLight[num])
glEnable ((GLenum)(GL_LIGHT0+num));
else
glDisable ((GLenum)(GL_LIGHT0+num));
#endif
} }
} }
@ -425,10 +406,6 @@ void CDriverGLStates3::alphaFunc(float threshold)
{ {
// new state // new state
_CurAlphaTestThreshold= threshold; _CurAlphaTestThreshold= threshold;
// setup function.
#ifndef GLSL
glAlphaFunc(GL_GREATER, _CurAlphaTestThreshold);
#endif
} }
} }
@ -496,9 +473,6 @@ void CDriverGLStates3::setEmissive(uint32 packedColor, const GLfloat color[4])
#endif #endif
{ {
_CurEmissive= packedColor; _CurEmissive= packedColor;
#ifndef GLSL
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
#endif
} }
} }
@ -511,9 +485,6 @@ void CDriverGLStates3::setAmbient(uint32 packedColor, const GLfloat color[4])
#endif #endif
{ {
_CurAmbient= packedColor; _CurAmbient= packedColor;
#ifndef GLSL
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
#endif
} }
} }
@ -526,9 +497,6 @@ void CDriverGLStates3::setDiffuse(uint32 packedColor, const GLfloat color[4])
#endif #endif
{ {
_CurDiffuse= packedColor; _CurDiffuse= packedColor;
#ifndef GLSL
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
#endif
} }
} }
@ -541,9 +509,6 @@ void CDriverGLStates3::setSpecular(uint32 packedColor, const GLfloat color[4])
#endif #endif
{ {
_CurSpecular= packedColor; _CurSpecular= packedColor;
#ifndef GLSL
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
#endif
} }
} }
@ -556,9 +521,6 @@ void CDriverGLStates3::setShininess(float shin)
#endif #endif
{ {
_CurShininess= shin; _CurShininess= shin;
#ifndef GLSL
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shin);
#endif
} }
} }
@ -583,29 +545,6 @@ void CDriverGLStates3::setVertexColorLighted(bool enable)
#endif #endif
{ {
_VertexColorLighted= enable; _VertexColorLighted= enable;
#ifndef GLSL
if (_VertexColorLighted)
{
glEnable (GL_COLOR_MATERIAL);
glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
}
else
{
glDisable (GL_COLOR_MATERIAL);
// Since we leave glColorMaterial mode, GL diffuse is now scracth. reset him to current value.
CRGBA diffCol;
diffCol.R= (uint8)((_CurDiffuse >> 24) & 255);
diffCol.G= (uint8)((_CurDiffuse >> 16) & 255);
diffCol.B= (uint8)((_CurDiffuse >> 8) & 255);
diffCol.A= (uint8)((_CurDiffuse ) & 255);
GLfloat glColor[4];
convColor(diffCol, glColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, glColor);
}
#endif
} }
} }
@ -660,48 +599,6 @@ void CDriverGLStates3::setTexGenMode (uint stage, GLint mode)
#endif #endif
{ {
_TexGenMode[stage] = mode; _TexGenMode[stage] = mode;
#ifndef GLSL
if (!_TextureCubeMapSupported) return;
if(mode==0)
{
glDisable( GL_TEXTURE_GEN_S );
glDisable( GL_TEXTURE_GEN_T );
glDisable( GL_TEXTURE_GEN_R );
glDisable( GL_TEXTURE_GEN_Q );
}
else
{
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode);
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode);
glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, mode);
/* Object or Eye Space ? => enable W generation. VERY IMPORTANT because
was a bug with VegetableRender and ShadowRender:
- Vegetable use the TexCoord1.w in his VertexProgram
- Shadow Render don't use any TexCoord in VB (since projected)
=> TexCoord1.w dirty!!
*/
if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR)
{
glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, mode);
glEnable( GL_TEXTURE_GEN_Q );
}
else
{
glDisable( GL_TEXTURE_GEN_Q );
}
// Enable All.
glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T );
glEnable( GL_TEXTURE_GEN_R );
}
#endif
} }
} }
@ -710,22 +607,6 @@ void CDriverGLStates3::resetTextureMode()
{ {
H_AUTO_OGL(CDriverGLStates3_resetTextureMode); H_AUTO_OGL(CDriverGLStates3_resetTextureMode);
#ifndef GLSL
glDisable(GL_TEXTURE_2D);
if (_TextureCubeMapSupported)
{
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
}
if (_TextureRectangleSupported)
{
glDisable(GL_TEXTURE_RECTANGLE_NV);
}
#endif
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled; _TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
} }
@ -738,66 +619,6 @@ void CDriverGLStates3::setTextureMode(TTextureMode texMode)
if(oldTexMode != texMode) if(oldTexMode != texMode)
{ {
#ifndef GLSL
// Disable first old mode.
if (oldTexMode == Texture2D)
{
glDisable(GL_TEXTURE_2D);
}
else if(oldTexMode == TextureRect)
{
if(_TextureRectangleSupported)
{
glDisable(GL_TEXTURE_RECTANGLE_NV);
}
else
{
glDisable(GL_TEXTURE_2D);
}
}
else if(oldTexMode == TextureCubeMap)
{
if(_TextureCubeMapSupported)
{
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
}
else
{
glDisable(GL_TEXTURE_2D);
}
}
// Enable new mode.
if(texMode == Texture2D)
{
glEnable(GL_TEXTURE_2D);
}
else if(texMode == TextureRect)
{
if(_TextureRectangleSupported)
{
glEnable(GL_TEXTURE_RECTANGLE_NV);
}
else
{
glEnable(GL_TEXTURE_2D);
}
}
else if(texMode == TextureCubeMap)
{
if(_TextureCubeMapSupported)
{
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
}
else
{
glEnable(GL_TEXTURE_2D);
}
}
#endif
// new mode. // new mode.
_TextureMode[_CurrentActiveTextureARB]= texMode; _TextureMode[_CurrentActiveTextureARB]= texMode;
} }
@ -830,158 +651,43 @@ void CDriverGLStates3::forceActiveTextureARB(uint stage)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableVertexArray(bool enable) void CDriverGLStates3::enableVertexArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableVertexArray);
if(_VertexArrayEnabled != enable)
{
if(enable)
glEnableClientState(GL_VERTEX_ARRAY);
else
glDisableClientState(GL_VERTEX_ARRAY);
_VertexArrayEnabled= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableNormalArray(bool enable) void CDriverGLStates3::enableNormalArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableNormalArray)
if(_NormalArrayEnabled != enable)
{
if(enable)
glEnableClientState(GL_NORMAL_ARRAY);
else
glDisableClientState(GL_NORMAL_ARRAY);
_NormalArrayEnabled= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableWeightArray(bool enable) void CDriverGLStates3::enableWeightArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableWeightArray);
if(_WeightArrayEnabled != enable)
{
if(enable)
glEnableClientState(GL_VERTEX_WEIGHTING_EXT);
else
glDisableClientState(GL_VERTEX_WEIGHTING_EXT);
_WeightArrayEnabled= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableColorArray(bool enable) void CDriverGLStates3::enableColorArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableColorArray);
if(_ColorArrayEnabled != enable)
{
if(enable)
glEnableClientState(GL_COLOR_ARRAY);
else
glDisableClientState(GL_COLOR_ARRAY);
_ColorArrayEnabled= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableSecondaryColorArray(bool enable) void CDriverGLStates3::enableSecondaryColorArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableSecondaryColorArray);
if(_SecondaryColorArrayEnabled != enable)
{
if(enable)
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
else
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
_SecondaryColorArrayEnabled= enable;
// If disable
if(!enable)
{
// GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs
nglSecondaryColor3ubEXT(0,0,0);
}
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::clientActiveTextureARB(uint stage) void CDriverGLStates3::clientActiveTextureARB(uint stage)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_clientActiveTextureARB);
if( _CurrentClientActiveTextureARB != stage )
{
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
_CurrentClientActiveTextureARB= stage;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableTexCoordArray(bool enable) void CDriverGLStates3::enableTexCoordArray(bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableTexCoordArray);
if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable)
{
if(enable)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
_TexCoordArrayEnabled[_CurrentClientActiveTextureARB]= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates3::enableVertexAttribArray(uint glIndex, bool enable) void CDriverGLStates3::enableVertexAttribArray(uint glIndex, bool enable)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGLStates3_enableVertexAttribArray);
if(_VertexAttribArrayEnabled[glIndex] != enable)
{
if(enable)
glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
else
glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
_VertexAttribArrayEnabled[glIndex]= enable;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -1014,13 +720,6 @@ void CDriverGLStates3::enableFog(uint enable)
{ {
// new state. // new state.
_CurFog= enabled; _CurFog= enabled;
#ifndef GLSL
// Setup GLState.
if(_CurFog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
#endif
} }
} }

@ -1442,129 +1442,6 @@ void CDriverGL3::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv
_CurrentTexEnv[stage].EnvPacked= env.EnvPacked; _CurrentTexEnv[stage].EnvPacked= env.EnvPacked;
// Disable Special tex env f(). // Disable Special tex env f().
_CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled; _CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled;
#ifndef GLSL
// Setup the gl env mode.
_DriverGLStates.activeTextureARB(stage);
// if the Mad operator is used, then
// "Normal drivers", setup EnvCombine.
if(_Extensions.EXTTextureEnvCombine)
{
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
// RGB.
//=====
if (env.Env.OpRGB == CMaterial::Mad)
{
//
if (_Extensions.ATITextureEnvCombine3)
{
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, OperandLUT[env.Env.OpArg1RGB]);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, SourceLUT[env.Env.SrcArg2RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, OperandLUT[env.Env.OpArg2RGB]);
}
else
{
// fallback to modulate ..
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
//
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, OperandLUT[env.Env.OpArg1RGB]);
}
}
else
{
// Operator.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, OperatorLUT[env.Env.OpRGB] );
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
if(env.Env.OpRGB > CMaterial::Replace)
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, OperandLUT[env.Env.OpArg1RGB]);
// Arg2.
if(env.Env.OpRGB >= CMaterial::InterpolateTexture )
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, InterpolateSrcLUT[env.Env.OpRGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
}
}
}
// Alpha.
//=====
if (env.Env.OpAlpha == CMaterial::Mad)
{
if (_Extensions.ATITextureEnvCombine3)
{
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, SourceLUT[env.Env.SrcArg0Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, OperandLUT[env.Env.OpArg0Alpha]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, SourceLUT[env.Env.SrcArg1Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, OperandLUT[env.Env.OpArg1Alpha]);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, SourceLUT[env.Env.SrcArg2Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, OperandLUT[env.Env.OpArg2Alpha]);
}
else
{
// fallback to modulate ..
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE);
//
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, OperandLUT[env.Env.OpArg1RGB]);
}
}
else
{
// Operator.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, OperatorLUT[env.Env.OpAlpha] );
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, SourceLUT[env.Env.SrcArg0Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, OperandLUT[env.Env.OpArg0Alpha]);
// Arg1.
if(env.Env.OpAlpha > CMaterial::Replace)
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, SourceLUT[env.Env.SrcArg1Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, OperandLUT[env.Env.OpArg1Alpha]);
// Arg2.
if(env.Env.OpAlpha >= CMaterial::InterpolateTexture )
{
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, InterpolateSrcLUT[env.Env.OpAlpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
}
}
}
}
}
// Very Bad drivers.
else
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
#endif
} }
// *************************************************************************** // ***************************************************************************

@ -207,17 +207,13 @@ bool CDriverGL3::activeIndexBuffer(CIndexBuffer& IB)
bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines) bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
{ {
H_AUTO_OGL(CDriverGL3_renderLines) H_AUTO_OGL(CDriverGL3_renderLines)
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL ) if ( !setupMaterial(mat) || _LastIB._Values == NULL )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
// render primitives. // render primitives.
@ -232,8 +228,6 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
// draw the primitives. // draw the primitives.
if(nlines) if(nlines)
{ {
@ -264,19 +258,12 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
{ {
H_AUTO_OGL(CDriverGL3_renderTriangles); H_AUTO_OGL(CDriverGL3_renderTriangles);
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL ) if ( !setupMaterial(mat) || _LastIB._Values == NULL )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
refreshTexMatrices();
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -294,8 +281,6 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
// draw the primitives. // draw the primitives.
if(ntris) if(ntris)
{ {
@ -329,9 +314,6 @@ bool CDriverGL3::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
nlassert(ntris>0); nlassert(ntris>0);
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
// Don't setup any material here. // Don't setup any material here.
@ -362,17 +344,13 @@ bool CDriverGL3::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPoints) bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPoints)
{ {
H_AUTO_OGL(CDriverGL3_renderRawPoints) H_AUTO_OGL(CDriverGL3_renderRawPoints)
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) ) if ( !setupMaterial(mat) )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
// render primitives. // render primitives.
@ -387,8 +365,6 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
// draw the primitives. // draw the primitives.
if(numPoints) if(numPoints)
glDrawArrays(GL_POINTS, startIndex, numPoints); glDrawArrays(GL_POINTS, startIndex, numPoints);
@ -409,17 +385,13 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLines) bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLines)
{ {
H_AUTO_OGL(CDriverGL3_renderRawLines) H_AUTO_OGL(CDriverGL3_renderRawLines)
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) ) if ( !setupMaterial(mat) )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
// render primitives. // render primitives.
@ -434,8 +406,6 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
// draw the primitives. // draw the primitives.
if(numLines) if(numLines)
glDrawArrays(GL_LINES, startIndex << 1, numLines << 1); glDrawArrays(GL_LINES, startIndex << 1, numLines << 1);
@ -456,17 +426,13 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 numTris) bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 numTris)
{ {
H_AUTO_OGL(CDriverGL3_renderRawTriangles) H_AUTO_OGL(CDriverGL3_renderRawTriangles)
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) ) if ( !setupMaterial(mat) )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
// render primitives. // render primitives.
@ -481,8 +447,6 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
// draw the primitives. // draw the primitives.
if(numTris) if(numTris)
{ {
@ -506,17 +470,13 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
{ {
H_AUTO_OGL(CDriverGL3_renderRawQuads) H_AUTO_OGL(CDriverGL3_renderRawQuads)
if (!numQuads) return true; if (!numQuads) return true;
// update matrix and Light in OpenGL if needed
refreshRenderSetup();
// setup material // setup material
if ( !setupMaterial(mat) ) if ( !setupMaterial(mat) )
return false; return false;
#ifdef GLSL
if( !setupProgram( mat ) ) if( !setupProgram( mat ) )
return false; return false;
#endif
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -553,8 +513,6 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
if( !setupPass(pass) ) if( !setupPass(pass) )
return false; return false;
refreshTexMatrices();
uint32 currIndex = startIndex; uint32 currIndex = startIndex;
uint32 numLeftQuads = numQuads; uint32 numLeftQuads = numQuads;
@ -633,37 +591,6 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
void CDriverGL3::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId) void CDriverGL3::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGL3_setupUVPtr)
// sould not be called with vertex program Array setuped.
nlassert(!_LastSetupGLArrayVertexProgram);
_DriverGLStates.clientActiveTextureARB(stage);
if (VB.VertexFormat & (CVertexBuffer::TexCoord0Flag<<uvId))
{
// Check type, if not supported, just ignore
CVertexBuffer::TType uvType = VB.Type[CVertexBuffer::TexCoord0+uvId];
if (uvType == CVertexBuffer::Float2 ||
uvType == CVertexBuffer::Float3)
{
_DriverGLStates.enableTexCoordArray(true);
uint numTexCoord = (uvType == CVertexBuffer::Float2) ? 2 : 3;
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
// with arb buffers, position is relative to the start of the stream
glTexCoordPointer(numTexCoord,GL_FLOAT,VB.VertexSize, VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
}
else
{
_DriverGLStates.enableTexCoordArray(false);
}
}
else
_DriverGLStates.enableTexCoordArray(false);
#endif
} }
@ -835,66 +762,6 @@ const uint CDriverGL3::GLVertexAttribIndex[CVertexBuffer::NumValue]=
// *************************************************************************** // ***************************************************************************
void CDriverGL3::setupGlArraysStd(CVertexBufferInfo &vb) void CDriverGL3::setupGlArraysStd(CVertexBufferInfo &vb)
{ {
#ifndef GLSL
H_AUTO_OGL(CDriverGL3_setupGlArraysStd)
uint32 flags= vb.VertexFormat;
_DriverGLStates.bindARBVertexBuffer(vb.VertexObjectId);
{
{
// setup vertex ptr.
//-----------
uint numVertexCoord = CVertexBuffer::NumComponentsType[vb.Type[CVertexBuffer::Position]];
nlassert (numVertexCoord >= 2);
_DriverGLStates.enableVertexArray(true);
glVertexPointer(numVertexCoord, GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Position]);
// setup normal ptr.
//-----------
// Check for normal param in vertex buffer
if (flags & CVertexBuffer::NormalFlag)
{
// Check type
nlassert (vb.Type[CVertexBuffer::Normal]==CVertexBuffer::Float3);
_DriverGLStates.enableNormalArray(true);
glNormalPointer(GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
}
else
{
_DriverGLStates.enableNormalArray(false);
}
// Setup Color
//-----------
// Check for color param in vertex buffer
if (flags & CVertexBuffer::PrimaryColorFlag)
{
// Check type
nlassert (vb.Type[CVertexBuffer::PrimaryColor]==CVertexBuffer::UChar4);
_DriverGLStates.enableColorArray(true);
// Setup ATI VBHard or std ptr.
glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[CVertexBuffer::PrimaryColor]);
}
else
{
_DriverGLStates.enableColorArray(false);
}
}
}
// Setup Uvs
//-----------
// Get the routing
for(uint i=0; i<inlGetNumTextStages(); i++)
{
// normal behavior: each texture has its own UV.
setupUVPtr(i, vb, vb.UVRouting[i]);
}
#endif
} }
@ -905,70 +772,6 @@ void CDriverGL3::toggleGlArraysForARBVertexProgram()
// If change of setup type, must disable olds. // If change of setup type, must disable olds.
//======================= //=======================
#ifndef GLSL
// If last was a VertexProgram setup, and now it is a standard GL array setup.
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
{
if (_Extensions.ATITextureEnvCombine3)
{
// fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render
// (seems to be a driver bug)
ITexture *oldTex[IDRV_MAT_MAXTEXTURES];
for(uint stage=0 ; stage < inlGetNumTextStages() ; stage++)
{
oldTex[stage] = _CurrentTexture[stage];
// activate the texture, or disable texturing if NULL.
activateTexture(stage, NULL);
}
glBegin(GL_QUADS);
glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f);
glEnd();
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
{
// activate the texture, or disable texturing if NULL.
activateTexture(stage, oldTex[stage]);
}
}
// Disable all VertexAttribs.
for (uint value=0; value<CVertexBuffer::NumValue; value++)
{
// Index
uint glIndex=GLVertexAttribIndex[value];
_DriverGLStates.enableVertexAttribArrayARB(glIndex, false);
}
// no more a vertex program setup.
_LastSetupGLArrayVertexProgram= false;
}
// If last was a standard GL array setup, and now it is a VertexProgram setup.
if( !_LastSetupGLArrayVertexProgram && isVertexProgramEnabled () )
{
// Disable all standards ptrs.
_DriverGLStates.enableVertexArray(false);
_DriverGLStates.enableNormalArray(false);
_DriverGLStates.enableColorArray(false);
_DriverGLStates.enableSecondaryColorArray(false);
for(uint i=0; i<inlGetNumTextStages(); i++)
{
_DriverGLStates.clientActiveTextureARB(i);
_DriverGLStates.enableTexCoordArray(false);
}
// now, vertex program setup.
_LastSetupGLArrayVertexProgram= true;
}
#endif
} }
// tells for each vertex argument if it must be normalized when it is an integral type // tells for each vertex argument if it must be normalized when it is an integral type
@ -1040,21 +843,7 @@ void CDriverGL3::setupGlArrays(CVertexBufferInfo &vb)
{ {
H_AUTO_OGL(CDriverGL3_setupGlArrays) H_AUTO_OGL(CDriverGL3_setupGlArrays)
#ifndef GLSL
toggleGlArraysForARBVertexProgram();
// Use a vertex program ?
if (!isVertexProgramEnabled ())
{
setupGlArraysStd(vb);
}
else
{
#endif
setupGlArraysForARBVertexProgram(vb); setupGlArraysForARBVertexProgram(vb);
#ifndef GLSL
}
#endif
} }

@ -36,542 +36,6 @@ namespace NL3D {
namespace NLDRIVERGL3 { namespace NLDRIVERGL3 {
#endif #endif
// ***************************************************************************
CVertexProgamDrvInfosGL3::CVertexProgamDrvInfosGL3 (CDriverGL3 *drv, ItVtxPrgDrvInfoPtrList it) : IVertexProgramDrvInfos (drv, it)
{
H_AUTO_OGL(CVertexProgamDrvInfosGL_CVertexProgamDrvInfosGL);
nglGenProgramsARB(1, &ID);
}
//=================================================================================================
static const char *ARBVertexProgramInstrToName[] =
{
"MOV ",
"ARL ",
"MUL ",
"ADD ",
"MAD ",
"RSQ ",
"DP3 ",
"DP4 ",
"DST ",
"LIT ",
"MIN ",
"MAX ",
"SLT ",
"SGE ",
"EXP ",
"LOG ",
"RCP "
};
//=================================================================================================
static const char *ARBVertexProgramOutputRegisterToName[] =
{
"position",
"color.primary",
"color.secondary",
"color.back.primary",
"color.back.secondary",
"fogcoord",
"pointsize",
"texcoord[0]",
"texcoord[1]",
"texcoord[2]",
"texcoord[3]",
"texcoord[4]",
"texcoord[5]",
"texcoord[6]",
"texcoord[7]"
};
//=================================================================================================
static void ARBVertexProgramDumpWriteMask(uint mask, std::string &out)
{
H_AUTO_OGL(ARBVertexProgramDumpWriteMask)
if (mask == 0xf)
{
out = "";
return;
}
out = ".";
if (mask & 1) out +="x";
if (mask & 2) out +="y";
if (mask & 4) out +="z";
if (mask & 8) out +="w";
}
//=================================================================================================
static void ARBVertexProgramDumpSwizzle(const CVPSwizzle &swz, std::string &out)
{
H_AUTO_OGL(ARBVertexProgramDumpSwizzle)
if (swz.isIdentity())
{
out = "";
return;
}
out = ".";
for(uint k = 0; k < 4; ++k)
{
switch(swz.Comp[k])
{
case CVPSwizzle::X: out += "x"; break;
case CVPSwizzle::Y: out += "y"; break;
case CVPSwizzle::Z: out += "z"; break;
case CVPSwizzle::W: out += "w"; break;
default:
nlassert(0);
break;
}
if (swz.isScalar() && k == 0) break;
}
}
//=================================================================================================
static void ARBVertexProgramDumpOperand(const CVPOperand &op, bool destOperand, std::string &out)
{
H_AUTO_OGL(ARBVertexProgramDumpOperand)
out = op.Negate ? " -" : " ";
switch(op.Type)
{
case CVPOperand::Variable: out += "R" + NLMISC::toString(op.Value.VariableValue); break;
case CVPOperand::Constant:
out += "c[";
if (op.Indexed)
{
out += "A0.x + ";
}
out += NLMISC::toString(op.Value.ConstantValue) + "]";
break;
case CVPOperand::InputRegister: out += "vertex.attrib[" + NLMISC::toString((uint) op.Value.InputRegisterValue) + "]"; break;
case CVPOperand::OutputRegister:
nlassert(op.Value.OutputRegisterValue < CVPOperand::OutputRegisterCount);
out += "result." + std::string(ARBVertexProgramOutputRegisterToName[op.Value.OutputRegisterValue]);
break;
case CVPOperand::AddressRegister:
out += "A0.x";
break;
default:
break;
}
std::string suffix;
if (destOperand)
{
ARBVertexProgramDumpWriteMask(op.WriteMask, suffix);
}
else
{
ARBVertexProgramDumpSwizzle(op.Swizzle, suffix);
}
out += suffix;
}
//=================================================================================================
/** Dump an instruction in a string
*/
static void ARBVertexProgramDumpInstr(const CVPInstruction &instr, std::string &out)
{
H_AUTO_OGL(ARBVertexProgramDumpInstr)
nlassert(instr.Opcode < CVPInstruction::OpcodeCount);
// Special case for EXP with a scalar output argument (y component) -> translate to FRC
out = ARBVertexProgramInstrToName[instr.Opcode];
uint nbOp = instr.getNumUsedSrc();
std::string destOperand;
ARBVertexProgramDumpOperand(instr.Dest, true, destOperand);
out += destOperand;
for(uint k = 0; k < nbOp; ++k)
{
out += ", ";
std::string srcOperand;
ARBVertexProgramDumpOperand(instr.getSrc(k), false, srcOperand);
out += srcOperand;
}
out +="; \n";
}
// ***************************************************************************
bool CDriverGL3::setupARBVertexProgram (const CVPParser::TProgram &inParsedProgram, GLuint id, bool &specularWritten)
{
H_AUTO_OGL(CDriverGL3_setupARBVertexProgram);
// tmp
CVPParser::TProgram parsedProgram = inParsedProgram;
//
std::string code;
code = "!!ARBvp1.0\n";
// declare temporary registers
code += "TEMP ";
const uint NUM_TEMPORARIES = 12;
for(uint k = 0; k < NUM_TEMPORARIES; ++k)
{
code += toString("R%d", (int) k);
if (k != (NUM_TEMPORARIES - 1))
{
code +=", ";
}
}
code += "; \n";
// declare address register
code += "ADDRESS A0;\n";
// declare constant register
code += "PARAM c[96] = {program.env[0..95]}; \n";
uint writtenSpecularComponents = 0;
for(uint k = 0; k < parsedProgram.size(); ++k)
{
if (parsedProgram[k].Dest.Type == CVPOperand::OutputRegister && parsedProgram[k].Dest.Value.OutputRegisterValue == CVPOperand::OSecondaryColor)
{
writtenSpecularComponents |= parsedProgram[k].Dest.WriteMask;
}
}
// tmp fix : write unwritten components of specular (seems that glDisable(GL_COLOR_SUM_ARB) does not work in a rare case for me ...)
if (writtenSpecularComponents != 0xf)
{
// add a new instruction to write 0 in unwritten components
CVPSwizzle sw;
sw.Comp[0] = CVPSwizzle::X;
sw.Comp[1] = CVPSwizzle::Y;
sw.Comp[2] = CVPSwizzle::Z;
sw.Comp[3] = CVPSwizzle::W;
CVPInstruction vpi;
vpi.Opcode = CVPInstruction::ADD;
vpi.Dest.WriteMask = 0xf ^ writtenSpecularComponents;
vpi.Dest.Type = CVPOperand::OutputRegister;
vpi.Dest.Value.OutputRegisterValue = CVPOperand::OSecondaryColor;
vpi.Dest.Indexed = false;
vpi.Dest.Negate = false;
vpi.Dest.Swizzle = sw;
vpi.Src1.Type = CVPOperand::InputRegister;
vpi.Src1.Value.InputRegisterValue = CVPOperand::IPosition; // tmp -> check that position is present
vpi.Src1.Indexed = false;
vpi.Src1.Negate = false;
vpi.Src1.Swizzle = sw;
vpi.Src2.Type = CVPOperand::InputRegister;
vpi.Src2.Value.InputRegisterValue = CVPOperand::IPosition; // tmp -> chec
vpi.Src2.Indexed = false;
vpi.Src2.Negate = true;
vpi.Src2.Swizzle = sw;
//
parsedProgram.push_back(vpi);
}
specularWritten = (writtenSpecularComponents != 0);
for(uint k = 0; k < parsedProgram.size(); ++k)
{
std::string instr;
ARBVertexProgramDumpInstr(parsedProgram[k], instr);
code += instr + "\r\n";
}
code += "END\n";
//
/*
static COFile output;
static bool opened = false;
if (!opened)
{
output.open("vp.txt", false, true);
opened = true;
}
std::string header = "=====================================================================================";
output.serial(header);
output.serial(code);
*/
//
nglBindProgramARB( GL_VERTEX_PROGRAM_ARB, id);
glGetError();
nglProgramStringARB( GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)code.size(), code.c_str() );
GLenum err = glGetError();
if (err != GL_NO_ERROR)
{
if (err == GL_INVALID_OPERATION)
{
GLint position;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &position);
nlassert(position != -1); // there was an error..
nlassert(position < (GLint) code.size());
uint line = 0;
const char *lineStart = code.c_str();
for(uint k = 0; k < (uint) position; ++k)
{
if (code[k] == '\n')
{
lineStart = code.c_str() + k;
++line;
}
}
nlwarning("ARB vertex program parse error at line %d.", (int) line);
// search end of line
const char *lineEnd = code.c_str() + code.size();
for(uint k = position; k < code.size(); ++k)
{
if (code[k] == '\n')
{
lineEnd = code.c_str() + k;
break;
}
}
nlwarning(std::string(lineStart, lineEnd).c_str());
// display the gl error msg
const GLubyte *errorMsg = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
nlassert((const char *) errorMsg);
nlwarning((const char *) errorMsg);
}
nlassert(0);
return false;
}
#ifdef NL_OS_MAC
// Wait for GPU to finish program upload, else draw comands might crash.
// Happened to CVegetableBlendLayerModel (glDrawElements()).
// For more information, see http://dev.ryzom.com/issues/1006
glFinish();
#endif
return true;
}
// ***************************************************************************
bool CDriverGL3::activeARBVertexProgram (CVertexProgram *program)
{
H_AUTO_OGL(CDriverGL3_activeARBVertexProgram);
// Setup or unsetup ?
if (program)
{
// Driver info
CVertexProgamDrvInfosGL3 *drvInfo;
// Program setuped ?
if (program->_DrvInfo==NULL)
{
// try to parse the program
CVPParser parser;
CVPParser::TProgram parsedProgram;
std::string errorOutput;
bool result = parser.parse(program->getProgram().c_str(), parsedProgram, errorOutput);
if (!result)
{
nlwarning("Unable to parse a vertex program.");
#ifdef NL_DEBUG
nlerror(errorOutput.c_str());
#endif
return false;
}
// Insert into driver list. (so it is deleted when driver is deleted).
ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), (NL3D::IVertexProgramDrvInfos*)NULL);
// Create a driver info
*it = drvInfo = new CVertexProgamDrvInfosGL3 (this, it);
// Set the pointer
program->_DrvInfo=drvInfo;
if (!setupARBVertexProgram(parsedProgram, drvInfo->ID, drvInfo->SpecularWritten))
{
delete drvInfo;
program->_DrvInfo = NULL;
_VtxPrgDrvInfos.erase(it);
return false;
}
}
else
{
// Cast the driver info pointer
drvInfo=safe_cast<CVertexProgamDrvInfosGL3*>((IVertexProgramDrvInfos*)program->_DrvInfo);
}
glEnable( GL_VERTEX_PROGRAM_ARB );
_VertexProgramEnabled = true;
nglBindProgramARB( GL_VERTEX_PROGRAM_ARB, drvInfo->ID );
if (drvInfo->SpecularWritten)
{
glEnable( GL_COLOR_SUM_ARB );
}
else
{
glDisable( GL_COLOR_SUM_ARB ); // no specular written
}
_LastSetuppedVP = program;
}
else
{
glDisable( GL_VERTEX_PROGRAM_ARB );
glDisable( GL_COLOR_SUM_ARB );
#ifndef GLSL
_VertexProgramEnabled = false;
#endif
}
return true;
}
// ***************************************************************************
bool CDriverGL3::activeVertexProgram (CVertexProgram *program)
{
H_AUTO_OGL(CDriverGL3_activeVertexProgram)
// Extension here ?
return activeARBVertexProgram(program);
// Can't do anything
return false;
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, float f0, float f1, float f2, float f3)
{
H_AUTO_OGL(CDriverGL3_setConstant);
// Vertex program exist ?
nglProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, index, f0, f1, f2, f3);
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, double d0, double d1, double d2, double d3)
{
H_AUTO_OGL(CDriverGL3_setConstant);
nglProgramEnvParameter4dARB(GL_VERTEX_PROGRAM_ARB, index, d0, d1, d2, d3);
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, const NLMISC::CVector& value)
{
H_AUTO_OGL(CDriverGL3_setConstant);
nglProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, const NLMISC::CVectorD& value)
{
H_AUTO_OGL(CDriverGL3_setConstant);
nglProgramEnvParameter4dARB(GL_VERTEX_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, uint num, const float *src)
{
H_AUTO_OGL(CDriverGL3_setConstant);
for(uint k = 0; k < num; ++k)
{
nglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, index + k, src + 4 * k);
}
}
// ***************************************************************************
void CDriverGL3::setConstant (uint index, uint num, const double *src)
{
H_AUTO_OGL(CDriverGL3_setConstant);
for(uint k = 0; k < num; ++k)
{
nglProgramEnvParameter4dvARB(GL_VERTEX_PROGRAM_ARB, index + k, src + 4 * k);
}
}
// ***************************************************************************
const uint CDriverGL3::GLMatrix[IDriver::NumMatrix]=
{
GL_MODELVIEW,
GL_PROJECTION,
GL_MODELVIEW_PROJECTION_NV
};
// ***************************************************************************
const uint CDriverGL3::GLTransform[IDriver::NumTransform]=
{
GL_IDENTITY_NV,
GL_INVERSE_NV,
GL_TRANSPOSE_NV,
GL_INVERSE_TRANSPOSE_NV
};
// ***************************************************************************
void CDriverGL3::setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver::TTransform transform)
{
H_AUTO_OGL(CDriverGL3_setConstantMatrix);
{
// First, ensure that the render setup is correctly setuped.
refreshRenderSetup();
CMatrix mat;
switch (matrix)
{
case IDriver::ModelView:
mat = _ModelViewMatrix;
break;
case IDriver::Projection:
{
mat = _GLProjMat;
}
break;
case IDriver::ModelViewProjection:
mat = _GLProjMat * _ModelViewMatrix;
break;
default:
break;
}
switch(transform)
{
case IDriver::Identity: break;
case IDriver::Inverse:
mat.invert();
break;
case IDriver::Transpose:
mat.transpose();
break;
case IDriver::InverseTranspose:
mat.invert();
mat.transpose();
break;
default:
break;
}
mat.transpose();
float matDatas[16];
mat.get(matDatas);
nglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, index, matDatas);
nglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, index + 1, matDatas + 4);
nglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, index + 2, matDatas + 8);
nglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, index + 3, matDatas + 12);
}
}
// ***************************************************************************
void CDriverGL3::setConstantFog (uint index)
{
H_AUTO_OGL(CDriverGL3_setConstantFog)
const float *values = _ModelViewMatrix.get();
setConstant (index, -values[2], -values[6], -values[10], -values[14]);
}
// ***************************************************************************
void CDriverGL3::enableVertexProgramDoubleSidedColor(bool doubleSided) void CDriverGL3::enableVertexProgramDoubleSidedColor(bool doubleSided)
{ {
H_AUTO_OGL(CDriverGL3_enableVertexProgramDoubleSidedColor); H_AUTO_OGL(CDriverGL3_enableVertexProgramDoubleSidedColor);

Loading…
Cancel
Save