Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Read framebuffer pixels without rendering on screen


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 16 May 2012 - 11:46 AM

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.

Sponsor:

#2 Batch2   Members   -  Reputation: 119

Like
0Likes
Like

Posted 16 May 2012 - 12:15 PM

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...

Edited by Batch2, 16 May 2012 - 12:16 PM.


#3 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 16 May 2012 - 08:37 PM

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.

#4 trotlinebeercan   Members   -  Reputation: 186

Like
0Likes
Like

Posted 22 May 2012 - 09:55 PM

Try using glCopyTexImage2D.

http://www.opengl.org/sdk/docs/man4/xhtml/glCopyTexImage2D.xml

You can specify which buffer to render into, then select said buffer for read operations, then copy directly into a texture.
The texture then can simply be drawn on a quad.
hopper.dustin@gmail.com




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS