fix for inverted screenshot

This commit is contained in:
David Rose 2008-08-13 18:27:33 +00:00
parent 75de7a30c9
commit 07c2787a39
4 changed files with 46 additions and 11 deletions

View File

@ -1420,7 +1420,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
if (tex->get_texture_type() != Texture::TT_2d_texture) {
// For a specialty texture like a cube map, go the slow route
// through RAM for now.
return framebuffer_copy_to_ram(tex, z, dr, rb);
return do_framebuffer_copy_to_ram(tex, z, dr, rb, true);
}
nassertr(dtc->get_d3d_2d_texture() != NULL, false);
@ -1501,7 +1501,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
if (!okflag) {
// The copy failed. Fall back to copying it to RAM and back.
// Terribly slow, but what are you going to do?
return framebuffer_copy_to_ram(tex, z, dr, rb);
return do_framebuffer_copy_to_ram(tex, z, dr, rb, true);
}
return true;
@ -1520,6 +1520,21 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
////////////////////////////////////////////////////////////////////
bool DXGraphicsStateGuardian8::
framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb) {
return do_framebuffer_copy_to_ram(tex, z, dr, rb, false);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::do_framebuffer_copy_to_ram
// Access: Public
// Description: This is the implementation of
// framebuffer_copy_to_ram(); it adds one additional
// parameter, which should be true if the framebuffer is
// to be inverted during the copy (as in the same way it
// copies to texture memory).
////////////////////////////////////////////////////////////////////
bool DXGraphicsStateGuardian8::
do_framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb, bool inverted) {
set_read_buffer(rb);
RECT rect;
@ -1603,7 +1618,7 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr, const Rend
return false;
}
// copy_inverted = true;
copy_inverted = true;
RELEASE(backbuffer, dxgsg8, "backbuffer", RELEASE_ONCE);
@ -1647,8 +1662,6 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr, const Rend
return false;
}
// For some reason the front buffer comes out inverted, but the
// back buffer does not.
copy_inverted = true;
} else {
@ -1658,6 +1671,9 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr, const Rend
return false;
}
if (inverted) {
copy_inverted = !copy_inverted;
}
DXTextureContext8::d3d_surface_to_texture(rect, temp_surface,
copy_inverted, tex, z);

View File

@ -98,6 +98,8 @@ public:
const RenderBuffer &rb);
virtual bool framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb);
bool do_framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb, bool inverted);
virtual void reset();

View File

@ -2074,7 +2074,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
if (tex->get_texture_type() != Texture::TT_2d_texture) {
// For a specialty texture like a cube map, go the slow route
// through RAM for now.
return framebuffer_copy_to_ram(tex, z, dr, rb);
return do_framebuffer_copy_to_ram(tex, z, dr, rb, true);
}
nassertr(dtc->get_d3d_2d_texture() != NULL, false);
@ -2172,7 +2172,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
if (!okflag) {
// The copy failed. Fall back to copying it to RAM and back.
// Terribly slow, but what are you going to do?
return framebuffer_copy_to_ram(tex, z, dr, rb);
return do_framebuffer_copy_to_ram(tex, z, dr, rb, true);
}
return true;
@ -2192,6 +2192,21 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
bool DXGraphicsStateGuardian9::
framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb) {
return do_framebuffer_copy_to_ram(tex, z, dr, rb, false);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::do_framebuffer_copy_to_ram
// Access: Public
// Description: This is the implementation of
// framebuffer_copy_to_ram(); it adds one additional
// parameter, which should be true if the framebuffer is
// to be inverted during the copy (as in the same way it
// copies to texture memory).
////////////////////////////////////////////////////////////////////
bool DXGraphicsStateGuardian9::
do_framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb, bool inverted) {
set_read_buffer(rb);
RECT rect;
@ -2291,7 +2306,7 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
return false;
}
// copy_inverted = true;
copy_inverted = true;
RELEASE(backbuffer, dxgsg9, "backbuffer", RELEASE_ONCE);
@ -2339,8 +2354,6 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
return false;
}
// For some reason the front buffer comes out inverted, but the
// back buffer does not.
copy_inverted = true;
} else {
@ -2350,7 +2363,9 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
return false;
}
copy_inverted = false;
if (inverted) {
copy_inverted = !copy_inverted;
}
DXTextureContext9::d3d_surface_to_texture(rect, temp_surface,
copy_inverted, tex, z);

View File

@ -138,6 +138,8 @@ public:
const RenderBuffer &rb);
virtual bool framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb);
bool do_framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
const RenderBuffer &rb, bool inverted);
void reset_render_states (void);
virtual void reset();