An OpenGL® projection is the process and image resulting from the translation of three-dimensional (3D) objects to an aligned two-dimensional (2D) image that can be displayed on a screen. The word "projection" in computer graphics programming refers to the fact that 3D objects within a scene need to be mathematically moved, or projected, onto a virtual 2D surface so it can be shown on a flat display on a device. Although the entire sequence of events that take a 3D object and render it to a 2D surface can be called projection, the term also is more narrowly applied to the specific set of geometric transformations in the graphics pipeline that occurs as a step between other sets of transformations. The two specific types of OpenGL® projection modes that are available to programmers are perspective and orthographic.
The challenge of creating an OpenGL® projection is to take the data that comprise all the objects in a given scene and adjust it so that, when shown on a screen, the objects are consistent with the projection mode, viewing volume and virtual camera settings. The viewing volume is the visible area of a scene from the location of the viewer within the scene, or the eye position. Six numbers define the viewing volume, including the right, left, top and bottom distances from a virtual center of the viewing frame. Additionally, two values known as the near and far planes define the depth of the viewing volume. This volume defines what objects will be projected, while all other objects outside the volume will be ignored, or clipped so the non-visible portions are not evaluated.
The first mode of OpenGL® projection that can be employed is known as orthographic projection. In this mode, the coordinates of the objects within a scene are not adjusted for their distance from the viewer, or perspective. This means all objects are drawn in the same size no matter the distance from the viewer. This OpenGL® projection mode is most often used in 3D modeling programs, engineering design programs and applications that use 3D polygons to create 2D composite images and do not require accurate perspective.
The more commonly used OpenGL® projection mode is known as perspective projection. In perspective projection mode, the objects in a scene are scaled and positioned according to their distance from the viewer. This means objects that are more distant appear smaller. It also means that objects in the scene are adjusted so they slowly converge at a point on the viewing horizon known as the vanishing point. Perspective projection closely models how the real world appears and is used to create realistic renderings as opposed to technical ones.