Skip to main content
GameDev.net gamedev.net
🔒 Locked

Read framebuffer pixels without rendering on screen

Started by leonard2012 May 16, 2012 at 5:46 PM 2 replies 1.5k views
Original Post
leonard2012
leonard2012
I want to read out the color buffer into a memory block of my application in order to implement some features like showing a thumbnail view of the client area, or saving the rendering content of the client area as a disk image fiIe. Our current method is to first render the scene and then call glReadPixels().
However, there is an annoying issue with this method. In my application, there are usually several graphics layers shown in the client area and I need to create one thumbnail for each layer. With the above method, I have to render one graphics layer at a time and then call glReadPixels() to get the buffer pixels for the current layer. The visual result of repeating this two-step process looks like playing PowerPoint slides. So I want to know if there is a method via which I can disable rendering but still get the pixels? Just like press "Ctrl+Q" in Internet Explorer 9 to get thumbnail views for all web pages, without rendering these pages one by one.
Kacper Kuryllo
Kacper Kuryllo
I can think of three different approaches to do this. Well depending on what you need. I'm not 100% clear...

glReadBuffer is supposed to let you choose to either read from the FrontBuffer (screen) or the BackBuffer. I think this is what you're looking for.

Alternatively you could also just render to a texture and then display that on an object.

You may also just use glViewPort to define the rendering to a small area of the window so you don't even need to bother about reading pixels from buffers or dealing with textures. This approach isn't as flexible and you'd still need to use one of the others if you want to save the image. But it's probably the fastest...
leonard2012
leonard2012

I can think of three different approaches to do this. Well depending on what you need. I'm not 100% clear...

glReadBuffer is supposed to let you choose to either read from the FrontBuffer (screen) or the BackBuffer. I think this is what you're looking for.

Alternatively you could also just render to a texture and then display that on an object.

You may also just use glViewPort to define the rendering to a small area of the window so you don't even need to bother about reading pixels from buffers or dealing with textures. This approach isn't as flexible and you'd still need to use one of the others if you want to save the image. But it's probably the fastest...


Thanks, the first approach is simple to implement and it works. I will do some search on "render to texture" to see how to do it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.