From 555e319c284445c520299b199caac0061c3cbd09 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 7 Dec 2004 06:53:06 +0000 Subject: [PATCH] ParasiteBuffer's default_display_region needs size; fix offscreen rendering for dx8/9 --- panda/src/display/parasiteBuffer.cxx | 1 + panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx | 6 +++++- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 8 ++++++-- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 8 ++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index 69a27c7459..b9f78e6d18 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -49,6 +49,7 @@ ParasiteBuffer(GraphicsOutput *host, const string &name, _x_size = x_size; _y_size = y_size; _has_size = true; + _default_display_region->compute_pixels(_x_size, _y_size); _is_valid = true; diff --git a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx index 49f37117a3..4527e1be88 100644 --- a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx +++ b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx @@ -268,6 +268,10 @@ DXGraphicsStateGuardian7(const FrameBufferProperties &properties) : _cur_read_pixel_buffer=RenderBuffer::T_front; set_color_clear_value(_color_clear_value); + + // DirectX drivers seem to consistently invert the texture when + // they copy framebuffer-to-texture. Ok. + _copy_texture_inverted = true; } //////////////////////////////////////////////////////////////////// @@ -3563,7 +3567,7 @@ copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) { nassertr(pb != NULL && dr != NULL, false); int xo, yo, w, h; - dr->get_region_pixels(xo, yo, w, h); + dr->get_region_pixels_i(xo, yo, w, h); // only handled simple case nassertr(xo == 0 && yo==0 && w == pb->get_xsize() && h == pb->get_ysize(), false); diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index d0824c999f..db69730769 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -396,6 +396,10 @@ DXGraphicsStateGuardian8(const FrameBufferProperties &properties) : _cur_read_pixel_buffer=RenderBuffer::T_front; set_color_clear_value(_color_clear_value); + + // DirectX drivers seem to consistently invert the texture when + // they copy framebuffer-to-texture. Ok. + _copy_texture_inverted = true; } //////////////////////////////////////////////////////////////////// @@ -3148,7 +3152,7 @@ copy_texture(Texture *tex, const DisplayRegion *dr) { HRESULT hr; int xo, yo, w, h; - dr->get_region_pixels(xo, yo, w, h); + dr->get_region_pixels_i(xo, yo, w, h); PixelBuffer *pb = tex->_pbuffer; pb->set_xsize(w); @@ -3240,7 +3244,7 @@ copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) { nassertr(pb != NULL && dr != NULL, false); int xo, yo, w, h; - dr->get_region_pixels(xo, yo, w, h); + dr->get_region_pixels_i(xo, yo, w, h); // only handled simple case nassertr(xo == 0 && yo==0 && w == pb->get_xsize() && h == pb->get_ysize(), false); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 7e612fb3a4..3aa0fc3937 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -396,6 +396,10 @@ DXGraphicsStateGuardian9(const FrameBufferProperties &properties) : _cur_read_pixel_buffer=RenderBuffer::T_front; set_color_clear_value(_color_clear_value); + + // DirectX drivers seem to consistently invert the texture when + // they copy framebuffer-to-texture. Ok. + _copy_texture_inverted = true; } //////////////////////////////////////////////////////////////////// @@ -3145,7 +3149,7 @@ copy_texture(Texture *tex, const DisplayRegion *dr) { HRESULT hr; int xo, yo, w, h; - dr->get_region_pixels(xo, yo, w, h); + dr->get_region_pixels_i(xo, yo, w, h); PixelBuffer *pb = tex->_pbuffer; pb->set_xsize(w); @@ -3242,7 +3246,7 @@ copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) { nassertr(pb != NULL && dr != NULL, false); int xo, yo, w, h; - dr->get_region_pixels(xo, yo, w, h); + dr->get_region_pixels_i(xo, yo, w, h); // only handled simple case nassertr(xo == 0 && yo==0 && w == pb->get_xsize() && h == pb->get_ysize(), false);