From a2c8f382f3cb9ebf77d65848d207936e447ca0f9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 12 May 2008 23:31:42 +0000 Subject: [PATCH] pixel zoom --- panda/src/tinydisplay/tinyOsxGraphicsWindow.h | 1 + .../src/tinydisplay/tinyOsxGraphicsWindow.mm | 30 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h index 7c927ad054..2d493684a1 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h @@ -52,6 +52,7 @@ public: virtual void begin_flip(); virtual void end_flip(); virtual void process_events(); + virtual bool supports_pixel_zoom() const; virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size); diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index 574ab87c0a..0e3119b074 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -736,11 +736,12 @@ void TinyOsxGraphicsWindow::begin_flip() QDErr err; // 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 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() // Access: virtual, protected