Using Polygon Offsets for Efficient Object Translation
The PGONOFFS sample demonstrates the use of the polygon-offset call available
in OpenGL 1.1. Using this call, the depth values of the fragments generated by
the rasterization of the polygon may be shifted away or towards the origin,
as an affine function of the window coordinate depth slope of the polygon.
In this sample, a quadric (cylinder, sphere or disk) is drawn normally and
with a polygon-offset value. A trackball is used to view the object from
various angles, by dragging it with a mouse. Additionally, the following
key inputs are recognized:
Key Description
--- -----------
left/right Decrease/increase the units in the glPolygonOffset() call.
up/down Increase/decrease the factors in the glPolygonOffset() call.
a/A Decrease/increase the number of stacks in the quadric.
c Toggle on/off culling.
f Cycle through the various quadrics.
g/G Decrease/increase the radius of the quadric.
h/H Decrease/increase the height of the quadric.
i Set initial values for units and factors.
t Toggle on/off texturing.
z/Z Translate the object in Z.
1/2/3 Enable GL_POLYGON_OFFSET_FILL/GL_POLYGON_OFFSET_LINE/
GL_POLYGON_OFFSET_POINT.
0 Toggle on/off smooth shading.
Note
----
PGONOFFS will not run on an implementation of OpenGL version 1.0. The OpenGL
for Windows 95 redistributables included on the Win32 SDK are an
implementation of OpenGL version 1.0.