mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
[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.
This commit is contained in:
parent
e4fe655521
commit
c2a982cf9c
@ -793,10 +793,9 @@ cogl_read_pixels (int x,
|
|||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
guint8 *pixels)
|
guint8 *pixels)
|
||||||
{
|
{
|
||||||
int viewport_height;
|
int draw_buffer_height;
|
||||||
int rowstride = width * 4;
|
int rowstride = width * 4;
|
||||||
guint8 *temprow;
|
guint8 *temprow;
|
||||||
CoglHandle draw_buffer;
|
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -805,12 +804,11 @@ cogl_read_pixels (int x,
|
|||||||
|
|
||||||
temprow = g_alloca (rowstride * sizeof (guint8));
|
temprow = g_alloca (rowstride * sizeof (guint8));
|
||||||
|
|
||||||
draw_buffer = _cogl_get_draw_buffer ();
|
draw_buffer_height = _cogl_draw_buffer_get_height (_cogl_get_draw_buffer ());
|
||||||
viewport_height = _cogl_draw_buffer_get_viewport_height (draw_buffer);
|
|
||||||
|
|
||||||
/* The y co-ordinate should be given in OpenGL's coordinate system
|
/* The y co-ordinate should be given in OpenGL's coordinate system
|
||||||
so 0 is the bottom row */
|
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
|
/* Setup the pixel store parameters that may have been changed by
|
||||||
Cogl */
|
Cogl */
|
||||||
|
Loading…
Reference in New Issue
Block a user