From 38423a2c2118525b2bb51a3dcae22a774c070ce6 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Tue, 15 May 2001 01:14:39 +0000 Subject: [PATCH] fix lighting optimization --- panda/src/glgsg/glGraphicsStateGuardian.I | 1 + panda/src/glgsg/glGraphicsStateGuardian.cxx | 9 ++++----- panda/src/glgsg/glGraphicsStateGuardian.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/panda/src/glgsg/glGraphicsStateGuardian.I b/panda/src/glgsg/glGraphicsStateGuardian.I index 70522b5f41..8f17b8207a 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.I +++ b/panda/src/glgsg/glGraphicsStateGuardian.I @@ -757,6 +757,7 @@ enable_lighting(bool val) { << "glEnable(GL_LIGHTING)" << endl; #endif glEnable(GL_LIGHTING); + _lighting_enabled_this_frame = true; } else { #ifdef GSG_VERBOSE glgsg_cat.debug() diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index 528f98af62..f7fab186e5 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -467,6 +467,8 @@ render_frame(const AllAttributesWrapper &initial_state) { << " --------------------------------------------" << endl; #endif + _lighting_enabled_this_frame = false; + _win->begin_frame(); report_errors(); _decal_level = 0; @@ -515,10 +517,7 @@ render_frame(const AllAttributesWrapper &initial_state) { // Now we're done with the frame processing. Clean up. - // We can't necessarily rely on this test not to this this right - // now. Come up with a better optimization later. - - // if (_lighting_enabled) { + if (_lighting_enabled) { // Let's turn off all the lights we had on, and clear the light // cache--to force the lights to be reissued next frame, in case @@ -540,7 +539,7 @@ render_frame(const AllAttributesWrapper &initial_state) { // ideal--there may be a better way. Maybe if the lights were just // more aware of whether their parameters or positions have changed // at all? - // } + } #ifndef NDEBUG report_errors(); diff --git a/panda/src/glgsg/glGraphicsStateGuardian.h b/panda/src/glgsg/glGraphicsStateGuardian.h index f830e8fcfb..b49688b75e 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.h +++ b/panda/src/glgsg/glGraphicsStateGuardian.h @@ -298,6 +298,7 @@ protected: bool _point_smooth_enabled; bool _scissor_enabled; bool _lighting_enabled; + bool _lighting_enabled_this_frame; bool _texturing_enabled; bool _dither_enabled; bool _stencil_test_enabled;