glReadPixels Question

Started by
10 comments, last by Geometrian 16 years, 8 months ago
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

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Advertisement
What does your current function look like?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

I don't have one. I don't know how to make one, so that's my question.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

glReadPixelsb(x, y, 1, 1, GL_RGB) works. Thanks for looking, everyone.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

b == byte the -128->127 i think u perhaps want to use ub == unsigned byte which is 0->255
Where would I put that?
G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Instead of glReadPixelsb(x, y, 1, 1, GL_RGB) use glReadPixelsub(x, y, 1, 1, GL_RGB). :)
I see, but why would it make a difference?
G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

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.
That's weird, the function works exactly as it should, perhaps because I'm using Python?

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

This topic is closed to new replies.

Advertisement