A Tutorial Tool for Understanding Viewing and Projection in OpenGL

© Thomas W. Rauber
with the collaboration of Thiago Oliveira dos Santos, Computer Engineering master student of the Universidade Federal do Espírito Santo, Vitória, Brazil.

VVV is tool that allows you to see the effects of changing viewing and projection parameters on seeing a scene.

Besides the usual OpenGL libraries GL, GLU and GLUT you need GLUI, a cross-platform programming interface for creating a user control interface to an OpenGL application. GLUI was written by Paul Rademacher and is now distributed at SourceForge.

Snapshots of the control and graphical output windows

User's Manual

The program opens two windows, the graphical output and the control panel. The graphical output window is separated into two vertical halves. The upper part shows the Principal View, i.e. what the camera sees. The lower part is what a second camera sees. Usually the second camera sees everything what the first camera sees (usually the object in the scene), plus the position of the first camera and also the viewing volume defined by the viewing and projection parameters of the first camera. The viewing volume is defined by six clipping planes. Everything inside the viewing volume is visible, everything outside invisible.

The definition of the viewing volume is controlled by the left column of the control panel (Camera 1). The first principal distinction is made between Orthographic Projection and Perspective Projection. If Perspective Projection is chosen (Orthografic checkbox not selected) two possible specifications for Perspective Projection can be given: "Perspective" and "Frustum". If "Perspective" is chosen then the system call gluPerspective( fovy, aspect, near, far ) to OpenGL is used to specify the parameters of the Perspective Projection. If "Frustum" is chosen then the system call glFrustum( left, right, bottom, top, near, far ) to OpenGL is used to specify the parameters of the Perspective Projection. From these two alternative system calls the Projection Matrix in OpenGL is calculated.

The viewing parameters of the scene, i.e. the relationship between eye coordinates and object coordinates are defined by the parameters of the system call of the GLU utility library gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz ), where eye* is the position of the camera (in object coordinates), center* is the focal point to which the camera is looking (in object coordinates) and the up* vector defines the direction which is considered "pointing upwards". From gluLookAt() the Modelview Matrix in OpenGL is calculated. Since the Modelview Matrix transforms from object coordinates to eye coordinates an equivalent effect to 'gluLookAt' could have been achieved by two rotations and one translation.

Exactly as for the principal view, the viewing and projection parameters can be specified for camera 2 (middle column of control panel).

Additional Features:

© Thomas W. Rauber