Jump to content
• Advertisement

# glReadPixels Question

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

##### Share on other sites
Advertisement
What does your current function look like?

#### Share this post

##### Share on other sites
I don't have one. I don't know how to make one, so that's my question.

#### Share this post

##### Share on other sites
glReadPixelsb(x, y, 1, 1, GL_RGB) works. Thanks for looking, everyone.

#### Share this post

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

#### Share this post

##### Share on other sites
Where would I put that?
G

#### Share this 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

##### Share on other sites
I see, but why would it make a difference?
G

#### Share this 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

##### Share on other sites
That's weird, the function works exactly as it should, perhaps because I'm using Python?

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement
• ### Popular Tags

• Advertisement

• 11
• 19
• 12
• 34
• 9
• ### Forum Statistics

• Total Topics
631398
• Total Posts
2999838
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!