From 1e2d88e7891a02b26d0143e28788072e8731be6b Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 21 Oct 2009 23:24:28 +0100 Subject: [PATCH] [cogl_read_pixels] use buffer not viewport height to calculate y offset glReadPixel takes window coordinates not viewport coordinates so we shouldn't have been assuming that the viewport height == window height. --- clutter/cogl/cogl/cogl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index 8fdb36ff8..e2fd88d88 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -793,10 +793,9 @@ cogl_read_pixels (int x, CoglPixelFormat format, guint8 *pixels) { - int viewport_height; + int draw_buffer_height; int rowstride = width * 4; guint8 *temprow; - CoglHandle draw_buffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -805,12 +804,11 @@ cogl_read_pixels (int x, temprow = g_alloca (rowstride * sizeof (guint8)); - draw_buffer = _cogl_get_draw_buffer (); - viewport_height = _cogl_draw_buffer_get_viewport_height (draw_buffer); + draw_buffer_height = _cogl_draw_buffer_get_height (_cogl_get_draw_buffer ()); /* The y co-ordinate should be given in OpenGL's coordinate system so 0 is the bottom row */ - y = viewport_height - y - height; + y = draw_buffer_height - y - height; /* Setup the pixel store parameters that may have been changed by Cogl */