the position of point

Could you please give me some idea about following codes:

Find the position of the points displayed in window coordinates with
the origin at the bottom left corner, and rounded to the nearest pixel.

void display ()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-2.5, 2.5, -2.5, 2.5, 4.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glBegin(GL_POINTS);
glVertex3f( 1.0, 0.0, 0.0 );
glEnd();
glRotatef(90.0, 0.0, 0.0, 1.0);
glBegin(GL_POINTS);
glVertex3f( 1.0, 0.0, 0.0 );
glEnd();
glFlush();
}
void main (int argc, char **argv)
{

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);

// GLUT general initialization
glutDisplayFunc(display);
glutMainLoop();
}

Ok, I started actually working through some of the calculations for you until I realized… You didn’t provide enough information. You need to know what’s passed to glViewport for the final steps of converting to window coordinates.

But, anyway, to at least attempt to help you out a bit…

Check the back of the Red book for the formula to calculate what the Projection matrix looks like after glFrustum. Appendix G has what you need.

For the Modelview matrix, that particular gluLookAt call is essentially equivalent to glTranslate(0, 0, -5), so you can also consult Appendix G to see what the modelview matrix looks like.

After you know what your Modelview and Projection matrices look like, you can go to the OpenGL 1.4 specification to find the formulas for calculating object coordinates to eye coordinates to normalized device coordinates to window coordinates. Section 2.10 is what you want. (OpenGL operation->Coordinate transformations)

Edit: If you’re not sure of the matrix multiplication operations Google is your friend.

[This message has been edited by Deiussum (edited 01-31-2003).]

Hi, buddy: I apprecite your help. I will try depending on your direction.