Jump to content
  • Advertisement
Sign in to follow this  
salukin15

trouble with glReadPixels()

This topic is 3257 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
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
Sign in to follow this  

  • Advertisement
×

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!