Graphics Reference
In-Depth Information
using the operator provided. For example, to specify that the stencil test
passes where the lowest three bits of the stencil buffer are equal to 2, you
would call
glStencilFunc ( GL_EQUAL, 2, 0x7 );
and enable the stencil test. Note that in binary format, the last three bits
of 0x7 are 111 .
With the stencil test configured, you generally also need to let OpenGL
ES 3.0 know what to do with the values in the stencil buffer when the
stencil test passes. In fact, modifying the values in the stencil buffer
relies on more than just the stencil tests, but also incorporates the
results of the depth test (discussed in the next section). Three possible
outcomes can occur for a fragment with the combined stencil and
depth tests:
1.
The fragment fails the stencil tests. If this occurs, no further testing
(i.e., the depth test) is applied to that fragment.
2.
The fragment passes the stencil test, but fails the depth test.
3.
The fragment passes both the stencil and depth tests.
Each of those possible outcomes can be used to affect the value
in the stencil buffer for that pixel location. The glStencilOp and
glStencilOpSeparate functions control the actions done on the stencil
buffer's value for each of those test outcomes, and the possible operations
on the stencil values are shown in Table 11-2.
Table 11-2
Stencil Operations
Description
Stencil Function
GL_ZERO
Set the stencil value to zero
GL_REPLACE
Replace the current stencil value with the
reference value specified in glStencilFunc
or glStencilFuncSeparate
GL_INCR, GL_DECR
Increment or decrement the stencil value; the
stencil value is clamped to zero or 2 n , where n is
the number of bits in the stencil buffer
GL_INCR_WRAP ,
GL_DECR_WRAP
Increment or decrement the stencil value, but
“wrap” the value if the stencil value overflows
 
 
Search WWH ::




Custom Search