Browse Source

fix nan in scissor region

David Rose 17 years ago
parent
commit
9a817b27c6

+ 7 - 1
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -4258,7 +4258,13 @@ set_scissor(float left, float right, float bottom, float top) {
   float ysize = top - bottom;
   float xcenter = (left + right) - 1.0f;
   float ycenter = (bottom + top) - 1.0f;
-  _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f)));
+  if (xsize == 0.0f || ysize == 0.0f) {
+    // If the scissor region is zero, nothing will be drawn anyway, so
+    // don't worry about it.
+    _scissor_mat = TransformState::make_identity();
+  } else {
+    _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f)));
+  }
   prepare_lens();
 }
 

+ 7 - 1
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1958,7 +1958,13 @@ set_scissor(float left, float right, float bottom, float top) {
   float ysize = top - bottom;
   float xcenter = (left + right) - 1.0f;
   float ycenter = (bottom + top) - 1.0f;
-  _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f)));
+  if (xsize == 0.0f || ysize == 0.0f) {
+    // If the scissor region is zero, nothing will be drawn anyway, so
+    // don't worry about it.
+    _scissor_mat = TransformState::make_identity();
+  } else {
+    _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f)));
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 10 - 0
panda/src/tinydisplay/tinyWinGraphicsPipe.cxx

@@ -20,6 +20,7 @@
 #include "config_tinydisplay.h"
 #include "config_windisplay.h"
 #include "tinyWinGraphicsWindow.h"
+#include "tinyGraphicsBuffer.h"
 
 TypeHandle TinyWinGraphicsPipe::_type_handle;
   
@@ -116,6 +117,15 @@ make_output(const string &name,
                                      flags, gsg, host);
   }
   
+  // Second thing to try: a TinyGraphicsBuffer
+  if (retry == 1) {
+    if (((flags&BF_require_parasite)!=0)||
+        ((flags&BF_require_window)!=0)) {
+      return NULL;
+    }
+    return new TinyGraphicsBuffer(this, name, fb_prop, win_prop, flags, gsg, host);
+  }
+  
   // Nothing else left to try.
   return NULL;
 }