Sign in to follow this  
Geometrian

glReadPixels Question

Recommended Posts

Geometrian    1810
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
Redien    122
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
Redien    122
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this