1GLSTENCILFUNC(3G) GLSTENCILFUNC(3G)
2
3
4
6 glStencilFunc - set function and reference value for stencil testing
7
8
10 void glStencilFunc( GLenum func,
11 GLint ref,
12 GLuint mask )
13
14
16 func Specifies the test function. Eight tokens are valid: GL_NEVER,
17 GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL, GL_EQUAL, GL_NOTEQUAL,
18 and GL_ALWAYS. The initial value is GL_ALWAYS.
19
20 ref Specifies the reference value for the stencil test. ref is
21 clamped to the range [0,2n−1], where n is the number of bitplanes
22 in the stencil buffer. The initial value is 0.
23
24 mask Specifies a mask that is ANDed with both the reference value and
25 the stored stencil value when the test is done. The initial value
26 is all 1's.
27
29 Stenciling, like depth-buffering, enables and disables drawing on a
30 per-pixel basis. You draw into the stencil planes using GL drawing
31 primitives, then render geometry and images, using the stencil planes
32 to mask out portions of the screen. Stenciling is typically used in
33 multipass rendering algorithms to achieve special effects, such as
34 decals, outlining, and constructive solid geometry rendering.
35
36 The stencil test conditionally eliminates a pixel based on the outcome
37 of a comparison between the reference value and the value in the sten‐
38 cil buffer. To enable and disable the test, call glEnable and
39 glDisable with argument GL_STENCIL_TEST. To specify actions based on
40 the outcome of the stencil test, call glStencilOp.
41
42 func is a symbolic constant that determines the stencil comparison
43 function. It accepts one of eight values, shown in the following list.
44 ref is an integer reference value that is used in the stencil compari‐
45 son. It is clamped to the range [0,2n−1], where n is the number of
46 bitplanes in the stencil buffer. mask is bitwise ANDed with both the
47 reference value and the stored stencil value, with the ANDed values
48 participating in the comparison.
49
50 If stencil represents the value stored in the corresponding stencil
51 buffer location, the following list shows the effect of each comparison
52 function that can be specified by func. Only if the comparison suc‐
53 ceeds is the pixel passed through to the next stage in the rasteriza‐
54 tion process (see glStencilOp). All tests treat stencil values as
55 unsigned integers in the range [0,2n−1], where n is the number of bit‐
56 planes in the stencil buffer.
57
58 The following values are accepted by func:
59
60 GL_NEVER Always fails.
61
62 GL_LESS Passes if ( ref & mask ) < ( stencil & mask ).
63
64 GL_LEQUAL Passes if ( ref & mask ) ≤ ( stencil & mask ).
65
66 GL_GREATER Passes if ( ref & mask ) > ( stencil & mask ).
67
68 GL_GEQUAL Passes if ( ref & mask ) ≥ ( stencil & mask ).
69
70 GL_EQUAL Passes if ( ref & mask ) = ( stencil & mask ).
71
72 GL_NOTEQUAL Passes if ( ref & mask ) ≠ ( stencil & mask ).
73
74 GL_ALWAYS Always passes.
75
77 Initially, the stencil test is disabled. If there is no stencil buf‐
78 fer, no stencil modification can occur and it is as if the stencil test
79 always passes.
80
82 GL_INVALID_ENUM is generated if func is not one of the eight accepted
83 values.
84
85 GL_INVALID_OPERATION is generated if glStencilFunc is executed between
86 the execution of glBegin and the corresponding execution of glEnd.
87
89 glGet with argument GL_STENCIL_FUNC
90 glGet with argument GL_STENCIL_VALUE_MASK
91 glGet with argument GL_STENCIL_REF
92 glGet with argument GL_STENCIL_BITS
93 glIsEnabled with argument GL_STENCIL_TEST
94
96 glAlphaFunc(3G), glBlendFunc(3G), glDepthFunc(3G), glEnable(3G),
97 glIsEnabled(3G), glLogicOp(3G), glStencilOp(3G)
98
99
100
101 GLSTENCILFUNC(3G)