glReadPixels problem
I'm trying to use glReadPixels to read the depth of the pixel at a particular window coordinate,
The problem that winZ is always 1.0
I'm calling the following code after rendering my scene. Any common errors anyone can think of? glGetError() returns GL_NO_ERROR
int winX = 400; // just for example
int winY = 300; // just for example
GLfloat winZ;
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
winY = viewport[3] - winY;
glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
Make sure
- you have a RC attached to a HDC (on Windows)
- you do some rendering before the query
- you have your zBuffer enabled
- you don't perform a SwapBuffers before the query
(or you have PFD_SWAP_COPY set)
- your viewport is at least 400x300 in size
- you have a RC attached to a HDC (on Windows)
- you do some rendering before the query
- you have your zBuffer enabled
- you don't perform a SwapBuffers before the query
(or you have PFD_SWAP_COPY set)
- your viewport is at least 400x300 in size
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement