I am trying to use glReadPixels to determine the RGBA value of a single pixel. However, glReadPixels seems to return junk. Is there a better way to do this? Here’s my current code:

GLfloat pixels[4];
glReadPixels(center,center, 1, 1, GL_RGBA, GL_FLOAT, pixels); 

Thanks for any help!

Read pixels uses the current glReadBuffer setting. For double buffered pixelformats that’s the backbuffer. You probable want to read from GL_FRONT.
If the color buffer you read from is fixed point, using floating point target will scale the values to the range 0.0 to 1.0.
OpenGL’s coordinate system is bottom left. If "center"is in Windows’ coordinates you need to invert the y-value.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.