• Advertisement
Sign in to follow this  

trouble with glReadPixels()

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

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

Share this post


Link to post
Share on other sites
Advertisement
there is an error but i cant find a way to know exactly what the error is .....how do i print the exact error

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Read the documentation
Quote:
x, y Specify the window coordinates of the first pixel that is read from the frame buffer. This location is the lower left corner of a rectangular block of pixels.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement