trouble with glReadPixels()

Started by
9 comments, last by Kambiz 14 years, 9 months ago
I am using glReadPixels() to read RGB values off the screen but all i get is zeros. Here is the code i am using GLfloat pixels[3]; GLfloat r,g,b; glReadPixels(x,y,1,1,GL_RGB,GL_FLOAT,(void*)pixels); r =pixels[0]; g =pixels[1]; b =pixels[2]; can someone tell me what is wrong with this.Thanks Salukin
Advertisement
Did you check for OpenGL errors, i.e. glGetError()?
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
no....how do i check for errors

See what glGetError() returns if you call it right after glReadPixels(...).

Have a look here http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
there is an error but i cant find a way to know exactly what the error is .....how do i print the exact error
ok i found it the error is "GL_INVALID_ENUM" any ideas what this means
ok i found it the error is due to the an invalid type, so i have changed the type the code is now

GLushort pixels[3];
GLfloat r,g,b;
glReadPixels(x,y,1,1,GL_RGB,GL_UNSIGNED_SHORT,pixels);

r =pixels[0];
g =pixels[1];
b =pixels[2];

There are no errors now but i am still getting zeros
I assume the pixel at position x,y isnt' black [smile].
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
it isn't black
ok i am getting colors now, but by my x and y are all wrong where should the origin be and what is the direction of the positive x and y axis

This topic is closed to new replies.

Advertisement