See if this helps you - Googled
http://www.idevgames.com/forums/thread-6400.html[
^]
Check this for code -
http://nehe.gamedev.net/data/articles/article.asp?article=13[
^]
I am copying the code from that link what you need, you are converting mouse (X,Y)
points to a space(X,Y,Z) GL coordinates -
CVector3 GetOGLPos(int x, int y)
{
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
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 CVector3(posX, posY, posZ);
}
Hope this helps...