diff options
Diffstat (limited to 'source/gameengine/GamePlayer/common')
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 40 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_RenderTools.h | 8 |
2 files changed, 33 insertions, 15 deletions
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 4e28bb4a449..743af35ae9b 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -52,6 +52,7 @@ #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" #include "RAS_ICanvas.h" +#include "RAS_GLExtensionManager.h" // next two includes/dependencies come from the shadow feature // it needs the gameobject and the sumo physics scene for a raycast @@ -153,6 +154,15 @@ int GPC_RenderTools::ProcessLighting(int layer) return result; } +void GPC_RenderTools::EnableOpenGLLights() +{ + glEnable(GL_LIGHTING); + glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glEnableClientState(GL_NORMAL_ARRAY); + if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +} void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, const char* text, @@ -368,9 +378,9 @@ int GPC_RenderTools::applyLights(int objectlayer) glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); - // without this next line it looks backward compatible. - //attennuation still is acceptable - // glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist)); + // without this next line it looks backward compatible. + //attennuation still is acceptable + glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { vec[0] = -(*(lightdata->m_worldmatrix))(0,2); @@ -386,11 +396,25 @@ int GPC_RenderTools::applyLights(int objectlayer) else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); } - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); + if (lightdata->m_nodiffuse) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; + } + glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); + if (lightdata->m_nospecular) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else if (lightdata->m_nodiffuse) { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; + } glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); glEnable((GLenum)(GL_LIGHT0+count)); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 432bf393e3a..9c76ccd478d 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -67,13 +67,7 @@ public: glDisableClientState(GL_NORMAL_ARRAY); } - void EnableOpenGLLights() - { - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); - glEnableClientState(GL_NORMAL_ARRAY); - } + void EnableOpenGLLights(); int ProcessLighting(int layer); |