1GLSTENCILOP(3G)                  OpenGL Manual                 GLSTENCILOP(3G)
2
3
4

NAME

6       glStencilOp - set front and back stencil test actions
7

C SPECIFICATION

9       void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
10

PARAMETERS

12       sfail
13           Specifies the action to take when the stencil test fails. Eight
14           symbolic constants are accepted: GL_KEEP, GL_ZERO, GL_REPLACE,
15           GL_INCR, GL_INCR_WRAP, GL_DECR, GL_DECR_WRAP, and GL_INVERT. The
16           initial value is GL_KEEP.
17
18       dpfail
19           Specifies the stencil action when the stencil test passes, but the
20           depth test fails.  dpfail accepts the same symbolic constants as
21           sfail. The initial value is GL_KEEP.
22
23       dppass
24           Specifies the stencil action when both the stencil test and the
25           depth test pass, or when the stencil test passes and either there
26           is no depth buffer or depth testing is not enabled.  dppass accepts
27           the same symbolic constants as sfail. The initial value is GL_KEEP.
28

DESCRIPTION

30       Stenciling, like depth-buffering, enables and disables drawing on a
31       per-pixel basis. You draw into the stencil planes using GL drawing
32       primitives, then render geometry and images, using the stencil planes
33       to mask out portions of the screen. Stenciling is typically used in
34       multipass rendering algorithms to achieve special effects, such as
35       decals, outlining, and constructive solid geometry rendering.
36
37       The stencil test conditionally eliminates a pixel based on the outcome
38       of a comparison between the value in the stencil buffer and a reference
39       value. To enable and disable the test, call glEnable() and glDisable()
40       with argument GL_STENCIL_TEST; to control it, call glStencilFunc() or
41       glStencilFuncSeparate().
42
43       There can be two separate sets of sfail, dpfail, and dppass parameters;
44       one affects back-facing polygons, and the other affects front-facing
45       polygons as well as other non-polygon primitives.  glStencilOp() sets
46       both front and back stencil state to the same values. Use
47       glStencilOpSeparate() to set front and back stencil state to different
48       values.
49
50       glStencilOp takes three arguments that indicate what happens to the
51       stored stencil value while stenciling is enabled. If the stencil test
52       fails, no change is made to the pixel's color or depth buffers, and
53       sfail specifies what happens to the stencil buffer contents. The
54       following eight actions are possible.
55
56       GL_KEEP
57           Keeps the current value.
58
59       GL_ZERO
60           Sets the stencil buffer value to 0.
61
62       GL_REPLACE
63           Sets the stencil buffer value to ref, as specified by
64           glStencilFunc().
65
66       GL_INCR
67           Increments the current stencil buffer value. Clamps to the maximum
68           representable unsigned value.
69
70       GL_INCR_WRAP
71           Increments the current stencil buffer value. Wraps stencil buffer
72           value to zero when incrementing the maximum representable unsigned
73           value.
74
75       GL_DECR
76           Decrements the current stencil buffer value. Clamps to 0.
77
78       GL_DECR_WRAP
79           Decrements the current stencil buffer value. Wraps stencil buffer
80           value to the maximum representable unsigned value when decrementing
81           a stencil buffer value of zero.
82
83       GL_INVERT
84           Bitwise inverts the current stencil buffer value.
85
86       Stencil buffer values are treated as unsigned integers. When
87       incremented and decremented, values are clamped to 0 and 2 n - 1, where
88       n is the value returned by querying GL_STENCIL_BITS.
89
90       The other two arguments to glStencilOp specify stencil buffer actions
91       that depend on whether subsequent depth buffer tests succeed (dppass)
92       or fail (dpfail) (see glDepthFunc()). The actions are specified using
93       the same eight symbolic constants as sfail. Note that dpfail is ignored
94       when there is no depth buffer, or when the depth buffer is not enabled.
95       In these cases, sfail and dppass specify stencil action when the
96       stencil test fails and passes, respectively.
97

NOTES

99       Initially the stencil test is disabled. If there is no stencil buffer,
100       no stencil modification can occur and it is as if the stencil tests
101       always pass, regardless of any call to glStencilOp.
102
103       glStencilOp() is the same as calling glStencilOpSeparate() with face
104       set to GL_FRONT_AND_BACK.
105

ERRORS

107       GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value
108       other than the defined constant values.
109

ASSOCIATED GETS

111       glGet() with argument GL_STENCIL_FAIL, GL_STENCIL_PASS_DEPTH_PASS,
112       GL_STENCIL_PASS_DEPTH_FAIL, GL_STENCIL_BACK_FAIL,
113       GL_STENCIL_BACK_PASS_DEPTH_PASS, GL_STENCIL_BACK_PASS_DEPTH_FAIL, or
114       GL_STENCIL_BITS
115
116       glIsEnabled() with argument GL_STENCIL_TEST
117

SEE ALSO

119       glBlendFunc(), glDepthFunc(), glEnable(), glLogicOp(), glStencilFunc(),
120       glStencilFuncSeparate(), glStencilMask(), glStencilMaskSeparate(),
121       glStencilOpSeparate()
122
124       Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
125       under the SGI Free Software B License. For details, see
126       http://oss.sgi.com/projects/FreeB/.
127

AUTHORS

129       opengl.org
130
131
132
133opengl.org                        06/10/2014                   GLSTENCILOP(3G)
Impressum