Next: 2.3.3 The Accumulation Buffer Up: 2.3 Ancillary Buffers Previous: 2.3.1 The Depth Buffer

2.3.2 The Stencil Buffer

Another buffer supported by OpenGL is the stencil buffer. Like the depth buffer, the stencil buffer can be used to eliminate certain pixels from being drawn. The stencil buffer acts in much the same way as a cardboard stencil used with a can of spray paint. You can ``draw'' values into the stencil buffer using the normal OpenGL rendering primitives. Then a stencil test can be defined and stenciling enabled.

One possible use of the stencil buffer is in a flight simulator. Imagine that the view outside the plane is to fit into an irregularly shaped windshield. The rendering of the view outside the plane should not interfere with the rendering of the instruments ``inside'' the cockpit. If the windshield area is drawn in the stencil buffer, then a stencil test can be set up to make sure the windshield view is only drawn where the windshield stencil has been drawn. There are many other uses for stencil buffers.


mjk@asd.sgi.com
Wed Oct 19 18:06:42 PDT 1994