Drawing in 3 Dimensions

In a 3 dimensional scene objects closer to the viewpoint may obscure
objects further from the viewpoint.  To draw a realistic scene, hidden
surface removal must be performed to ensure that obscured parts of
objects are not visible.  Hidden surface removal is achieved through
the use of a depth buffer and depth testing.

When drawing occurs, a depth, or z-value, is associated with each pixel
and stored in the depth buffer.  A depth test is performed for each
vertex in the scene.  During a depth test, the depth buffer is checked
to see whether another vertex has previously been drawn that would
obscure the current vertex.  If so, the vertex is not drawn.

The tk command tkInitDisplayMode must be called to specify use of
the depth buffer.   Depth buffering must be enabled with the command 
glEnable.Before drawing a scene the depth buffer should be cleared with 
the command glClear.

By default OpenGL draws polygons in fill mode by filling in all the
pixels enclosed within the boundary, but they can also be drawn in line
mode as outlined polygons, or in point mode as points at the
vertices.  In OpenGL a polygon has a front and a back side.  Each side
can be drawn in the same mode or in different modes to allow cut-away
views of solid objects for example. 

The command glPolygonMode controls the drawing
mode for a polygon's front and back faces.  The parameter face
can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK;
mode can be GL_POINT, GL_LINE, or GL_FILL
to indicate whether the polygon should be drawn as points, outlined, or
filled.  By default, both the front and back faces are drawn filled.

A filled polygon can be solidly filled or stippled with a certain
pattern.  The stipple pattern must be defined using the command 
glPolygonStipple where the mask argument is a
pointer to a 32x32 bitmap that is interpreted as a mask of 0s and 1s.
A 1 indicates that the corresponding pixel in the polygon is drawn, and
0 that it is not.  The capability state variable
GL_POLYGON_STIPPLE must be enabled by the call glEnable
for stippling to occur. 

The command glCullFace indicates which polygons should be discarded
(culled) before they are converted to screen coordinates.  The
parameter mode is either GL_FRONT, GL_BACK, or
GL_FRONT_AND_BACK to indicate front-facing, back-facing, or all
polygons.  To take effect, the state variable for culling,
GL_CULL_FACE must be enabled.