[read-pixels] don't flip data when reading from offscreen draw buffers

Since we do all offscreen rendering upside down (so that we can have the
origin for texture coordinates be the top left of textures for the cases
where offscreen draw buffers are bound to textures) we don't need to flip
data read back from an offscreen framebuffer before we we return it to the
user.
This commit is contained in:
Robert Bragg 2009-10-22 16:55:07 +01:00
parent 0f86470eef
commit 800d18bc19

View File

@ -793,6 +793,7 @@ cogl_read_pixels (int x,
CoglPixelFormat format,
guint8 *pixels)
{
CoglHandle draw_buffer;
int draw_buffer_height;
int rowstride = width * 4;
guint8 *temprow;
@ -804,7 +805,8 @@ cogl_read_pixels (int x,
temprow = g_alloca (rowstride * sizeof (guint8));
draw_buffer_height = _cogl_draw_buffer_get_height (_cogl_get_draw_buffer ());
draw_buffer = _cogl_get_draw_buffer ();
draw_buffer_height = _cogl_draw_buffer_get_height (draw_buffer);
/* The y co-ordinate should be given in OpenGL's coordinate system
so 0 is the bottom row */
@ -825,6 +827,11 @@ cogl_read_pixels (int x,
glReadPixels (x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
/* NB: All offscreen rendering is done upside down so there is no need
* to flip in this case... */
if (cogl_is_offscreen (draw_buffer))
return;
/* TODO: consider using the GL_MESA_pack_invert extension in the future
* to avoid this flip... */