1GLSTENCILOP(3G) GLSTENCILOP(3G)
2
3
4
6 glStencilOp - set stencil test actions
7
8
10 void glStencilOp( GLenum fail,
11 GLenum zfail,
12 GLenum zpass )
13
14
16 fail Specifies the action to take when the stencil test fails. Six
17 symbolic constants are accepted: GL_KEEP, GL_ZERO, GL_REPLACE,
18 GL_INCR, GL_DECR, and GL_INVERT. The initial value is GL_KEEP.
19
20 zfail Specifies the stencil action when the stencil test passes, but
21 the depth test fails. zfail accepts the same symbolic constants
22 as fail. The initial value is GL_KEEP.
23
24 zpass Specifies the stencil action when both the stencil test and the
25 depth test pass, or when the stencil test passes and either
26 there is no depth buffer or depth testing is not enabled. zpass
27 accepts the same symbolic constants as fail. The initial value
28 is GL_KEEP.
29
31 Stenciling, like depth-buffering, enables and disables drawing on a
32 per-pixel basis. You draw into the stencil planes using GL drawing
33 primitives, then render geometry and images, using the stencil planes
34 to mask out portions of the screen. Stenciling is typically used in
35 multipass rendering algorithms to achieve special effects, such as
36 decals, outlining, and constructive solid geometry rendering.
37
38 The stencil test conditionally eliminates a pixel based on the outcome
39 of a comparison between the value in the stencil buffer and a reference
40 value. To enable and disable the test, call glEnable and glDisable with
41 argument GL_STENCIL_TEST; to control it, call glStencilFunc.
42
43 glStencilOp takes three arguments that indicate what happens to the
44 stored stencil value while stenciling is enabled. If the stencil test
45 fails, no change is made to the pixel's color or depth buffers, and
46 fail specifies what happens to the stencil buffer contents. The fol‐
47 lowing six actions are possible.
48
49 GL_KEEP Keeps the current value.
50
51 GL_ZERO Sets the stencil buffer value to 0.
52
53 GL_REPLACE Sets the stencil buffer value to ref, as specified by
54 glStencilFunc.
55
56 GL_INCR Increments the current stencil buffer value. Clamps to
57 the maximum representable unsigned value.
58
59 GL_DECR Decrements the current stencil buffer value. Clamps to
60 0.
61
62 GL_INVERT Bitwise inverts the current stencil buffer value.
63
64 Stencil buffer values are treated as unsigned integers. When incre‐
65 mented and decremented, values are clamped to 0 and 2n−1, where n is
66 the value returned by querying GL_STENCIL_BITS.
67
68 The other two arguments to glStencilOp specify stencil buffer actions
69 that depend on whether subsequent depth buffer tests succeed (zpass) or
70 fail (zfail) (see
71 glDepthFunc). The actions are specified using the same six symbolic
72 constants as fail. Note that zfail is ignored when there is no depth
73 buffer, or when the depth buffer is not enabled. In these cases, fail
74 and zpass specify stencil action when the stencil test fails and
75 passes, respectively.
76
78 Initially the stencil test is disabled. If there is no stencil buffer,
79 no stencil modification can occur and it is as if the stencil tests
80 always pass, regardless of any call to glStencilOp.
81
83 GL_INVALID_ENUM is generated if fail, zfail, or zpass is any value
84 other than the six defined constant values.
85
86 GL_INVALID_OPERATION is generated if glStencilOp is executed between
87 the execution of glBegin and the corresponding execution of glEnd.
88
90 glGet with argument GL_STENCIL_FAIL
91 glGet with argument GL_STENCIL_PASS_DEPTH_PASS
92 glGet with argument GL_STENCIL_PASS_DEPTH_FAIL
93 glGet with argument GL_STENCIL_BITS
94 glIsEnabled with argument GL_STENCIL_TEST
95
97 glAlphaFunc(3G), glBlendFunc(3G), glDepthFunc(3G), glEnable(3G),
98 glLogicOp(3G), glStencilFunc(3G)
99
100
101
102 GLSTENCILOP(3G)