Browse Source

pixel zoom

David Rose 17 years ago
parent
commit
a2c8f382f3

+ 1 - 0
panda/src/tinydisplay/tinyOsxGraphicsWindow.h

@@ -52,6 +52,7 @@ public:
   virtual void begin_flip();
   virtual void begin_flip();
   virtual void end_flip();
   virtual void end_flip();
   virtual void process_events();
   virtual void process_events();
+  virtual bool supports_pixel_zoom() const;
   
   
   virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
   virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
                                   int x_size, int y_size);
                                   int x_size, int y_size);

+ 25 - 5
panda/src/tinydisplay/tinyOsxGraphicsWindow.mm

@@ -736,11 +736,12 @@ void TinyOsxGraphicsWindow::begin_flip()
   QDErr err;
   QDErr err;
 
 
   // blit rendered framebuffer into window backing store
   // blit rendered framebuffer into window backing store
-  long width  = _frame_buffer->xsize;
-  long height  = _frame_buffer->ysize;
-  
-  Rect src_rect = {0, 0, height, width};
-  Rect ddrc_rect = {0, 0, height, width};
+  Rect src_rect = {0, 0, _frame_buffer->ysize, _frame_buffer->xsize};
+  Rect ddrc_rect = {0, 0, _frame_buffer->ysize, _frame_buffer->xsize};
+  if (get_pixel_factor() != 1.0) {
+    src_rect.right = get_fb_x_size();
+    src_rect.bottom = get_fb_y_size();
+  }
   
   
   // create a GWorld containing our image
   // create a GWorld containing our image
   GWorldPtr pGWorld;
   GWorldPtr pGWorld;
@@ -1113,6 +1114,25 @@ void TinyOsxGraphicsWindow::process_events()
     }
     }
 };
 };
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TinyOsxGraphicsWindow::supports_pixel_zoom
+//       Access: Published, Virtual
+//  Description: Returns true if a call to set_pixel_zoom() will be
+//               respected, false if it will be ignored.  If this
+//               returns false, then get_pixel_factor() will always
+//               return 1.0, regardless of what value you specify for
+//               set_pixel_zoom().
+//
+//               This may return false if the underlying renderer
+//               doesn't support pixel zooming, or if you have called
+//               this on a DisplayRegion that doesn't have both
+//               set_clear_color() and set_clear_depth() enabled.
+////////////////////////////////////////////////////////////////////
+bool TinyOsxGraphicsWindow::
+supports_pixel_zoom() const {
+  return true;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: TinyOsxGraphicsWindow::handleKeyInput()
 //     Function: TinyOsxGraphicsWindow::handleKeyInput()
 //       Access: virtual, protected
 //       Access: virtual, protected