Browse Source

fix scissoring during the DisplayRegion's glClear() operation

David Rose 11 years ago
parent
commit
9f896821e7
1 changed files with 47 additions and 1 deletions
  1. 47 1
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx

+ 47 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -2429,9 +2429,17 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
   set_draw_buffer(_draw_buffer_type);
   set_draw_buffer(_draw_buffer_type);
 
 
   if (dr->get_scissor_enabled()) {
   if (dr->get_scissor_enabled()) {
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glEnable(GL_SCISSOR_TEST)\n";
+    }
     glEnable(GL_SCISSOR_TEST);
     glEnable(GL_SCISSOR_TEST);
     _scissor_enabled = true;
     _scissor_enabled = true;
   } else {
   } else {
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glDisable(GL_SCISSOR_TEST)\n";
+    }
     glDisable(GL_SCISSOR_TEST);
     glDisable(GL_SCISSOR_TEST);
     _scissor_enabled = false;
     _scissor_enabled = false;
   }
   }
@@ -2455,6 +2463,24 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
     if (dr->get_scissor_enabled()) {
     if (dr->get_scissor_enabled()) {
       _glScissorArrayv(0, count, scissors);
       _glScissorArrayv(0, count, scissors);
     }
     }
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glViewportArrayv(0, " << count << ", [\n";
+      for (int i = 0; i < count; ++i) {
+        GLfloat *vr = viewports + i * 4;
+        GLCAT.spam(false) << vr[0] << ", " << vr[1] << ", " << vr[2] << ", " << vr[3] << ",\n";
+      }
+      GLCAT.spam(false) << "])\n";
+      if (dr->get_scissor_enabled()) {
+        GLCAT.spam()
+          << "glScissorArrayv(0, " << count << ", [\n";
+        for (int i = 0; i < count; ++i) {
+          GLint *sr = scissors + i * 4;
+          GLCAT.spam(false) << sr[0] << ", " << sr[1] << ", " << sr[2] << ", " << sr[3] << ",\n";
+        }
+      }
+      GLCAT.spam(false) << "])\n";
+    }
 
 
   } else
   } else
 #endif  // OPENGLES
 #endif  // OPENGLES
@@ -2463,6 +2489,14 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
     if (dr->get_scissor_enabled()) {
     if (dr->get_scissor_enabled()) {
       glScissor(x, y, width, height);
       glScissor(x, y, width, height);
     }
     }
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glViewport(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+      if (dr->get_scissor_enabled()) {
+        GLCAT.spam()
+          << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+      }
+    }
   }
   }
 
 
   report_my_gl_errors();
   report_my_gl_errors();
@@ -11676,13 +11710,21 @@ void CLP(GraphicsStateGuardian)::
 do_issue_scissor() {
 do_issue_scissor() {
   const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot()));
   const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot()));
 
 
-  if (target_scissor->is_off()) {
+  if (target_scissor->is_off() && !_current_display_region->get_scissor_enabled()) {
     if (_scissor_enabled) {
     if (_scissor_enabled) {
+      if (GLCAT.is_spam()) {
+        GLCAT.spam()
+          << "glDisable(GL_SCISSOR_TEST)\n";
+      }
       glDisable(GL_SCISSOR_TEST);
       glDisable(GL_SCISSOR_TEST);
       _scissor_enabled = false;
       _scissor_enabled = false;
     }
     }
   } else {
   } else {
     if (!_scissor_enabled) {
     if (!_scissor_enabled) {
+      if (GLCAT.is_spam()) {
+        GLCAT.spam()
+          << "glEnable(GL_SCISSOR_TEST)\n";
+      }
       glEnable(GL_SCISSOR_TEST);
       glEnable(GL_SCISSOR_TEST);
       _scissor_enabled = true;
       _scissor_enabled = true;
     }
     }
@@ -11694,6 +11736,10 @@ do_issue_scissor() {
     int width = (int)(_viewport_width * (frame[1] - frame[0]) + 0.5f);
     int width = (int)(_viewport_width * (frame[1] - frame[0]) + 0.5f);
     int height = (int)(_viewport_height * (frame[3] - frame[2]) + 0.5f);
     int height = (int)(_viewport_height * (frame[3] - frame[2]) + 0.5f);
 
 
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+    }
     glScissor(x, y, width, height);
     glScissor(x, y, width, height);
   }
   }
 }
 }