diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-05-21 12:56:05 +0400 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-05-21 12:56:05 +0400 |
commit | 22883f9232da3df2bcba995bb0d84d4cf95803e8 (patch) | |
tree | d8654ce7acacc9359fdd23f5966a4f4fa0b4b84b /source/gameengine | |
parent | e78ef29a593857d87b0c35c211d082c8caa80f7b (diff) |
Query GL for max number of lights to use.
Diffstat (limited to 'source/gameengine')
4 files changed, 21 insertions, 18 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 3ce8437a55b..0a8eb2d4e08 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -69,6 +69,9 @@ KX_BlenderRenderTools::KX_BlenderRenderTools() { + glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights); + if (m_numgllights < 8) + m_numgllights = 8; } /** @@ -343,16 +346,13 @@ int KX_BlenderRenderTools::applyLights(int objectlayer) vec[3]= 1.0; - for(count=0; count<8; count++) + for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); - count= 0; - //std::vector<struct RAS_LightObject*> m_lights; std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); - - for (lit = m_lights.begin(); !(lit==m_lights.end()); ++lit) + for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); if (lightdata->m_layer & objectlayer) @@ -410,11 +410,9 @@ int KX_BlenderRenderTools::applyLights(int objectlayer) glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); glEnable((GLenum)(GL_LIGHT0+count)); - glPopMatrix(); - count++; - if(count>7) - break; + + glPopMatrix(); } } @@ -435,3 +433,5 @@ RAS_IPolyMaterial* KX_BlenderRenderTools::CreateBlenderPolyMaterial( ba,matname,tile,tilexrep,tileyrep,mode,transparant,lightlayer ,bIsTriangle,clientobject,(struct TFace*)tface); } + +unsigned int KX_BlenderRenderTools::m_numgllights; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 91227967185..e8a789893ca 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -51,7 +51,8 @@ class KX_BlenderRenderTools : public RAS_IRenderTools void* m_lastblenderobject; int m_lastlayer; bool m_lastlighting; - + static unsigned int m_numgllights; + public: KX_BlenderRenderTools(); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 3a7520861f9..79d769f7a1a 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -103,6 +103,9 @@ GPC_RenderTools::GPC_RenderTools() { m_font = BMF_GetFont(BMF_kHelvetica10); + glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights); + if (m_numgllights < 8) + m_numgllights = 8; } @@ -326,16 +329,14 @@ int GPC_RenderTools::applyLights(int objectlayer) vec[3]= 1.0; - for(count=0; count<8; count++) + for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); - count= 0; - //std::vector<struct RAS_LightObject*> m_lights; std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); - for (lit = m_lights.begin(); !(lit==m_lights.end()); ++lit) + for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); if (lightdata->m_layer & objectlayer) @@ -392,12 +393,10 @@ int GPC_RenderTools::applyLights(int objectlayer) glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); glEnable((GLenum)(GL_LIGHT0+count)); + + count++; glPopMatrix(); - - count++; - if(count>7) - break; } } @@ -511,3 +510,5 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in } } } + +unsigned int GPC_RenderTools::m_numgllights; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index c346003411c..3a878244e47 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -170,6 +170,7 @@ protected: BMF_Font* m_font; + static unsigned int m_numgllights; }; #endif // __GPC_RENDERTOOLS_H |