Sign in to follow this  
salukin15

trouble with glReadPixels()

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this