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

NAME

6       glStencilFunc - set front and back function and reference value for
7       stencil testing
8

C SPECIFICATION

10       void glStencilFunc(GLenum func, GLint ref, GLuint mask);
11

PARAMETERS

13       func
14           Specifies the test function. Eight symbolic constants are valid:
15           GL_NEVER, GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL, GL_EQUAL,
16           GL_NOTEQUAL, and GL_ALWAYS. The initial value is GL_ALWAYS.
17
18       ref
19           Specifies the reference value for the stencil test.  ref is clamped
20           to the range 0 2 n - 1, where n is the number of bitplanes in the
21           stencil buffer. The initial value is 0.
22
23       mask
24           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

DESCRIPTION

29       Stenciling, like depth-buffering, enables and disables drawing on a
30       per-pixel basis. Stencil planes are first drawn into using GL drawing
31       primitives, then geometry and images are rendered using the stencil
32       planes to mask out portions of the screen. Stenciling is typically used
33       in 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
38       stencil 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() or
41       glStencilOpSeparate().
42
43       There can be two separate sets of func, ref, and mask parameters; one
44       affects back-facing polygons, and the other affects front-facing
45       polygons as well as other non-polygon primitives.  glStencilFunc() sets
46       both front and back stencil state to the same values. Use
47       glStencilFuncSeparate() to set front and back stencil state to
48       different values.
49
50       func is a symbolic constant that determines the stencil comparison
51       function. It accepts one of eight values, shown in the following list.
52       ref is an integer reference value that is used in the stencil
53       comparison. It is clamped to the range 0 2 n - 1, where n is the number
54       of bitplanes in the stencil buffer.  mask is bitwise ANDed with both
55       the reference value and the stored stencil value, with the ANDed values
56       participating in the comparison.
57
58       If stencil represents the value stored in the corresponding stencil
59       buffer location, the following list shows the effect of each comparison
60       function that can be specified by func. Only if the comparison succeeds
61       is the pixel passed through to the next stage in the rasterization
62       process (see glStencilOp()). All tests treat stencil values as unsigned
63       integers in the range 0 2 n - 1, where n is the number of bitplanes in
64       the stencil buffer.
65
66       The following values are accepted by func:
67
68       GL_NEVER
69           Always fails.
70
71       GL_LESS
72           Passes if ( ref & mask ) < ( stencil & mask ).
73
74       GL_LEQUAL
75           Passes if ( ref & mask ) <= ( stencil & mask ).
76
77       GL_GREATER
78           Passes if ( ref & mask ) > ( stencil & mask ).
79
80       GL_GEQUAL
81           Passes if ( ref & mask ) >= ( stencil & mask ).
82
83       GL_EQUAL
84           Passes if ( ref & mask ) = ( stencil & mask ).
85
86       GL_NOTEQUAL
87           Passes if ( ref & mask ) != ( stencil & mask ).
88
89       GL_ALWAYS
90           Always passes.
91

NOTES

93       Initially, the stencil test is disabled. If there is no stencil buffer,
94       no stencil modification can occur and it is as if the stencil test
95       always passes.
96
97       glStencilFunc() is the same as calling glStencilFuncSeparate() with
98       face set to GL_FRONT_AND_BACK.
99

ERRORS

101       GL_INVALID_ENUM is generated if func is not one of the eight accepted
102       values.
103

ASSOCIATED GETS

105       glGet() with argument GL_STENCIL_FUNC, GL_STENCIL_VALUE_MASK,
106       GL_STENCIL_REF, GL_STENCIL_BACK_FUNC, GL_STENCIL_BACK_VALUE_MASK,
107       GL_STENCIL_BACK_REF, or GL_STENCIL_BITS
108
109       glIsEnabled() with argument GL_STENCIL_TEST
110

SEE ALSO

112       glBlendFunc(), glDepthFunc(), glEnable(), glLogicOp(),
113       glStencilFuncSeparate(), glStencilMask(), glStencilMaskSeparate(),
114       glStencilOp(), glStencilOpSeparate()
115
117       Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
118       under the SGI Free Software B License. For details, see
119       http://oss.sgi.com/projects/FreeB/.
120

AUTHORS

122       opengl.org
123
124
125
126opengl.org                        06/10/2014                 GLSTENCILFUNC(3G)
Impressum