Commit | Line | Data |
---|---|---|
7faf1d71 AW |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd"> | |
4 | <refentry id="glStencilOp"> | |
5 | <refmeta> | |
6 | <refmetainfo> | |
7 | <copyright> | |
8 | <year>1991-2006</year> | |
9 | <holder>Silicon Graphics, Inc.</holder> | |
10 | </copyright> | |
11 | </refmetainfo> | |
12 | <refentrytitle>glStencilOp</refentrytitle> | |
13 | <manvolnum>3G</manvolnum> | |
14 | </refmeta> | |
15 | <refnamediv> | |
16 | <refname>glStencilOp</refname> | |
17 | <refpurpose>set front and back stencil test actions</refpurpose> | |
18 | </refnamediv> | |
19 | <!-- eqn: ignoring delim $$ --> | |
20 | <refsynopsisdiv><title>C Specification</title> | |
21 | <funcsynopsis> | |
22 | <funcprototype> | |
23 | <funcdef>void <function>glStencilOp</function></funcdef> | |
24 | <paramdef>GLenum <parameter>sfail</parameter></paramdef> | |
25 | <paramdef>GLenum <parameter>dpfail</parameter></paramdef> | |
26 | <paramdef>GLenum <parameter>dppass</parameter></paramdef> | |
27 | </funcprototype> | |
28 | </funcsynopsis> | |
29 | </refsynopsisdiv> | |
30 | <refsect1 id="parameters"><title>Parameters</title> | |
31 | <variablelist> | |
32 | <varlistentry> | |
33 | <term><parameter>sfail</parameter></term> | |
34 | <listitem> | |
35 | <para> | |
36 | Specifies the action to take when the stencil test fails. | |
37 | Eight symbolic constants are accepted: | |
38 | <constant>GL_KEEP</constant>, | |
39 | <constant>GL_ZERO</constant>, | |
40 | <constant>GL_REPLACE</constant>, | |
41 | <constant>GL_INCR</constant>, | |
42 | <constant>GL_INCR_WRAP</constant>, | |
43 | <constant>GL_DECR</constant>, | |
44 | <constant>GL_DECR_WRAP</constant>, and | |
45 | <constant>GL_INVERT</constant>. The initial value is <constant>GL_KEEP</constant>. | |
46 | </para> | |
47 | </listitem> | |
48 | </varlistentry> | |
49 | <varlistentry> | |
50 | <term><parameter>dpfail</parameter></term> | |
51 | <listitem> | |
52 | <para> | |
53 | Specifies the stencil action when the stencil test passes, | |
54 | but the depth test fails. | |
55 | <parameter>dpfail</parameter> accepts the same symbolic constants as <parameter>sfail</parameter>. The initial value | |
56 | is <constant>GL_KEEP</constant>. | |
57 | </para> | |
58 | </listitem> | |
59 | </varlistentry> | |
60 | <varlistentry> | |
61 | <term><parameter>dppass</parameter></term> | |
62 | <listitem> | |
63 | <para> | |
64 | Specifies the stencil action when both the stencil test and the depth | |
65 | test pass, or when the stencil test passes and either there is no | |
66 | depth buffer or depth testing is not enabled. | |
67 | <parameter>dppass</parameter> accepts the same symbolic constants as <parameter>sfail</parameter>. The initial value | |
68 | is <constant>GL_KEEP</constant>. | |
69 | </para> | |
70 | </listitem> | |
71 | </varlistentry> | |
72 | </variablelist> | |
73 | </refsect1> | |
74 | <refsect1 id="description"><title>Description</title> | |
75 | <para> | |
76 | Stenciling, | |
77 | like depth-buffering, | |
78 | enables and disables drawing on a per-pixel basis. | |
79 | You draw into the stencil planes using GL drawing primitives, | |
80 | then render geometry and images, | |
81 | using the stencil planes to mask out portions of the screen. | |
82 | Stenciling is typically used in multipass rendering algorithms | |
83 | to achieve special effects, | |
84 | such as decals, | |
85 | outlining, | |
86 | and constructive solid geometry rendering. | |
87 | </para> | |
88 | <para> | |
89 | The stencil test conditionally eliminates a pixel based on the outcome | |
90 | of a comparison between the value in the stencil buffer and a | |
91 | reference value. To enable and disable the test, call <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry> | |
92 | and <citerefentry><refentrytitle>glDisable</refentrytitle></citerefentry> with argument | |
93 | <constant>GL_STENCIL_TEST</constant>; to control it, call | |
94 | <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry> or | |
95 | <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry>. | |
96 | </para> | |
97 | <para> | |
98 | There can be two separate sets of <parameter>sfail</parameter>, <parameter>dpfail</parameter>, and | |
99 | <parameter>dppass</parameter> parameters; one affects back-facing polygons, and the other | |
100 | affects front-facing polygons as well as other non-polygon primitives. | |
101 | <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry> sets both front | |
102 | and back stencil state to the same values. Use <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry> | |
103 | to set front and back stencil state to different values. | |
104 | </para> | |
105 | <para> | |
106 | <function>glStencilOp</function> takes three arguments that indicate what happens | |
107 | to the stored stencil value while stenciling is enabled. | |
108 | If the stencil test fails, | |
109 | no change is made to the pixel's color or depth buffers, | |
110 | and <parameter>sfail</parameter> specifies what happens to the stencil buffer contents. | |
111 | The following eight actions are possible. | |
112 | </para> | |
113 | <variablelist> | |
114 | <varlistentry> | |
115 | <term><constant>GL_KEEP</constant></term> | |
116 | <listitem> | |
117 | <para> | |
118 | Keeps the current value. | |
119 | </para> | |
120 | </listitem> | |
121 | </varlistentry> | |
122 | <varlistentry> | |
123 | <term><constant>GL_ZERO</constant></term> | |
124 | <listitem> | |
125 | <para> | |
126 | Sets the stencil buffer value to 0. | |
127 | </para> | |
128 | </listitem> | |
129 | </varlistentry> | |
130 | <varlistentry> | |
131 | <term><constant>GL_REPLACE</constant></term> | |
132 | <listitem> | |
133 | <para> | |
134 | Sets the stencil buffer value to <emphasis>ref</emphasis>, | |
135 | as specified by <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>. | |
136 | </para> | |
137 | </listitem> | |
138 | </varlistentry> | |
139 | <varlistentry> | |
140 | <term><constant>GL_INCR</constant></term> | |
141 | <listitem> | |
142 | <para> | |
143 | Increments the current stencil buffer value. | |
144 | Clamps to the maximum representable unsigned value. | |
145 | </para> | |
146 | </listitem> | |
147 | </varlistentry> | |
148 | <varlistentry> | |
149 | <term><constant>GL_INCR_WRAP</constant></term> | |
150 | <listitem> | |
151 | <para> | |
152 | Increments the current stencil buffer value. | |
153 | Wraps stencil buffer value to zero when incrementing the maximum | |
154 | representable unsigned value. | |
155 | </para> | |
156 | </listitem> | |
157 | </varlistentry> | |
158 | <varlistentry> | |
159 | <term><constant>GL_DECR</constant></term> | |
160 | <listitem> | |
161 | <para> | |
162 | Decrements the current stencil buffer value. | |
163 | Clamps to 0. | |
164 | </para> | |
165 | </listitem> | |
166 | </varlistentry> | |
167 | <varlistentry> | |
168 | <term><constant>GL_DECR_WRAP</constant></term> | |
169 | <listitem> | |
170 | <para> | |
171 | Decrements the current stencil buffer value. | |
172 | Wraps stencil buffer value to the maximum representable unsigned value when | |
173 | decrementing a stencil buffer value of zero. | |
174 | </para> | |
175 | </listitem> | |
176 | </varlistentry> | |
177 | <varlistentry> | |
178 | <term><constant>GL_INVERT</constant></term> | |
179 | <listitem> | |
180 | <para> | |
181 | Bitwise inverts the current stencil buffer value. | |
182 | </para> | |
183 | </listitem> | |
184 | </varlistentry> | |
185 | </variablelist> | |
186 | <para> | |
187 | Stencil buffer values are treated as unsigned integers. | |
188 | When incremented and decremented, | |
189 | values are clamped to 0 and | |
190 | <inlineequation><mml:math> | |
191 | <!-- eqn: 2 sup n - 1: --> | |
192 | <mml:mrow> | |
193 | <mml:msup><mml:mn>2</mml:mn> | |
194 | <mml:mi mathvariant="italic">n</mml:mi> | |
195 | </mml:msup> | |
196 | <mml:mo>-</mml:mo> | |
197 | <mml:mn>1</mml:mn> | |
198 | </mml:mrow> | |
199 | </mml:math></inlineequation>, | |
200 | where | |
201 | <inlineequation><mml:math><mml:mi mathvariant="italic">n</mml:mi></mml:math></inlineequation> | |
202 | is the value returned by querying <constant>GL_STENCIL_BITS</constant>. | |
203 | </para> | |
204 | <para> | |
205 | The other two arguments to <function>glStencilOp</function> specify stencil buffer actions | |
206 | that depend on whether subsequent depth buffer tests succeed (<parameter>dppass</parameter>) | |
207 | or fail (<parameter>dpfail</parameter>) (see | |
208 | <citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>). | |
209 | The actions are specified using the same eight symbolic constants as <parameter>sfail</parameter>. | |
210 | Note that <parameter>dpfail</parameter> is ignored when there is no depth buffer, | |
211 | or when the depth buffer is not enabled. | |
212 | In these cases, <parameter>sfail</parameter> and <parameter>dppass</parameter> specify stencil action when the | |
213 | stencil test fails and passes, | |
214 | respectively. | |
215 | </para> | |
216 | </refsect1> | |
217 | <refsect1 id="notes"><title>Notes</title> | |
218 | <para> | |
219 | Initially the stencil test is disabled. | |
220 | If there is no stencil buffer, | |
221 | no stencil modification can occur | |
222 | and it is as if the stencil tests always pass, | |
223 | regardless of any call to <function>glStencilOp</function>. | |
224 | </para> | |
225 | <para> | |
226 | <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry> is the same as | |
227 | calling <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry> | |
228 | with <parameter>face</parameter> set to <constant>GL_FRONT_AND_BACK</constant>. | |
229 | </para> | |
230 | </refsect1> | |
231 | <refsect1 id="errors"><title>Errors</title> | |
232 | <para> | |
233 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>sfail</parameter>, | |
234 | <parameter>dpfail</parameter>, or <parameter>dppass</parameter> is any value other than the defined constant values. | |
235 | </para> | |
236 | </refsect1> | |
237 | <refsect1 id="associatedgets"><title>Associated Gets</title> | |
238 | <para> | |
239 | <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument | |
240 | <constant>GL_STENCIL_FAIL</constant>, <constant>GL_STENCIL_PASS_DEPTH_PASS</constant>, | |
241 | <constant>GL_STENCIL_PASS_DEPTH_FAIL</constant>, <constant>GL_STENCIL_BACK_FAIL</constant>, | |
242 | <constant>GL_STENCIL_BACK_PASS_DEPTH_PASS</constant>, <constant>GL_STENCIL_BACK_PASS_DEPTH_FAIL</constant>, | |
243 | or <constant>GL_STENCIL_BITS</constant> | |
244 | </para> | |
245 | <para> | |
246 | <citerefentry><refentrytitle>glIsEnabled</refentrytitle></citerefentry> with argument <constant>GL_STENCIL_TEST</constant> | |
247 | </para> | |
248 | </refsect1> | |
249 | <refsect1 id="seealso"><title>See Also</title> | |
250 | <para> | |
251 | <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry>, | |
252 | <citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>, | |
253 | <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry>, | |
254 | <citerefentry><refentrytitle>glLogicOp</refentrytitle></citerefentry>, | |
255 | <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>, | |
256 | <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry>, | |
257 | <citerefentry><refentrytitle>glStencilMask</refentrytitle></citerefentry>, | |
258 | <citerefentry><refentrytitle>glStencilMaskSeparate</refentrytitle></citerefentry>, | |
259 | <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry> | |
260 | </para> | |
261 | </refsect1> | |
262 | <refsect1 id="Copyright"><title>Copyright</title> | |
263 | <para> | |
264 | Copyright <trademark class="copyright"></trademark> 1991-2006 | |
265 | Silicon Graphics, Inc. This document is licensed under the SGI | |
266 | Free Software B License. For details, see | |
267 | <ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>. | |
268 | </para> | |
269 | </refsect1> | |
270 | </refentry> |