Graphics Reference
In-Depth Information
Table 11-2
Stencil Operations (continued)
Description
Stencil Function
(incrementing the maximum value will result
in a new stencil value of zero) or underflows
(decrementing zero will result in the maximum
stencil value)
GL_KEEP
Keep the current stencil value, effectively not
modifying the value for that pixel
GL_INVERT
Bit-wise invert the value in the stencil buffer
void glStencilOp (GLenum sfail , GLenum zfail ,
GLenum zpass )
void glStencilOpSeparate (GLenum face , GLenum sfail ,
GLenum zfail , GLenum zpass )
face specifies the face associated with the provided stencil function.
Valid values are GL_FRONT , GL_BACK , and GL_FRONT_AND_BACK
( glStencilOpSeparate only).
sfail specifies the operation applied to the stencil bits if the fragment
fails the stencil test. Valid values are GL_KEEP , GL_ZERO ,
GL_REPLACE , GL_INCR , GL_DECR , GL_INCR_WRAP ,
GL_DECR_WRAP , and GL_INVERT .
zfail specifies the operation applied when the fragment passes the
stencil test, but fails the depth test
zpass specifies the operation applied when the fragment passes both
the stencil and depth tests
The following example illustrates using glStencilFunc and glStencilOp
to control rendering in various parts of the viewport:
GLfloat vVertices[] =
{
−0.75f, 0.25f, 0.50f, // Quad #0
−0.25f, 0.25f, 0.50f,
−0.25f, 0.75f, 0.50f,
−0.75f, 0.75f, 0.50f,
(continues)
 
 
Search WWH ::




Custom Search