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