trouble with glReadPixels()
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
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.
Have a look here http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml.
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 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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement