Edge of screen coordinates

Hi all - very simple question here.

I have a screen setup with
glviewport(0, 0, self.width, self.height)
gluPerspective(45.0, self.width/self.height, 0.1, 1000)

I want to draw a square at the top left of the screen (at -20 into the screen). I was under the impression that this could be acheived with the following:
Can someone please explain how the coordinate system works as you draw images further into the screen (decrease z), and how you can easily find the edge coordinates of the screen.


It works the same way as you draw a perspective drawing, object become smaller and moves to the center of the window when you move them away from the “viewer”.

You can use gluProject/gluUnproject to map between window coordinates and world coordinates.

If you don’t want the perspecive effect you can use orthographic projection instead of perspective in which case the object will not move or change size depending on Z value, but 3D objects will look a bit odd then of course.