NAME
glStencilFunc
- set function and reference value for stencil testing
delim $$
C SPECIFICATION
void ggllSStteenncciillFFuunncc(
GLenum _f_u_n_c,
GLint _r_e_f,
GLuint _m_a_s_k )
PARAMETERS
-
_f_u_n_c
-
Specifies the test function.
Eight tokens are valid:
GGLL__NNEEVVEERR,
GGLL__LLEESSSS,
GGLL__LLEEQQUUAALL,
GGLL__GGRREEAATTEERR,
GGLL__GGEEQQUUAALL,
GGLL__EEQQUUAALL,
GGLL__NNOOTTEEQQUUAALL, and
GGLL__AALLWWAAYYSS. The initial value is GGLL__AALLWWAAYYSS.
-
_r_e_f
-
Specifies the reference value for the stencil test.
_r_e_f is clamped to the range [0,$2 sup n - 1$],
where $n$ is the number of bitplanes in the stencil buffer. The
initial value is 0.
-
_m_a_s_k
-
Specifies a mask that is ANDed with both the reference value
and the stored stencil value when the test is done. The initial value
is all 1's.
DESCRIPTION
Stenciling,
like depth-buffering,
enables and disables drawing on a per-pixel basis.
You draw into the stencil planes using GL drawing primitives,
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 reference value
and the value in the stencil buffer.
To enable and disable the test, call ggllEEnnaabbllee and ggllDDiissaabbllee
with argument GGLL__SSTTEENNCCIILL__TTEESSTT.
To specify actions based on the outcome of the stencil test, call
ggllSStteenncciillOOpp.
_f_u_n_c is a symbolic constant that determines the stencil comparison function.
It accepts one of eight values,
shown in the following list.
_r_e_f is an integer reference value that is used in the stencil comparison.
It is clamped to the range [0,$2 sup n - 1$],
where $n$ is the number of bitplanes in the stencil buffer.
_m_a_s_k is bitwise ANDed with both the reference value
and the stored stencil value,
with the ANDed values participating in the comparison.
If _s_t_e_n_c_i_l represents the value stored in the corresponding
stencil buffer location,
the following list shows the effect of each comparison function
that can be specified by _f_u_n_c.
Only if the comparison succeeds is the pixel passed through
to the next stage in the rasterization process
(see ggllSStteenncciillOOpp).
All tests treat _s_t_e_n_c_i_l values as unsigned integers in the range
[0,$2 sup n - 1$],
where $n$ is the number of bitplanes in the stencil buffer.
The following values are accepted by _f_u_n_c:
-
GGLL__NNEEVVEERR
-
Always fails.
-
GGLL__LLEESSSS
-
Passes if ( _r_e_f & _m_a_s_k ) < ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__LLEEQQUUAALL
-
Passes if ( _r_e_f & _m_a_s_k ) <= ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__GGRREEAATTEERR
-
Passes if ( _r_e_f & _m_a_s_k ) > ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__GGEEQQUUAALL
-
Passes if ( _r_e_f & _m_a_s_k ) >= ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__EEQQUUAALL
-
Passes if ( _r_e_f & _m_a_s_k ) = ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__NNOOTTEEQQUUAALL
-
Passes if ( _r_e_f & _m_a_s_k ) != ( _s_t_e_n_c_i_l & _m_a_s_k ).
-
GGLL__AALLWWAAYYSS
-
Always passes.
NOTES
Initially, the stencil test is disabled.
If there is no stencil buffer,
no stencil modification can occur and it is as if
the stencil test always passes.
ERRORS
GGLL__IINNVVAALLIIDD__EENNUUMM is generated if _f_u_n_c is not one of the eight
accepted values.
GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if ggllSStteenncciillFFuunncc
is executed between the execution of ggllBBeeggiinn
and the corresponding execution of ggllEEnndd.
ASSOCIATED GETS
ggllGGeett with argument GGLL__SSTTEENNCCIILL__FFUUNNCC
ggllGGeett with argument GGLL__SSTTEENNCCIILL__VVAALLUUEE__MMAASSKK
ggllGGeett with argument GGLL__SSTTEENNCCIILL__RREEFF
ggllGGeett with argument GGLL__SSTTEENNCCIILL__BBIITTSS
ggllIIssEEnnaabblleedd with argument GGLL__SSTTEENNCCIILL__TTEESSTT
SEE ALSO
ggllAAllpphhaaFFuunncc((33GG)),
ggllBBlleennddFFuunncc((33GG)),
ggllDDeepptthhFFuunncc((33GG)),
ggllEEnnaabbllee((33GG)),
ggllIIssEEnnaabblleedd((33GG)),
ggllLLooggiiccOOpp((33GG)),
ggllSStteenncciillOOpp((33GG))