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.


glReadPixels and a Multiple Color Attachment FrameBuffer


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 BlueSpud   Members   -  Reputation: 446

Like
0Likes
Like

Posted 21 July 2014 - 09:55 AM

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.



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8275

Like
1Likes
Like

Posted 21 July 2014 - 10:00 AM

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


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 BlueSpud   Members   -  Reputation: 446

Like
0Likes
Like

Posted 21 July 2014 - 10:03 AM

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.



#4 Xycaleth   Members   -  Reputation: 1273

Like
1Likes
Like

Posted 21 July 2014 - 11:22 AM

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);




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