• Advertisement
Sign in to follow this  

glReadPixels Question

This topic is 3853 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

Hi, I'm trying to use glReadPixels() to get the color of a single pixel at coordinates (x,y). I checked the documentation, but I couldn't find anything. So, can someone give me a few lines of code that returns data=(red, green, blue)? Thanks, Geometrian

Share this post


Link to post
Share on other sites
Advertisement
b == byte the -128->127 i think u perhaps want to use ub == unsigned byte which is 0->255

Share this post


Link to post
Share on other sites
Instead of glReadPixelsb(x, y, 1, 1, GL_RGB) use glReadPixelsub(x, y, 1, 1, GL_RGB). :)

Share this post


Link to post
Share on other sites
When you use the glReadPixelsb(x, y, 1, 1, GL_RGB) function it returns an array of signed bytes. I.E. the byte has a both positive and negative side ranging from -128 to 127 as mentioned before. But since standard RGB values range from 0 to 255 you would want to use the function that returns unsigned bytes which also range from 0 to 255.

Share this post


Link to post
Share on other sites
I don't know how your code looks like. But the bytes probably gets casted into unsigned bytes anyway when you store them.

IMHO, you should use glReadPixelsub(x, y, 1, 1, GL_RGB) anyway since it's probably unsigned bytes you want.

Share this post


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

  • Advertisement