|
|
|
|
| |
Stenciling on the ATI Rage128 with
OpenGL
|
|
|
The Rage128StencilCap sample program uses stenciling and a user clip plane to perform basic constructive solid geometry on a convex 3D object. A user clip plane is used to clip the object and the stencil buffer is used to appropriately mask a "capping" polgon so that the object remains convex. Figure 1 shows Rage128StencilCap in action.
| |
|
|
|
| Figure 1 |
Figure 2 - stencil buffer
generated by torus in Figure 1.
|
| |
|
- There are several steps used in Rage128StencilCap to implement capping:
-
- Turn on the user clip plane.
- Render the FRONT faces of the object to be capped.
- Program the stencil operations to set the stencil buffer to 1 for pixels that pass the z test.
- Render the BACK faces of the object to be capped. This creates a stencil buffer like the one shown in Figure 2.
- Turn off the user clip plane.
- Program the stencil operations to reject pixels if the stencil buffer is not set to 1.
- Draw a polygon which is exactly co-planar with the user clip plane. This provides the cap.
- Program the stencil operations to reject pixels if the stencil buffer is not set to 0.
- Draw alpha blended polygon which is exactly co-planar with the user clip plane. This is just used to illustrate the location of the user clip plane and can be turned off with the 'p' key.
- Rage128StencilCap Controls
-
- Right mouse drag - Slide clip plane
- Left mouse drag - Rotate object
- O - Cycle through some convex objects
- S - Take snapshot of stencil buffer (into stencil.bmp)
- P - Toggle drawing alpha blended clip plane
- Left/Right Arrows - Change point of view
- [ESC] - Quit
Building and Running Rage128StencilCap
Please see the page Building OpenGL Samples.
Win32 Downloads
Project file, source, executable, and support files (56 kb)
Shared source and include files (31 kb)
|
| |
 |
|
|
|