Actually, you have a function called gluProject that will do exactly that for you… It implements what jmX described except that it also takes the viewport into account (yes, you need it !).

So, if you want to use it:

GLdouble modelMatrix[16],projMatrix[16];

GLint viewport[4];

GLdouble winx,winy,winz; // Coordinates of the projected point on the screen //

glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix);

glGetDoublev(GL_PROJECTION_MATRIX,projMatrix);

glGetIntegerv(GL_VIEWPORT,viewport);

gluProject(x1,y1,z1,modelMatrix,projMatrix,viewport,&winx,&winy,&winz);

Where x1,y1,z1 are the coordinates of the point to project…

Best regards.

Eric