gluOrtho2D
setup an Orthographic projection matrix, with a given left, right, top and bottom, but a fixed near and far plane of -1 respectively 1.
gluOrtho2D( left, right, bottom, top );
This means that
gluOrtho2D(0,640,480,0)
creates a projection matrix, which maps 0 to the left border of the viewport, 640 to the right, 480 to the bottom and 0 to the top.
The values for left, right, bottom, top, near and far define a box. All the geometry which is inside the volume of the box is "visible" on the viewport.
The projection matrix describes the mapping from 3D points of a scene, to 2D points of the viewport. It transforms from eye space to the clip space, and the coordinates in the clip space are transformed to the normalized device coordinates (NDC) by dividing with the w
component of the clip coordinates. The NDC are in range (-1,-1,-1) to (1,1,1).
Every geometry which is out of the clippspace is clipped.
At Orthographic Projection the coordinates in the eye space are linearly mapped to normalized device coordinates and the clip space coordinates are equal the normalized device coordinates, because the w
component is 1 (for a Cartesian coordinate).
Orthographic Projection Matrix:
r = right, l = left, b = bottom, t = top, n = near, f = far
2/(r-l) 0 0 0
0 2/(t-b) 0 0
0 0 -2/(f-n) 0
-(r+l)/(r-l) -(t+b)/(t-b) -(f+n)/(f-n) 1