OpenGL Functions Used in This Tutorial

The first step in "taking a picture" of the modeled world is to establish the virtual camera. We use the following OpenGL function to accomplish this.

gluLookAt(eyeX, eyeY, eyeZ,
          centerX, centerY, centerZ,
          upX, upY, upZ); 

where the coordinates eyeX, eyeY, eyeZ and the coordinates centerX, centerY, centerZ are respectively the location of the virtual camera and the place were the camera is pointing (also called the look-at-point). The line (vector) going from the eye-point to the look-at-point is sometimes called the line of sight. The coordinates upX, upY and upZ establish the up vector and, in turn, the roll of the camera about the line of sight. Portrait, landscape and any orientation inbetween is created through changes in the up vector.

Besides thinking of a virtual camera, we should note that the function gluLookAt establishes what is called the viewing coordinate system. "Taking a picture" means computationally transforming the objects defined in world coordinates to those defined in viewing coordinates, sometimes called eye coordinates. OpenGL handles a call to gluLookAt by placing the viewing transformation matrix on the MODEL_VIEW stack.

The next thing we must consider after establishing the viewing transformation is projecting the world onto a virtual screen. We use one of the three functions glOrtho, gluPerspective or glFrustum for setting the projection method.

glOrtho(GLdouble left,   GLdouble right,
        GLdouble bottom, GLdouble top,
        GLdouble near,   GLdouble far);

The parameters establish the view-volume, which is a rectangular box. Left and right define the left and right sides of the view-volume while bottom and top define the bottom and top sides of the box. Near and far establish the locations of the nearer and farther sides of the view-volume with respect to the viewer. Objects within the view-volume (or portions thereof) will appear in the projected image, while those outside the box are clipped and do not appear in the image. Due to their purposes, the sides of the view-volume are called clipping planes. Last, orthographic projection is a form of parallel projection and perserves angles and line lengths.

gluPerspective(GLdouble angle, GLdouble aspect,
               GLdouble near,  GLdouble far);

The view-volume established by this function is a truncated pyramid where the apex of the pyramid is at the eye-point. Near is the distance from the eye-point to the near clipping plane, the plane that truncates the pyramid while far is the distance from the eye-point to the base of the pyramid and the far clipping plane. Angle is given in degrees and establishes the field of view in the vertical (y) direction. Aspect establishes the field of view in the horizonal (x) direction. The aspect is the ratio of the width of the pyramid to the height of the pyramid at its base.

glFrustum(GLdouble left,   GLdouble right,
          GLdouble bottom, GLdouble top,
          GLdouble near,   GLdouble far);

This function is an alternative for obtaining perspective projection. The view-volume established by this method is also a truncated pyramid with the apex of the pyramid at the eye-point. Near and far have the same meanings as in a call to gluPerspective and establish the locations of the near and far clipping planes relative to the eye point. Left, right, bottom and top define the locations of the sides of the near clipping plane and, in turn, are displacements from the line-of-sight. In turn, left, right, bottom and top along with the distance between the eye-point and the near plane establish the clipping planes along the sides of the pyramid.