include more low-level bindings
[clinton/guile-figl.git] / upstream-man-pages / man2 / xhtml / glStencilOp.xml
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd">
2 <!-- saved from url=(0013)about:internet -->
3 <?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>glStencilOp</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glStencilOp"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glStencilOp — set front and back stencil test actions</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glStencilOp</b>(</code></td><td>GLenum  </td><td><var class="pdparam">sfail</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">dpfail</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">dppass</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>sfail</code></em></span></dt><dd><p>
4 Specifies the action to take when the stencil test fails.
5 Eight symbolic constants are accepted:
6 <code class="constant">GL_KEEP</code>,
7 <code class="constant">GL_ZERO</code>,
8 <code class="constant">GL_REPLACE</code>,
9 <code class="constant">GL_INCR</code>,
10 <code class="constant">GL_INCR_WRAP</code>,
11 <code class="constant">GL_DECR</code>,
12 <code class="constant">GL_DECR_WRAP</code>, and
13 <code class="constant">GL_INVERT</code>. The initial value is <code class="constant">GL_KEEP</code>.
14 </p></dd><dt><span class="term"><em class="parameter"><code>dpfail</code></em></span></dt><dd><p>
15 Specifies the stencil action when the stencil test passes,
16 but the depth test fails.
17 <em class="parameter"><code>dpfail</code></em> accepts the same symbolic constants as <em class="parameter"><code>sfail</code></em>. The initial value
18 is <code class="constant">GL_KEEP</code>.
19 </p></dd><dt><span class="term"><em class="parameter"><code>dppass</code></em></span></dt><dd><p>
20 Specifies the stencil action when both the stencil test and the depth
21 test pass, or when the stencil test passes and either there is no
22 depth buffer or depth testing is not enabled.
23 <em class="parameter"><code>dppass</code></em> accepts the same symbolic constants as <em class="parameter"><code>sfail</code></em>. The initial value
24 is <code class="constant">GL_KEEP</code>.
25 </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p>
26 Stenciling,
27 like depth-buffering,
28 enables and disables drawing on a per-pixel basis.
29 You draw into the stencil planes using GL drawing primitives,
30 then render geometry and images,
31 using the stencil planes to mask out portions of the screen.
32 Stenciling is typically used in multipass rendering algorithms
33 to achieve special effects,
34 such as decals,
35 outlining,
36 and constructive solid geometry rendering.
37 </p><p>
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
40 reference value. To enable and disable the test, call <a class="citerefentry" href="glEnable.xml"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>
41 and <a class="citerefentry" href="glDisable.xml"><span class="citerefentry"><span class="refentrytitle">glDisable</span></span></a> with argument
42 <code class="constant">GL_STENCIL_TEST</code>; to control it, call
43 <a class="citerefentry" href="glStencilFunc.xml"><span class="citerefentry"><span class="refentrytitle">glStencilFunc</span></span></a> or
44 <a class="citerefentry" href="glStencilFuncSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilFuncSeparate</span></span></a>.
45 </p><p>
46 There can be two separate sets of <em class="parameter"><code>sfail</code></em>, <em class="parameter"><code>dpfail</code></em>, and
47 <em class="parameter"><code>dppass</code></em> parameters; one affects back-facing polygons, and the other
48 affects front-facing polygons as well as other non-polygon primitives.
49 <a class="citerefentry" href="glStencilOp.xml"><span class="citerefentry"><span class="refentrytitle">glStencilOp</span></span></a> sets both front
50 and back stencil state to the same values. Use <a class="citerefentry" href="glStencilOpSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilOpSeparate</span></span></a>
51 to set front and back stencil state to different values.
52 </p><p>
53 <code class="function">glStencilOp</code> takes three arguments that indicate what happens
54 to the stored stencil value while stenciling is enabled.
55 If the stencil test fails,
56 no change is made to the pixel's color or depth buffers,
57 and <em class="parameter"><code>sfail</code></em> specifies what happens to the stencil buffer contents.
58 The following eight actions are possible.
59 </p><div class="variablelist"><dl><dt><span class="term"><code class="constant">GL_KEEP</code></span></dt><dd><p>
60 Keeps the current value.
61 </p></dd><dt><span class="term"><code class="constant">GL_ZERO</code></span></dt><dd><p>
62 Sets the stencil buffer value to 0.
63 </p></dd><dt><span class="term"><code class="constant">GL_REPLACE</code></span></dt><dd><p>
64 Sets the stencil buffer value to <span class="emphasis"><em>ref</em></span>,
65 as specified by <a class="citerefentry" href="glStencilFunc.xml"><span class="citerefentry"><span class="refentrytitle">glStencilFunc</span></span></a>.
66 </p></dd><dt><span class="term"><code class="constant">GL_INCR</code></span></dt><dd><p>
67 Increments the current stencil buffer value.
68 Clamps to the maximum representable unsigned value.
69 </p></dd><dt><span class="term"><code class="constant">GL_INCR_WRAP</code></span></dt><dd><p>
70 Increments the current stencil buffer value.
71 Wraps stencil buffer value to zero when incrementing the maximum
72 representable unsigned value.
73 </p></dd><dt><span class="term"><code class="constant">GL_DECR</code></span></dt><dd><p>
74 Decrements the current stencil buffer value.
75 Clamps to 0.
76 </p></dd><dt><span class="term"><code class="constant">GL_DECR_WRAP</code></span></dt><dd><p>
77 Decrements the current stencil buffer value.
78 Wraps stencil buffer value to the maximum representable unsigned value when
79 decrementing a stencil buffer value of zero.
80 </p></dd><dt><span class="term"><code class="constant">GL_INVERT</code></span></dt><dd><p>
81 Bitwise inverts the current stencil buffer value.
82 </p></dd></dl></div><p>
83 Stencil buffer values are treated as unsigned integers.
84 When incremented and decremented,
85 values are clamped to 0 and
86 <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
87
88 <mml:mrow>
89 <mml:msup><mml:mn>2</mml:mn>
90 <mml:mi mathvariant="italic">n</mml:mi>
91 </mml:msup>
92 <mml:mo>-</mml:mo>
93 <mml:mn>1</mml:mn>
94 </mml:mrow>
95 </mml:math>,
96 where
97 <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">n</mml:mi></mml:math>
98 is the value returned by querying <code class="constant">GL_STENCIL_BITS</code>.
99 </p><p>
100 The other two arguments to <code class="function">glStencilOp</code> specify stencil buffer actions
101 that depend on whether subsequent depth buffer tests succeed (<em class="parameter"><code>dppass</code></em>)
102 or fail (<em class="parameter"><code>dpfail</code></em>) (see
103 <a class="citerefentry" href="glDepthFunc.xml"><span class="citerefentry"><span class="refentrytitle">glDepthFunc</span></span></a>).
104 The actions are specified using the same eight symbolic constants as <em class="parameter"><code>sfail</code></em>.
105 Note that <em class="parameter"><code>dpfail</code></em> is ignored when there is no depth buffer,
106 or when the depth buffer is not enabled.
107 In these cases, <em class="parameter"><code>sfail</code></em> and <em class="parameter"><code>dppass</code></em> specify stencil action when the
108 stencil test fails and passes,
109 respectively.
110 </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p>
111 <code class="constant">GL_DECR_WRAP</code> and <code class="constant">GL_INCR_WRAP</code> are available only if the GL
112 version is 1.4 or greater.
113 </p><p>
114 Initially the stencil test is disabled.
115 If there is no stencil buffer,
116 no stencil modification can occur
117 and it is as if the stencil tests always pass,
118 regardless of any call to <code class="function">glStencilOp</code>.
119 </p><p>
120 <a class="citerefentry" href="glStencilOp.xml"><span class="citerefentry"><span class="refentrytitle">glStencilOp</span></span></a> is the same as
121 calling <a class="citerefentry" href="glStencilOpSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilOpSeparate</span></span></a>
122 with <em class="parameter"><code>face</code></em> set to <code class="constant">GL_FRONT_AND_BACK</code>.
123 </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p>
124 <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>sfail</code></em>,
125 <em class="parameter"><code>dpfail</code></em>, or <em class="parameter"><code>dppass</code></em> is any value other than the eight defined constant values.
126 </p><p>
127 <code class="constant">GL_INVALID_OPERATION</code> is generated if <code class="function">glStencilOp</code>
128 is executed between the execution of <a class="citerefentry" href="glBegin.xml"><span class="citerefentry"><span class="refentrytitle">glBegin</span></span></a>
129 and the corresponding execution of <a class="citerefentry" href="glEnd.xml"><span class="citerefentry"><span class="refentrytitle">glEnd</span></span></a>.
130 </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p>
131 <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument
132 <code class="constant">GL_STENCIL_FAIL</code>, <code class="constant">GL_STENCIL_PASS_DEPTH_PASS</code>,
133 <code class="constant">GL_STENCIL_PASS_DEPTH_FAIL</code>, <code class="constant">GL_STENCIL_BACK_FAIL</code>,
134 <code class="constant">GL_STENCIL_BACK_PASS_DEPTH_PASS</code>, <code class="constant">GL_STENCIL_BACK_PASS_DEPTH_FAIL</code>,
135 or <code class="constant">GL_STENCIL_BITS</code>
136 </p><p>
137 <a class="citerefentry" href="glIsEnabled.xml"><span class="citerefentry"><span class="refentrytitle">glIsEnabled</span></span></a> with argument <code class="constant">GL_STENCIL_TEST</code>
138 </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p>
139 <a class="citerefentry" href="glAlphaFunc.xml"><span class="citerefentry"><span class="refentrytitle">glAlphaFunc</span></span></a>,
140 <a class="citerefentry" href="glBlendFunc.xml"><span class="citerefentry"><span class="refentrytitle">glBlendFunc</span></span></a>,
141 <a class="citerefentry" href="glDepthFunc.xml"><span class="citerefentry"><span class="refentrytitle">glDepthFunc</span></span></a>,
142 <a class="citerefentry" href="glEnable.xml"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>,
143 <a class="citerefentry" href="glLogicOp.xml"><span class="citerefentry"><span class="refentrytitle">glLogicOp</span></span></a>,
144 <a class="citerefentry" href="glStencilFunc.xml"><span class="citerefentry"><span class="refentrytitle">glStencilFunc</span></span></a>,
145 <a class="citerefentry" href="glStencilFuncSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilFuncSeparate</span></span></a>,
146 <a class="citerefentry" href="glStencilMask.xml"><span class="citerefentry"><span class="refentrytitle">glStencilMask</span></span></a>,
147 <a class="citerefentry" href="glStencilMaskSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilMaskSeparate</span></span></a>,
148 <a class="citerefentry" href="glStencilOpSeparate.xml"><span class="citerefentry"><span class="refentrytitle">glStencilOpSeparate</span></span></a>
149 </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p>
150 Copyright <span class="trademark"></span>© 1991-2006
151 Silicon Graphics, Inc. This document is licensed under the SGI
152 Free Software B License. For details, see
153 <a class="ulink" href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>.
154 </p></div></div></body></html>