I have doing a projection from screen coordinate to 3D world space, but I have some problem in glReadPixels function… the code goes like this:

GLfloat winX, winY, winZ;

GLdouble posX, posY, posZ;

glGetDoublev( GL_MODELVIEW_MATRIX, modelview );

glGetDoublev( GL_PROJECTION_MATRIX, projection );

glGetIntegerv( GL_VIEWPORT, viewport );

winX = (float)x;

winY = (float)viewport[3] - (float)y;

glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );

gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);

return Vector(posX, posY, posZ);

the problem is that I am not able to get ‘winz’ value from glReadPixels(), I have checked my code by debugging it, but was not able to find out the reason…

so plzzzzzzzz help me out from this…