problem of glReadPixels

related code is as below:

int ww = glutGet( (GLenum)GLUT_WINDOW_WIDTH );
int wh = glutGet( (GLenum)GLUT_WINDOW_HEIGHT );



glPixelStorei(GL_PACK_ALIGNMENT, 1);

The problem is:
because the image background is white, there should be a lot of pixels with value of r=65535,g=65535 and b=65535.
but actually, it is not. a lot of other values.

and, when I save this array to a file, for example, ppm image file, and then open it in photoshop, the rendering result is right.

It almost drive me mad!!!

help. and thanks a lot!!!

maybe you’re looking at your array while debugging. In this case the contents of your front buffer…is just your debugging window, not the actual image that would appear otherwise.

Are you sure you’re clearing the front color buffer and not the back color buffer? If you’re clearing the back buffer you’ll need to do glutSwapBuffers() before reading from the front buffer.


Thank you very much!

Actually, it is because I am working in debug mode.

thanks again!!!