OpenGL C bindings library: libGL.a
void glStencilOp(GLenum Fail, GLenum zFail, GLenum zPass)
Stenciling, like z-buffering, enables and disables drawing on a per-pixel basis. You draw into the stencil planes using GL drawing primitives, and then render geometry and images, using the stencil planes to mask out portions of the screen. Stenciling is typically used in multipass rendering algorithms to achieve special effects, such as decals, outlining, and constructive solid geometry rendering.
The stencil test conditionally eliminates a pixel based on the outcome of a comparison between the value in the stencil buffer and a reference value. The test is enabled with the glEnable and glDisable subroutine calls with the GL_STENCIL argument, and controlled with the glStencilFunc subroutine.
The glStencilOp subroutine takes three arguments that indicate what happens to the stored stencil value while stenciling is enabled. If the stencil test fails, no change is made to the pixel's color or depth buffers, and the Fail parameter specifies what happens to the stencil buffer contents. The six possible actions are as follows:
Stencil buffer values are treated as unsigned integers. When incremented and decremented, values are clamped to 0 and 2n-1, where n is the value returned by querying GL_STENCIL_BITS.
The other two arguments to glStencilOp specify stencil buffer actions should subsequent depth buffer tests succeed (the zPass parameter) or fail (the zFail parameter). (See the glDepthFunc for information about specifying the function used for depth buffer comparisons.) They are specified using the same six symbolic constants as the Fail parameter. Note that the zFail parameter is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, the Fail and zPass parameters specify stencil action when the stencil test fails and passes, respectively.
Initially the stencil test is disabled. If there is no stencil buffer, no stencil modification can occur and it is as if the stencil tests always pass, regardless of any call to the glStencilOp subroutine.
Associated gets for the glStencilOp subroutine are as follows. (See the glGet subroutine for more information.)
glGet with argument GL_STENCIL_FAIL
glGet with argument GL_STENCIL_PASS_DEPTH_PASS
glGet with argument GL_STENCIL_PASS_DEPTH_FAIL
glGet with argument GL_STENCIL_BITS
glIsEnabled with argument GL_STENCIL_TEST.
/usr/include/GL/gl.h | Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL. |
The glAlphaFunc subroutine, glBegin or glEnd subroutine, glBlendFunc subroutine, glDepthFunc subroutine, glEnable or glDisable subroutine, glLogicOp subroutine, glStencilFunc subroutine.