GNOME Bugzilla – Bug 670979
screen-grabber: Fix area screenshots
Last modified: 2012-03-02 10:51:28 UTC
Follow-up fix for bug 669366 - see patch. OpenGL makes me cry ...
Created attachment 208587 [details] [review] 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.
Review of attachment 208587 [details] [review]: ::: src/shell-screen-grabber.c @@ +170,3 @@ + * top-left */ + glGetIntegerv (GL_VIEWPORT, &vp_size); + y = vp_size[3] - vp_size[1] /* buffer height */ - height - y; from 'man glGetInteger' GL_VIEWPORT params returns four values: the x and y window coordinates of the viewport, followed by its width and height. Initially the x and y window coordinates are both set to 0, and the width and height are set to the width and height of the window into which the GL will do its rendering. See glViewport. So, vp_size[3] - vp_size[1] is definitely not 'buffer height'. You are making an implicit assumption here that the viewport hasn't been changed from the original value or this would be invalid (glReadPixels doesn't care about the size of the viewport), so you probably just want: y = vp_size[3] - (y + height);
Created attachment 208614 [details] [review] screen-grabber: Fix area screenshots (In reply to comment #2) > from 'man glGetInteger' > > GL_VIEWPORT params returns four values: the x and y > window coordinates of the viewport, followed by its width and > height. Initially the x and y window > coordinates are both set to 0, and the width and height are set to > the width and height of the window into which > the GL will do its rendering. See glViewport. Gah, you're right - sorry, only read `man glReadPixels` :(
Review of attachment 208614 [details] [review]: Looks good.
Attachment 208614 [details] pushed as ca61287 - screen-grabber: Fix area screenshots