GL3: Remove GL_MAX_LIGHTS

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 8a60e5d4fa
commit 9c1165dcf9

@ -396,20 +396,12 @@ bool CDriverGL3::setupDisplay()
nlwarning("Missing Important GL extension: GL_EXT_texture_env_combine => All envcombine are setup to GL_MODULATE!!!");
}*/
// Get num of light for this driver
int numLight;
glGetIntegerv (GL_MAX_LIGHTS, &numLight);
_MaxDriverLight=(uint)numLight;
if (_MaxDriverLight>MaxLight)
_MaxDriverLight=MaxLight;
// All User Light are disabled by Default
uint i;
for (i=0;i<MaxLight;i++)
_UserLightEnable[i]= false;
for (uint i = 0; i < MaxLight; ++i)
_UserLightEnable[i] = false;
// init _DriverGLStates
_DriverGLStates.init(_MaxDriverLight);
_DriverGLStates.init();
// Init OpenGL/Driver defaults.
//=============================
@ -426,24 +418,24 @@ bool CDriverGL3::setupDisplay()
_CurrViewport.init(0.f, 0.f, 1.f, 1.f);
_CurrScissor.initFullScreen();
_CurrentGlNormalize= false;
_ForceNormalize= false;
_CurrentGlNormalize = false;
_ForceNormalize = false;
// Setup defaults for blend, lighting ...
_DriverGLStates.forceDefaults(inlGetNumTextStages());
// Default delta camera pos.
_PZBCameraPos= CVector::Null;
_PZBCameraPos = CVector::Null;
// Init VertexArrayRange according to supported extenstion.
_SlowUnlockVBHard= false;
_SlowUnlockVBHard = false;
_AGPVertexArrayRange= new CVertexArrayRange(this);
_VRAMVertexArrayRange= new CVertexArrayRange(this);
_AGPVertexArrayRange = new CVertexArrayRange(this);
_VRAMVertexArrayRange = new CVertexArrayRange(this);
// Reset VertexArrayRange.
_CurrentVertexArrayRange= NULL;
_CurrentVertexBufferHard= NULL;
_NVCurrentVARPtr= NULL;
_NVCurrentVARSize= 0;
_CurrentVertexArrayRange = NULL;
_CurrentVertexBufferHard = NULL;
_NVCurrentVARPtr = NULL;
_NVCurrentVARSize = 0;
initVertexBufferHard(NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, 0);
@ -456,8 +448,8 @@ bool CDriverGL3::setupDisplay()
for (uint stage=0;stage<inlGetNumTextStages(); stage++)
{
// init no texture.
_CurrentTexture[stage]= NULL;
_CurrentTextureInfoGL[stage]= NULL;
_CurrentTexture[stage] = NULL;
_CurrentTextureInfoGL[stage] = NULL;
// texture are disabled in DriverGLStates.forceDefaults().
// init default env.
@ -465,13 +457,15 @@ bool CDriverGL3::setupDisplay()
env.ConstantColor.set(255,255,255,255);
// Not special TexEnv.
_CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled;
_CurrentTexEnvSpecial[stage] = TexEnvSpecialDisabled;
// set All TexGen by default to identity matrix (prefer use the textureMatrix scheme)
_DriverGLStates.activeTextureARB(stage);
}
if (!initProgramPipeline())
nlerror("Failed to create Pipeline Object");
_PPLExponent = 1.f;
_PPLightDiffuseColor = NLMISC::CRGBA::White;
_PPLightSpecularColor = NLMISC::CRGBA::White;
@ -499,12 +493,6 @@ bool CDriverGL3::setupDisplay()
// Reset the vbl interval
setSwapVBLInterval(_Interval);
if (!initPipeline())
{
nlinfo("Failed to create Pipeline Object");
nlassert(false);
}
return true;
}

@ -305,7 +305,7 @@ class CDriverGL3 : public IDriver
public:
// Some constants
enum { MaxLight=8 };
enum { MaxLight = NL_OPENGL3_MAX_LIGHT };
CDriverGL3();
virtual ~CDriverGL3();
@ -900,8 +900,6 @@ private:
bool _RenderTargetFBO;
// Num lights return by GL_MAX_LIGHTS
uint _MaxDriverLight;
// real mirror of GL state
uint _LightMode[MaxLight]; // Light mode.
CVector _WorldLightPos[MaxLight]; // World position of the lights.
@ -1352,7 +1350,7 @@ private:
CGLSLShaderGenerator *shaderGenerator;
CUsrShaderManager *usrShaderManager;
bool initPipeline();
bool initProgramPipeline();
uint32 ppoId;
SProgram currentProgram;

