Hi guys,
I have a plane in perspective projection. When i click on the plane , I want to create a point on it on the fly. How do i accomplish this? This is what I have done so far...
Vector3 CPerspective::GetOglPos(int x , int y)
{
GLint iViewport[4] ;
GLdouble dModelViewMatrix[16] ;
GLdouble dProjectionMatrix[16] ;
GLfloat fWinX , fWinY , fWinZ ;
GLdouble dPosX , dPosY , dPosZ ;
glGetDoublev(GL_MODELVIEW_MATRIX , dModelViewMatrix) ;
glGetDoublev(GL_PROJECTION_MATRIX , dProjectionMatrix) ;
glGetIntegerv(GL_VIEWPORT , iViewport) ;
fWinX = (GLfloat)x ;
fWinY = (GLfloat)iViewport[3] - (GLfloat)y ;
glReadPixels(x , (int)fWinY , 1 , 1 , GL_DEPTH_COMPONENT , GL_FLOAT , &fWinZ) ;
gluUnProject(fWinX , fWinY , fWinZ , dModelViewMatrix , dProjectionMatrix , iViewport , &dPosX , &dPosY , &dPosZ) ;
return Vector3(dPosX , dPosY , dPosZ) ;
}
And I am using Visual Studio 6.0. Before passing the points, I use the function ScreenToClient() to get the point in the client coords.
Coudl anyone please tell me where i went wrong?



