• Advertisement
Sign in to follow this  

glReadPixels and a Multiple Color Attachment FrameBuffer

This topic is 1277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,

So I want to implement a color picking system into my engine. I am using deferred rendering, so Im at a bit of an advantage because I don't have to render the scene twice. Right now what Im doing is rendering the number of the object in an array to an attachment in my GBuffer. However, glReadPixels reads from the back buffer, according to what I've read. The identifier attachment isn't the first attachment, so it doesn't read it. Im not really sure how I can make this read from my GBuffer attachment. Any help or input is appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement

Use glCopyTexImage2D instead.  Alternatively, specify the texture object once-only and then use glCopyTexSubImage2D.

But I still have to set the read buffer, correct? I still downy know how to do that for a frame buffer with multiple attachments.

Share this post


Link to post
Share on other sites
With glCopyTexImage you would copy from the texture that's attached to your framebuffer. So no, you don't need to set the read buffer; you bind the texture you want to read from :)

If you wanted to use glReadPixels with a framebuffer attachment other than the first, then glReadBuffer is what you're looking for. For example, glReadBuffer(GL_COLOR_ATTACHMENT1);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement