PDA

View Full Version : Capturing screen, but offscreen.



davemar
06-30-2009, 08:01 AM
I'm new to OpenGL, so apologies if this is an obvious question.

I'm rending some graphics which I would like to convert to an image file (or just a memory buffer for now). I've worked out how to use glReadPixels to capture the visible window, but that has lots of drawbacks such as other windows in the way, and screen size limitations. I'd like to capture my rendering offscreen (i.e. so it doesn't get interfered with) and at my choice of resolution (e.g. something higher than my monitor can handle like 1920x1080). Is this possible?

ZbuffeR
06-30-2009, 09:09 AM
Yes it is possible, for this you need FBO :
http://www.opengl.org/wiki/GL_EXT_framebuffer_object_More_about_FBOs

Good tutorials on the topic :
http://www.gamedev.net/reference/programming/features/fbo1/
http://www.gamedev.net/reference/programming/features/fbo2/

davemar
07-02-2009, 12:59 AM
I must admit I'm struggling a little with understanding those. Has anyone got any example code of how FBOs can be used to grab images offscreen of what you are rendering?

ZbuffeR
07-02-2009, 01:13 AM
http://http.download.nvidia.com/develope...mebuffer_object (http://http.download.nvidia.com/developer/SDK/Individual_Samples/featured_samples.html#simple_framebuffer_object)

Those tutorials are pretty simple imho, and the spec page does provide code examples.
http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt

Can you be more specific about your problems ?

davemar
07-09-2009, 12:10 AM
In the end I approached from a slightly different angle. As I was going to involve Qt with my program, I found a QT example code called 'grabber' which does pretty much what I'm after. It gives a simple example usage of framebuffer object grabbing and render buffering. So now I can capture an image of my render of any size I like, independent of what being displayed on the screen.