@ -29,8 +29,8 @@ namespace NLDRIVERGL3 {
uint CDriverGL3::getMaxLight () const
{
H_AUTO_OGL(CDriverGL3_getMaxLight)
// return min(maxLight supported by openGL, MaxLight=8).
return _MaxDriverLight;
// return MaxLight=8.
return MaxLight;
}
@ -61,42 +61,42 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLightInternal)
// Check light count is good
// nlassert (num<_MaxDriverLight);
// nlassert(num < MaxLight);
// Set the light
if (num<_MaxDriverLight)
if (num < MaxLight)
{
// GL light number
GLenum lightNum=(GLenum)(GL_LIGHT0+num);
GLenum lightNum = (GLenum)(GL_LIGHT0+num);
// Get light mode
CLight::TLightMode mode=light.getMode ();
CLight::TLightMode mode = light.getMode ();
// Copy the mode
_LightMode[num]=mode;
_LightMode[num] = mode;
_UserLight[num] = light;
// Set the position
if ((mode==CLight::DirectionalLight)||(mode==CLight::SpotLight))
if ((mode == CLight::DirectionalLight) || (mode == CLight::SpotLight))
{
// Get the direction of the light
_WorldLightDirection[num]=light.getDirection ();
_WorldLightDirection[num] = light.getDirection();
}
if (mode!=CLight::DirectionalLight)
if (mode != CLight::DirectionalLight)
{
// Get the position of the light
_WorldLightPos[num]=light.getPosition ();
_WorldLightPos[num] = light.getPosition();
}
if (mode==CLight::SpotLight)
if (mode == CLight::SpotLight)
{
// Get the exponent of the spot
float exponent=light.getExponent ();
float exponent = light.getExponent();
// Get the cutoff of the spot
float cutoff=180.f*(light.getCutoff ()/(float)NLMISC::Pi);
float cutoff = 180.f * (light.getCutoff() / (float)NLMISC::Pi);
}
@ -104,7 +104,7 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
}
// ***************************************************************************
void CDriverGL3::enableLight (uint8 num, bool enable)
void CDriverGL3::enableLight(uint8 num, bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLight)
@ -112,12 +112,12 @@ void CDriverGL3::enableLight (uint8 num, bool enable)
enableLightInternal(num, enable);
// because the GL setup has changed, must dirt lightmap rendering
_LightMapDynamicLightDirty= true;
_LightMapDynamicLightDirty = true;
}
bool CDriverGL3::isLightEnabled (uint8 num)
{
if (num<_MaxDriverLight)
if (num < MaxLight)
return _UserLightEnable[num];
return false;
@ -129,13 +129,13 @@ void CDriverGL3::enableLightInternal(uint8 num, bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLightInternal)
// Check light count is good
// nlassert (num<_MaxDriverLight);
// nlassert(num < MaxLight);
// Enable glLight
if (num<_MaxDriverLight)
if (num < MaxLight)
{
_DriverGLStates.enableLight(num, enable);
_UserLightEnable[ num ] = enable;
_DriverGLStates.enableLight(num, enable); // FIXME GL3 FIXED
_UserLightEnable[num] = enable;
}
}
@ -168,7 +168,7 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
if (enable)
{
// disable all lights but the 0th.
for (uint i=1;i<_MaxDriverLight;i++)
for (uint i = 1; i < MaxLight; ++i)
enableLightInternal(i, false);
// if the dynamic light is really enabled
@ -185,7 +185,7 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
}
// ok it has been setup
_LightMapDynamicLightDirty= false;
_LightMapDynamicLightDirty = false;
}
// restore old lighting
else
@ -194,7 +194,7 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
setLightInternal(0, _UserLight0);
// restore all standard light enable states
for (uint i=0;i<_MaxDriverLight;i++)
for (uint i = 0; i < MaxLight; ++i)
enableLightInternal(i, _UserLightEnable[i]);
}
}

@ -1018,7 +1018,7 @@ namespace NL3D
}
}
bool CDriverGL3::initPipeline()
bool CDriverGL3::initProgramPipeline()
{
ppoId = 0;

@ -36,17 +36,14 @@ CDriverGLStates3::CDriverGLStates3()
_DepthRangeNear = 0.f;
_DepthRangeFar = 1.f;
_ZBias = 0.f;
_MaxDriverLight= 0;
_CullMode = CCW;
}
// ***************************************************************************
void CDriverGLStates3::init(uint maxLight)
void CDriverGLStates3::init()
{
H_AUTO_OGL(CDriverGLStates3_init)
_MaxDriverLight= maxLight;
_MaxDriverLight= std::min(_MaxDriverLight, uint(MaxLight));
// By default all arrays are disabled.
_VertexArrayEnabled= false;
@ -263,7 +260,7 @@ void CDriverGLStates3::enableLighting(uint enable)
void CDriverGLStates3::enableLight(uint num, uint enable)
{
H_AUTO_OGL(CDriverGLStates3_enableLight)
if (num>=_MaxDriverLight)
if (num >= MaxLight)
return;
// If different from current setup, update.
@ -281,7 +278,7 @@ void CDriverGLStates3::enableLight(uint num, uint enable)
bool CDriverGLStates3::isLightEnabled(uint num) const
{
H_AUTO_OGL(CDriverGLStates3_isLightEnabled)
if (num>=_MaxDriverLight)
if (num >= MaxLight)
return false;
else
return _CurLight[num];

@ -26,6 +26,8 @@ namespace NL3D {
namespace NLDRIVERGL3 {
#endif
#define NL_OPENGL3_MAX_LIGHT 8
// ***************************************************************************
/**
* Class for optimizing calls to openGL states, by caching old ones.
@ -74,7 +76,7 @@ public:
/// Constructor. no-op.
CDriverGLStates3();
// init. Do it just after setDisplay()
void init(uint maxLight);
void init();
/// Reset all OpenGL states of interest to default, and update caching. This don't apply to light.
void forceDefaults(uint nbTextureStages);
@ -221,8 +223,7 @@ private:
void updateDepthRange();
// Mirror of glEnable() and GL_LIGHT0+i
enum {MaxLight=8};
uint _MaxDriverLight;
enum { MaxLight = NL_OPENGL3_MAX_LIGHT };
bool _CurLight[MaxLight];
};

Loading…
Cancel
Save