From fb38a7a0a76ad6d22caf0742497706ed2b4022b2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 9 Dec 2013 03:55:37 +0100 Subject: [PATCH] Disable lights when the material isn't lighted. --HG-- branch : gsoc2013-dfighter --- code/nel/src/3d/driver/opengl3/driver_opengl.h | 1 + code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp | 8 ++++++++ code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp | 3 +++ code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp | 7 ------- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.h b/code/nel/src/3d/driver/opengl3/driver_opengl.h index 76bfb3abf..38c3ad534 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.h @@ -1181,6 +1181,7 @@ private: void setLightInternal(uint8 num, const CLight& light); void enableLightInternal(uint8 num, bool enable); void setupLightMapDynamicLighting(bool enable); + void disableAllLights(); /// \name VertexBufferHard diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp index dfbaabd59..fbb4037b8 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp @@ -199,6 +199,14 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable) } } +void CDriverGL3::disableAllLights() +{ + for( int i = 0; i < MaxLight; i++ ) + { + _UserLightEnable[ i ] = false; + } +} + #ifdef NL_STATIC } // NLDRIVERGL/ES #endif diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp index efb82977e..79cdb60b5 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp @@ -433,6 +433,9 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) // Light Part. _DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING); + if( ( mat.getFlags() & IDRV_MAT_LIGHTING ) == 0 ) + disableAllLights(); + if(mat.getFlags()&IDRV_MAT_LIGHTING) { _DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp index 2236049a0..04d00a677 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp @@ -261,13 +261,6 @@ void CDriverGLStates3::enableLighting(uint enable) { // new state. _CurLighting= enabled; - // Setup GLState. - if(_CurLighting) - glEnable(GL_LIGHTING); - else - { - glDisable(GL_LIGHTING); - } } }