screen-grabber: Fix area screenshots

Our DBus API (and mostly every other API in existence) define an
area as the top-left corner and width/height; glReadPixels on the
other hand uses the bottom-left corner, so we have to transform the
coordinates before passing them to GL.

https://bugzilla.gnome.org/show_bug.cgi?id=670979
This commit is contained in:
Florian Müllner 2012-02-28 15:59:35 +01:00
parent feb33a6a28
commit ca612872a6

View File

@ -107,6 +107,7 @@ shell_screen_grabber_grab (ShellScreenGrabber *grabber,
GLubyte *mapped_data;
GLint old_swap_bytes, old_lsb_first, old_row_length, old_skip_pixels, old_skip_rows, old_alignment;
GLint old_pack_invert = GL_FALSE;
GLint vp_size[4];
guchar *src_row, *dest_row;
int i;
@ -165,6 +166,10 @@ shell_screen_grabber_grab (ShellScreenGrabber *grabber,
pf_glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, grabber->pixel_buffer);
}
/* In OpenGL, (x,y) specifies the bottom-left corner rather than the
* top-left */
glGetIntegerv (GL_VIEWPORT, vp_size);
y = vp_size[3] - (y + height);
glReadPixels (x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0);
mapped_data = pf_glMapBufferARB (GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);