Browse Source

fix lighting optimization

cxgeorge 24 years ago
parent
commit
38423a2c21

+ 1 - 0
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()

+ 4 - 5
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();

+ 1 - 0
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;