<?xml version="1.0" encoding="UTF-8"?>
<!-- <font-metrics type="TYPE1">  -->
<!--   <font-name>Symbol</font-name>  -->
<!--   <embed/>  -->
<!--   <encoding>SymbolEncoding</encoding>  -->
<!--   <font-triplet name="any" style="normal" weight="normal"/>  -->
<!-- </font-metrics>  -->

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
              "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">


<book>

<title><graphic fileref="opengl_logo.gif" scale="25"/>Reference Pages</title>

<!--
<subtitle>Draft - Version 2.1 11/19/2007 - Draft</subtitle>
-->
<titleabbrev>OpenGL&reg; Reference Pages</titleabbrev>

<bookinfo>

  <corpauthor>OpenGL&reg; Architectural Review Board TSG, Khronos Group Inc.</corpauthor>
  <editor><personname><firstname>Brent</firstname><surname>Insko</surname><othername role='mi'>E</othername></personname></editor>
  <edition>2.1 11/14/2007 - DRAFT</edition>
  <copyright><year>2007</year>
    <holder>Khronos Group, Inc.</holder>
  </copyright>
  <abstract>
  <title>Contents</title>
    <para>
      This document contains reference information for the OpenGL&reg; Application 
Programming Interface. These reference pages (also known as "man pages") include 
all of the important usage information for each command. This information includes
a description of all parameters, return values, error conditions, and related
commands.  In addition, this document also provides usage information for the OpenGL&reg;
Utility Library (GLU) and the OpenGL&reg; extension to the X Window System (GLX).
    </para>
    <para>
      These pages also exist online in the 
<ulink url="http://www.opengl.org/sdk/docs/man/"><citetitle>OpenGL&reg; SDK.</citetitle></ulink>
    </para>
    <para>
If you find any inaccuracies or typos in the reference pages, don't hesitate to inform us via 
the online <ulink url="http://www.opengl.org/documentation/specs/feedback/"><citetitle>specification feedback form.</citetitle></ulink>

    </para>
  </abstract>

</bookinfo>



<colophon>
<title>Copyrights</title>


    <para>
The following OpenGL reference pages are Copyright &copy; 2007 The Khronos Group Inc. and licensed under the Khronos Free Use License. For details, see <ulink url="http://www.khronos.org/help/legal/KFUL/"><citetitle>http://www.khronos.org/help/legal/KFUL/</citetitle></ulink>.
    </para>

<blockquote> 
    <constant>
	glBlendEquationSeparate,
	glStencilFuncSeparate,
	glStencilMaskSeparate,
	glStencilOpSeparate
    </constant>
</blockquote>
 
    <para>
The following OpenGL reference pages are Copyright &copy; 2005 Addison-Wesley and may be distributed subject to the terms and conditions set forth in the Open Publication Licesnse, v 1.0, 8, June 1999. For details, see <ulink url="http://openlcontent.org/openpub/"><citetitle>http://openlcontent.org/openpub/</citetitle></ulink>.
    </para>

<blockquote>
    <constant>
	glBeginQuery,
	glBindBuffer,
	glBufferData,
	glBufferSubData,
	glDeleteBuffers,
	glDeleteQueries,
	glGenBuffers,
	glGenQueries,
	glGetBufferParameteriv,
	glGetBufferPointerv,
	glGetBufferSubData,
	glGetQueryiv,
	glGetQueryObject,
	glIsBuffer,
	glIsQuery,
	glMapBuffer
    </constant>
</blockquote>

    <para>
The following OpenGL reference pages are Copyright &copy; 2003-2005 3Dlabs, Inc. Ltd. And may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8, June 1999. For details, see <ulink url="http://openlcontent.org/openpub/"><citetitle>http://openlcontent.org/openpub/</citetitle></ulink>.
    </para>

<blockquote>
    <constant>
	glAttachShader,
	glBindAttribLocation,
	glCompileShader,
	glCreateProgram,
	glCreateShader,
	glDeleteProgram,
	glDeleteShader,
	glDetachShader,
	glDrawBuffers,
	glEnableVertexAttribArray,
	glGetActiveAttrib,
	glGetActiveUniform,
	glGetAttachedShaders,
	glGetAttribLocation,
	glGetProgram,
	glGetProgramInfoLog,
	glGetShader,
	glGetShaderInfoLog,
	glGetShaderSource,
	glGetUniform,
	glGetUniformLocation,
	glGetVertexAttrib,
	glGetVertexAttribPointerv,
	glIsProgram,
	glIsShader,
	glLinkProgram,
	glShaderSource,
	glUniform,
	glUseProgram,
	glValidateProgram,
	glVertexAttrib,
	glVertexAttribPointer
  </constant>
</blockquote>
 

    <para>
	All reference pages referring to the OpenGL Utility Library and the OpenGL
extension to the X Window System, and the following core OpenGL reference pages
are Copyright &copy; 1991-2006 Silicon Graphics, Inc. and may be distributed
subject to the terms and conditions set forth in the Free Software B License.
For details, see <ulink url="http://oss.sgi.com/projects/FreeB/">
<citetitle>http://oss.sgi.com/projects/FreeB/</citetitle></ulink>.
    </para>
<blockquote>
    <constant>
	glAccum,
	glActiveTexture,
	glAlphaFunc,
	glAreTexturesResident,
	glArrayElement,
	glBegin,
	glBindTexture, 
	glBitmap,
	glBlendColor,
	glBlendEquation,
	glBlendFunc,
	glBlendFuncSeparate,
	glCallList,
	glCallLists,
	glClear,
	glClearAccum,
	glClearColor,
	glClearDepth,
	glClearIndex,
	gllearStencil,
	glCLientActiveTexture,
	glClipPlane,
	glColor,
	glColorMask,
	glColorMaterial,
	glColorPointer,
	glColorSubTable,
	glColorTable,
	glColorTableParameter,
	glCompressedTexImage1D,
	glCompressedTexImage2D,
	glCompressedTexImage3D,
	glCompressedTexSubImage1D,
	glCompressedTexSubImage2D,
	glCompressedTexSubImage3D,
	glConvolutionFilter1D,
	glConvolutionFilter2D,
	glConvolutionParameter,
	glCopyColorSubTable,
	glCopyColorTable,
	glCopyConvolutionFilter1D,
	glCopyConvolutionFilter2D,
	glCopyPixels,
	glCopyTexImage1D,
	glCopyTexImage2D,
	glCopyTexSubImage1D, 
	glCopyTexSubImage2D,
	glCopyTexSubImage3D,   
	glCullFace,
	glDeleteLists,
	glDeleteTextures,
	glDepthFunc,
	glDepthMask,
	glDepthRange,
	glDrawArrays,
	glDrawBuffer,
	glDrawElements,
	glDrawPixels,
	glDrawRangeElements,
	glEdgeFlag,
	glEdgeFlagPointer,
	glEnable,
	glEnableClientState,
	glEvalCoord,
	glEvalMesh,
	glEvalPoint,
	glFeedbackBuffer,
	glFinish,
	glFlush,
	glFog,
	glFogCoord,
	glFogCoordPointer,
	glFrontFace,
	glFrustum,
	glGenLists,
	glGenTextures,
	glGet,
	glGetClipPlane,
	glGetColorTable,
	glGetColorTableParameter,
	glGetCompressedTexImage,
	glGetConvolutionFilter,
	glGetConvolutionParameter,
	glGetError,
	glGetHistogram,
	glGetHistogramParameter,
	glGetLight,
	glGetMap,
	glGetMaterial,
	glGetMinmax,
	glGetMinmaxParameter,
	glGetPixelMap,
	glGetPointerv,
	glGetPolygonStipple,
	glGetSeparableFilter,
	glGetString,
	glGetTexEnv,
	glGetTexGen,
	glGetTexImage,
	glGetTexLevelParameter,
	glGetTexParameter,
	glHint,
	glHistogram,
	glIndex,
	glIndexMask,
	glIndexPointer,
	glInitNames,
	glInterleavedArrays,
	glIsEnabled,
	glIsList,
	glIsTexture,
	glLight,
	glLightModel,
	glLineStipple,
	glLineWidth,
	glListBase,
	glLoadIdentity,
	glLoadMatrix,
	glLoadName,
	glLoadTransposeMatrix,
	glLogicOp,
	glMap1,
	glMap2,
	glMapGrid,
	glMaterial,
	glMatrixMode,
	glMinmax,
	glMultiDrawArrays,
	glMultiDrawElements,
	glMultiTexCoord,
	glMultMatrix,
	glMultTransposeMatrix,
	glNewList,
	glNormal,
	glNormalPointer,
	glOrtho,
	glPassThrough,
	glPixelMap,
	glPixelStore,
	glPixelTransfer,
	glPixelZoom,
	glPointParameter,
	glPointSize,
	glPolygonMode,
	glPolygonOffset,
	glPolygonStipple,
	glPrioritizeTextures,
	glPushAttrib,
	glPushClientAttrib,
	glPushMatrix,
	glPushName,
	glRasterPos,
	glReadBuffer,
	glReadPixels,
	glRect,
	glRenderMode,
	glResetHistogram,
	glResetMinmax,
	glRotate,
	glSampleCoverage,
	glScale,
	glScissor,
	glSecondaryColor,
	glSecondaryColorPointer,
	glSelectBuffer,
	glSeparableFilter2D,
	glShadeModel,
	glStencilFunc,
	glStencilMask,
	glStencilOp,
	glTexCoord,
	glTexCoordPointer,
	glTexEnv,
	glTexGen,
	glTexImage1D,
	glTexImage2D,
	glTexImage3D,
	glTexParameter,
	glTexSubImage1D,
	glTexSubImage2D,
	glTexSubImage3D,
	glTranslate,
	glVertex,
	glVertexPointer,
	glViewport,
	glWindowPos
    </constant>
</blockquote>


</colophon>





<reference>
<title>OpenGL<superscript>&reg;</superscript> Commands</title>
<refentry id="glBlendEquationSeparate">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glBlendEquationSeparate</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glBlendEquationSeparate</refname>
        <refpurpose>set the RGB blend equation and the alpha blend equation separately</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function moreinfo="none">glBlendEquationSeparate</function></funcdef>
                <paramdef>GLenum <parameter moreinfo="none">modeRGB</parameter></paramdef>
                <paramdef>GLenum <parameter moreinfo="none">modeAlpha</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter moreinfo="none">modeRGB</parameter></term>
            <listitem>
                <para>
                    specifies the RGB blend equation, how the red, green, and blue components of the source and destination colors are combined.
                    It must be <constant>GL_FUNC_ADD</constant>, <constant>GL_FUNC_SUBTRACT</constant>,
                    <constant>GL_FUNC_REVERSE_SUBTRACT</constant>, <constant>GL_MIN</constant>, <constant>GL_MAX</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">modeAlpha</parameter></term>
            <listitem>
                <para>
                    specifies the alpha blend equation, how the alpha component of the source and destination colors are combined.
                    It must be <constant>GL_FUNC_ADD</constant>, <constant>GL_FUNC_SUBTRACT</constant>,
                    <constant>GL_FUNC_REVERSE_SUBTRACT</constant>, <constant>GL_MIN</constant>, <constant>GL_MAX</constant>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            The blend equations determines how a new pixel (the ''source'' color)
            is combined with a pixel already in the framebuffer (the ''destination''
            color).  This function specifies one blend equation for the RGB-color 
            components and one blend equation for the alpha component.
        </para>
        <para>
            The blend equations use the source and destination blend factors
            specified by either <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry> or
            <citerefentry><refentrytitle>glBlendFuncSeparate</refentrytitle></citerefentry>.
            See <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry> or <citerefentry><refentrytitle>glBlendFuncSeparate</refentrytitle></citerefentry>
            for a description of the various blend factors.
        </para>
        <para>
            In the equations that follow, source and destination
            color components are referred to as
            <inlineequation><math>
                <!-- eqn: ( R sub s, G sub s, B sub s, A sub s ):-->
                <mfenced open="(" close=")">
                    <msub><mi mathvariant="italic">R</mi>
                    <mi mathvariant="italic">s</mi>
                    </msub>
                    <msub><mi mathvariant="italic">G</mi>
                    <mi mathvariant="italic">s</mi>
                    </msub>
                    <msub><mi mathvariant="italic">B</mi>
                    <mi mathvariant="italic">s</mi>
                    </msub>
                    <msub><mi mathvariant="italic">A</mi>
                    <mi mathvariant="italic">s</mi>
                    </msub>
                </mfenced>
            </math></inlineequation>
            and
            <inlineequation><math>
                <!-- eqn: ( R sub d, G sub d, B sub d, A sub d ):-->
                <mfenced open="(" close=")">
                    <msub><mi mathvariant="italic">R</mi>
                    <mi mathvariant="italic">d</mi>
                    </msub>
                    <msub><mi mathvariant="italic">G</mi>
                    <mi mathvariant="italic">d</mi>
                    </msub>
                    <msub><mi mathvariant="italic">B</mi>
                    <mi mathvariant="italic">d</mi>
                    </msub>
                    <msub><mi mathvariant="italic">A</mi>
                    <mi mathvariant="italic">d</mi>
                    </msub>
                </mfenced>
            </math></inlineequation>,
            respectively.
            The result color is referred to as
            <inlineequation><math>
                <!-- eqn: ( R sub r, G sub r, B sub r, A sub r ):-->
                <mfenced open="(" close=")">
                    <msub><mi mathvariant="italic">R</mi>
                    <mi mathvariant="italic">r</mi>
                    </msub>
                    <msub><mi mathvariant="italic">G</mi>
                    <mi mathvariant="italic">r</mi>
                    </msub>
                    <msub><mi mathvariant="italic">B</mi>
                    <mi mathvariant="italic">r</mi>
                    </msub>
                    <msub><mi mathvariant="italic">A</mi>
                    <mi mathvariant="italic">r</mi>
                    </msub>
                </mfenced>
            </math></inlineequation>.
            The source and destination blend factors are denoted
            <inlineequation><math>
                <!-- eqn: ( s sub R, s sub G, s sub B, s sub A ):-->
                <mfenced open="(" close=")">
                    <msub><mi mathvariant="italic">s</mi>
                    <mi mathvariant="italic">R</mi>
                    </msub>
                    <msub><mi mathvariant="italic">s</mi>
                    <mi mathvariant="italic">G</mi>
                    </msub>
                    <msub><mi mathvariant="italic">s</mi>
                    <mi mathvariant="italic">B</mi>
                    </msub>
                    <msub><mi mathvariant="italic">s</mi>
                    <mi mathvariant="italic">A</mi>
                    </msub>
                </mfenced>
            </math></inlineequation>
            and
            <inlineequation><math>
                <!-- eqn: ( d sub R, d sub G, d sub B, d sub A ):-->
                <mfenced open="(" close=")">
                    <msub><mi mathvariant="italic">d</mi>
                    <mi mathvariant="italic">R</mi>
                    </msub>
                    <msub><mi mathvariant="italic">d</mi>
                    <mi mathvariant="italic">G</mi>
                    </msub>
                    <msub><mi mathvariant="italic">d</mi>
                    <mi mathvariant="italic">B</mi>
                    </msub>
                    <msub><mi mathvariant="italic">d</mi>
                    <mi mathvariant="italic">A</mi>
                    </msub>
                </mfenced>
            </math></inlineequation>,
            respectively.
            For these equations all color components are understood to have values
            in the range 
            <inlineequation><math>
                <!-- eqn: [0,1]:-->
                <mfenced open="[" close="]">
                    <mn>0</mn>
                    <mn>1</mn>
                </mfenced>
            </math></inlineequation>.

        <informaltable frame="topbot">
            <tgroup cols="3" align="left">
                <colspec colwidth="1.1*"/>
                <colspec colwidth="1*"/>
                <colspec colwidth="1*"/>
                <thead>
                    <row>
                        <entry rowsep="1" align="left"><emphasis role="bold">
                        Mode
                        </emphasis></entry>
                        <entry rowsep="1" align="left"><emphasis role="bold">
                        RGB Components
                        </emphasis></entry>
                        <entry rowsep="1" align="left"><emphasis role="bold">
                        Alpha Component
                        </emphasis></entry>
                    </row>
                </thead>
                <tbody>
                    <row>
                        <entry align="left">
                        <constant>GL_FUNC_ADD</constant>
                        </entry>
                        <entry align="left">
                        <informalequation><math>
                            <!-- eqn: Rr  =      R sub s s sub R  +  R sub d d sub R :-->
                            <mrow>
                                <mi mathvariant="italic">Rr</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">R</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">R</mi>
									</msub>
									<mo>+</mo>
									<msub><mi mathvariant="italic">R</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">R</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        <informalequation><math>
                            <!-- eqn: Gr  =    G sub s s sub G  +  G sub d d sub G :-->
                            <mrow>
                                <mi mathvariant="italic">Gr</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">G</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">G</mi>
									</msub>
									<mo>+</mo>
									<msub><mi mathvariant="italic">G</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">G</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        <informalequation><math>
                            <!-- eqn: Br  =    B sub s s sub B  +  B sub d d sub B :-->
                            <mrow>
                                <mi mathvariant="italic">Br</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">B</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">B</mi>
									</msub>
									<mo>+</mo>
									<msub><mi mathvariant="italic">B</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">B</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        </entry>
                        <entry align="left">
                        <informalequation><math>
                            <!-- eqn: Ar  =    A sub s s sub A  +  A sub d d sub A :-->
                            <mrow>
                                <mi mathvariant="italic">Ar</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">A</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">A</mi>
									</msub>
									<mo>+</mo>
									<msub><mi mathvariant="italic">A</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">A</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_FUNC_SUBTRACT</constant>
                        </entry>
                        <entry align="left">
                        <informalequation><math>
                            <!-- eqn: Rr  =      R sub s s sub R  -  R sub d d sub R :-->
                            <mrow>
                                <mi mathvariant="italic">Rr</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">R</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">R</mi>
									</msub>
									<mo>-</mo>
									<msub><mi mathvariant="italic">R</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">R</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        <informalequation><math>
                            <!-- eqn: Gr  =    G sub s s sub G  -  G sub d d sub G :-->
                            <mrow>
                                <mi mathvariant="italic">Gr</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">G</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">G</mi>
									</msub>
									<mo>-</mo>
									<msub><mi mathvariant="italic">G</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">G</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        <informalequation><math>
                            <!-- eqn: Br  =    B sub s s sub B  -  B sub d d sub B :-->
                            <mrow>
                                <mi mathvariant="italic">Br</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">B</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">B</mi>
									</msub>
									<mo>-</mo>
									<msub><mi mathvariant="italic">B</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">B</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        </entry>
                        <entry align="left">
                        <informalequation><math>
                            <!-- eqn: Ar  =    A sub s s sub A  -  A sub d d sub A :-->
                            <mrow>
                                <mi mathvariant="italic">Ar</mi>
                                <mo>=</mo>
                                <mrow>
									<msub><mi mathvariant="italic">A</mi>
									<mi mathvariant="italic">s</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">s</mi>
									<mi mathvariant="italic">A</mi>
									</msub>
									<mo>-</mo>
									<msub><mi mathvariant="italic">A</mi>
									<mi mathvariant="italic">d</mi>
									</msub>
									<mo/>
									<msub><mi mathvariant="italic">d</mi>
									<mi mathvariant="italic">A</mi>
									</msub>
                                </mrow>
                            </mrow>
                        </math></informalequation>
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_FUNC_REVERSE_SUBTRACT</constant>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Rr  =      R sub d d sub R  -  R sub s s sub R :-->
                                <mrow>
                                    <mi mathvariant="italic">Rr</mi>
                                    <mo>=</mo>
                                    <mrow>
										<msub><mi mathvariant="italic">R</mi>
										<mi mathvariant="italic">d</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">d</mi>
										<mi mathvariant="italic">R</mi>
										</msub>
										<mo>-</mo>
										<msub><mi mathvariant="italic">R</mi>
										<mi mathvariant="italic">s</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">s</mi>
										<mi mathvariant="italic">R</mi>
										</msub>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Gr  =    G sub d d sub G  -  G sub s s sub G :-->
                                <mrow>
                                    <mi mathvariant="italic">Gr</mi>
                                    <mo>=</mo>
                                    <mrow>
										<msub><mi mathvariant="italic">G</mi>
										<mi mathvariant="italic">d</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">d</mi>
										<mi mathvariant="italic">G</mi>
										</msub>
										<mo>-</mo>
										<msub><mi mathvariant="italic">G</mi>
										<mi mathvariant="italic">s</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">s</mi>
										<mi mathvariant="italic">G</mi>
										</msub>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Br  =    B sub d d sub B  -  B sub s s sub B :-->
                                <mrow>
                                    <mi mathvariant="italic">Br</mi>
                                    <mo>=</mo>
                                    <mrow>
										<msub><mi mathvariant="italic">B</mi>
										<mi mathvariant="italic">d</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">d</mi>
										<mi mathvariant="italic">B</mi>
										</msub>
										<mo>-</mo>
										<msub><mi mathvariant="italic">B</mi>
										<mi mathvariant="italic">s</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">s</mi>
										<mi mathvariant="italic">B</mi>
										</msub>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Ar  =    A sub d d sub A  -  A sub s s sub A :-->
                                <mrow>
                                    <mi mathvariant="italic">Ar</mi>
                                    <mo>=</mo>
                                    <mrow>
										<msub><mi mathvariant="italic">A</mi>
										<mi mathvariant="italic">d</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">d</mi>
										<mi mathvariant="italic">A</mi>
										</msub>
										<mo>-</mo>
										<msub><mi mathvariant="italic">A</mi>
										<mi mathvariant="italic">s</mi>
										</msub>
										<mo/>
										<msub><mi mathvariant="italic">s</mi>
										<mi mathvariant="italic">A</mi>
										</msub>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_MIN</constant>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Rr  =      min ( R sub s, R sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Rr</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">min</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">R</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">R</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Gr  =      min ( G sub s, G sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Gr</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">min</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">G</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">G</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Br  =      min ( B sub s, B sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Br</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">min</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">B</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">B</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Ar  =      min ( A sub s, A sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Ar</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">min</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">A</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">A</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_MAX</constant>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Rr  =      max ( R sub s, R sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Rr</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">max</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">R</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">R</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Gr  =      max ( G sub s, G sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Gr</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">max</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">G</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">G</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                            <informalequation><math>
                                <!-- eqn: Br  =      max ( B sub s, B sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Br</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">max</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">B</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">B</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                        <entry align="left">
                            <informalequation><math>
                                <!-- eqn: Ar  =      max ( A sub s, A sub d):-->
                                <mrow>
                                    <mi mathvariant="italic">Ar</mi>
                                    <mo>=</mo>
                                    <mrow>
                                        <mi mathvariant="italic">max</mi>
                                        <mo/>
                                        <mfenced open="(" close=")">
                                            <mrow>
                                                <msub><mi mathvariant="italic">A</mi>
                                                <mi mathvariant="italic">s</mi>
                                                </msub>
                                            </mrow>
                                            <mrow>
                                                <msub><mi mathvariant="italic">A</mi>
                                                <mi mathvariant="italic">d</mi>
                                                </msub>
                                            </mrow>
                                        </mfenced>
                                    </mrow>
                                </mrow>
                            </math></informalequation>
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
        </para>
        <para>
            The results of these equations are clamped to the range 
                        <inlineequation><math>
                            <!-- eqn: [0,1]:-->
                            <mfenced open="[" close="]">
                                <mn>0</mn>
                                <mn>1</mn>
                            </mfenced>
                        </math></inlineequation>.
        </para>
        <para>
            The <constant>GL_MIN</constant> and <constant>GL_MAX</constant> equations are useful for applications
            that analyze image data (image thresholding against a constant color,
            for example).
            The <constant>GL_FUNC_ADD</constant> equation is useful
            for antialiasing and transparency, among other things.
        </para>
        <para>
            Initially, both the RGB blend equation and the alpha blend equation are set to <constant>GL_FUNC_ADD</constant>.
        </para>
        <para>
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <function moreinfo="none">glBlendEquationSeparate</function> is available only if the GL version is 2.0 or greater.
        </para>
        <para>
            The <constant>GL_MIN</constant>, and <constant>GL_MAX</constant> equations do not use
            the source or destination factors, only the source and destination colors.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if either <parameter moreinfo="none">modeRGB</parameter> or <parameter moreinfo="none">modeAlpha</parameter> is not one of
            <constant>GL_FUNC_ADD</constant>, <constant>GL_FUNC_SUBTRACT</constant>, <constant>GL_FUNC_REVERSE_SUBTRACT</constant>,
            <constant>GL_MAX</constant>, or <constant>GL_MIN</constant>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function moreinfo="none">glBlendEquationSeparate</function> is executed
            between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry> and the corresponding
            execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
                <para>
                    <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with an argument of <constant>GL_BLEND_EQUATION_RGB</constant>
                </para>
                <para>
                    <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with an argument of <constant>GL_BLEND_EQUATION_ALPHA</constant>
                </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glGetString</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBlendColor</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBlendFuncSeparate</refentrytitle></citerefentry>
        </para>
    </refsect1>
    
</refentry>
<refentry id="glStencilFuncSeparate">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glStencilFuncSeparate</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glStencilFuncSeparate</refname>
        <refpurpose>set front and/or back function and reference value for stencil testing</refpurpose>
    </refnamediv>
    <!-- eqn: ignoring delim $$ -->
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function moreinfo="none">glStencilFuncSeparate</function></funcdef>
                <paramdef>GLenum <parameter moreinfo="none">face</parameter></paramdef>
                <paramdef>GLenum <parameter moreinfo="none">func</parameter></paramdef>
                <paramdef>GLint <parameter moreinfo="none">ref</parameter></paramdef>
                <paramdef>GLuint <parameter moreinfo="none">mask</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter moreinfo="none">face</parameter></term>
            <listitem>
                <para>
                    Specifies whether front and/or back stencil state is updated.
                    Three symbolic constants are valid:
                    <constant>GL_FRONT</constant>,
                    <constant>GL_BACK</constant>, and
                    <constant>GL_FRONT_AND_BACK</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">func</parameter></term>
            <listitem>
                <para>
                    Specifies the test function.
                    Eight symbolic constants are valid:
                    <constant>GL_NEVER</constant>,
                    <constant>GL_LESS</constant>,
                    <constant>GL_LEQUAL</constant>,
                    <constant>GL_GREATER</constant>,
                    <constant>GL_GEQUAL</constant>,
                    <constant>GL_EQUAL</constant>,
                    <constant>GL_NOTEQUAL</constant>, and
                    <constant>GL_ALWAYS</constant>. The initial value is <constant>GL_ALWAYS</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">ref</parameter></term>
            <listitem>
                <para>
                    Specifies the reference value for the stencil test.
                    <parameter moreinfo="none">ref</parameter> is clamped to the range 
                    <inlineequation><math>
                        <!-- eqn: [0, 2 sup n - 1]:-->
                        <mfenced open="[" close="]">
                            <mn>0</mn>
                            <mrow>
                                <msup><mn>2</mn>
                                <mi mathvariant="italic">n</mi>
                                </msup>
                                <mo>-</mo>
                                <mn>1</mn>
                            </mrow>
                        </mfenced>
                    </math></inlineequation>,
                    where 
                    <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
                    is the number of bitplanes in the stencil buffer. The
                    initial value is 0.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">mask</parameter></term>
            <listitem>
                <para>
                    Specifies a mask that is ANDed with both the reference value
                    and the stored stencil value when the test is done. The initial value
                    is all 1's.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            Stenciling,
            like depth-buffering,
            enables and disables drawing on a per-pixel basis.
            You draw into the stencil planes using GL drawing primitives,
            then render geometry and images,
            using the stencil planes to mask out portions of the screen.
            Stenciling is typically used in multipass rendering algorithms
            to achieve special effects,
            such as decals,
            outlining,
            and constructive solid geometry rendering.
        </para>
        <para>
            The stencil test conditionally eliminates a pixel based on the outcome
            of a comparison between the reference value
            and the value in the stencil buffer.
            To enable and disable the test, call <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glDisable</refentrytitle></citerefentry>
            with argument <constant>GL_STENCIL_TEST</constant>.
            To specify actions based on the outcome of the stencil test, call
            <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry> or 
            <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry>.
        </para>
        <para>
            There can be two separate sets of <parameter moreinfo="none">func</parameter>, <parameter moreinfo="none">ref</parameter>, and 
            <parameter moreinfo="none">mask</parameter> parameters; one affects back-facing polygons, and the other
            affects front-facing polygons as well as other non-polygon primitives. 
            <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry> sets both front
            and back stencil state to the same values, as if 
            <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry> were called
            with <parameter moreinfo="none">face</parameter> set to <constant>GL_FRONT_AND_BACK</constant>.
        </para>
        <para>
            <parameter moreinfo="none">func</parameter> is a symbolic constant that determines the stencil comparison function.
            It accepts one of eight values,
            shown in the following list.
            <parameter moreinfo="none">ref</parameter> is an integer reference value that is used in the stencil comparison.
            It is clamped to the range 
            <inlineequation><math>
                <!-- eqn: [0, 2 sup n - 1]:-->
                <mfenced open="[" close="]">
                    <mn>0</mn>
                    <mrow>
                        <msup><mn>2</mn>
                        <mi mathvariant="italic">n</mi>
                        </msup>
                        <mo>-</mo>
                        <mn>1</mn>
                    </mrow>
                </mfenced>
            </math></inlineequation>,
            where 
            <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
            is the number of bitplanes in the stencil buffer.
            <parameter moreinfo="none">mask</parameter> is bitwise ANDed with both the reference value
            and the stored stencil value,
            with the ANDed values participating in the comparison.
        </para>
        <para>
            If <emphasis>stencil</emphasis> represents the value stored in the corresponding
            stencil buffer location,
            the following list shows the effect of each comparison function
            that can be specified by <parameter moreinfo="none">func</parameter>.
            Only if the comparison succeeds is the pixel passed through
            to the next stage in the rasterization process
            (see <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry>).
            All tests treat <emphasis>stencil</emphasis> values as unsigned integers in the range
            <inlineequation><math>
                <!-- eqn: [0, 2 sup n - 1]:-->
                <mfenced open="[" close="]">
                    <mn>0</mn>
                    <mrow>
                        <msup><mn>2</mn>
                        <mi mathvariant="italic">n</mi>
                        </msup>
                        <mo>-</mo>
                        <mn>1</mn>
                    </mrow>
                </mfenced>
            </math></inlineequation>,
            where 
            <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
            is the number of bitplanes in the stencil buffer.
        </para>
        <para>
            The following values are accepted by <parameter moreinfo="none">func</parameter>:
        </para>
        <variablelist>
            <varlistentry>
                <term><constant>GL_NEVER</constant></term>
                <listitem>
                    <para>
                        Always fails.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_LESS</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) &lt; ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_LEQUAL</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) &lt;= ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_GREATER</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) &gt; ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_GEQUAL</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) &gt;= ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_EQUAL</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) = ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_NOTEQUAL</constant></term>
                <listitem>
                    <para>
                        Passes if ( <parameter moreinfo="none">ref</parameter> &amp; <parameter moreinfo="none">mask</parameter> ) != ( <emphasis>stencil</emphasis> &amp; <parameter moreinfo="none">mask</parameter> ).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_ALWAYS</constant></term>
                <listitem>
                    <para>
                        Always passes.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
	<para>
            <function moreinfo="none">glStencilFuncSeparate</function> is available only if
            the GL version is 2.0 or greater.
        </para>
        <para>
            Initially, the stencil test is disabled.
            If there is no stencil buffer,
            no stencil modification can occur and it is as if
            the stencil test always passes.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter moreinfo="none">func</parameter> is not one of the eight
            accepted values.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function moreinfo="none">glStencilFuncSeparate</function>
            is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
            and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument 
            <constant>GL_STENCIL_FUNC</constant>, <constant>GL_STENCIL_VALUE_MASK</constant>, 
            <constant>GL_STENCIL_REF</constant>, <constant>GL_STENCIL_BACK_FUNC</constant>, 
            <constant>GL_STENCIL_BACK_VALUE_MASK</constant>, <constant>GL_STENCIL_BACK_REF</constant>, 
            or <constant>GL_STENCIL_BITS</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glIsEnabled</refentrytitle></citerefentry> with argument <constant>GL_STENCIL_TEST</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glAlphaFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glLogicOp</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilMaskSeparate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry>
        </para>
    </refsect1>
    
</refentry>
<refentry id="glStencilMaskSeparate">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glStencilMaskSeparate</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glStencilMaskSeparate</refname>
        <refpurpose>control the front and/or back writing of individual bits in the stencil planes</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function moreinfo="none">glStencilMaskSeparate</function></funcdef>
                <paramdef>GLenum <parameter moreinfo="none">face</parameter></paramdef>
                <paramdef>GLuint <parameter moreinfo="none">mask</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter moreinfo="none">face</parameter></term>
            <listitem>
                <para>
                    Specifies whether the front and/or back stencil writemask is updated.
                    Three symbolic constants are valid:
                    <constant>GL_FRONT</constant>,
                    <constant>GL_BACK</constant>, and
                    <constant>GL_FRONT_AND_BACK</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">mask</parameter></term>
            <listitem>
                <para>
                    Specifies a bit mask to enable and disable writing of individual bits
                    in the stencil planes.
                    Initially, the mask is all 1's.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function moreinfo="none">glStencilMaskSeparate</function> controls the writing of individual bits in the stencil planes.
            The least significant 
            <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
            bits of <parameter moreinfo="none">mask</parameter>,
            where 
            <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
            is the number of bits in the stencil buffer,
            specify a mask.
            Where a 1 appears in the mask,
            it's possible to write to the corresponding bit in the stencil buffer.
            Where a 0 appears,
            the corresponding bit is write-protected.
            Initially, all bits are enabled for writing.
        </para>
        <para>
            There can be two separate <parameter moreinfo="none">mask</parameter> writemasks; one affects back-facing polygons, and the other
            affects front-facing polygons as well as other non-polygon primitives. 
            <citerefentry><refentrytitle>glStencilMask</refentrytitle></citerefentry> sets both front
            and back stencil writemasks to the same values, as if
            <citerefentry><refentrytitle>glStencilMaskSeparate</refentrytitle></citerefentry> were called
            with <parameter moreinfo="none">face</parameter> set to <constant>GL_FRONT_AND_BACK</constant>.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
	<para>
            <function moreinfo="none">glStencilMaskSeparate</function> is available only if
            the GL version is 2.0 or greater.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function moreinfo="none">glStencilMaskSeparate</function>
            is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
            and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument 
            <constant>GL_STENCIL_WRITEMASK</constant>, <constant>GL_STENCIL_BACK_WRITEMASK</constant>, 
            or <constant>GL_STENCIL_BITS</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glColorMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glDepthMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glIndexMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry>
        </para>
    </refsect1>
    
</refentry>
<refentry id="glStencilOpSeparate">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glStencilOpSeparate</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glStencilOpSeparate</refname>
        <refpurpose>set front and/or back stencil test actions</refpurpose>
    </refnamediv>
    <!-- eqn: ignoring delim $$ -->
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function moreinfo="none">glStencilOpSeparate</function></funcdef>
                <paramdef>GLenum <parameter moreinfo="none">face</parameter></paramdef>
                <paramdef>GLenum <parameter moreinfo="none">sfail</parameter></paramdef>
                <paramdef>GLenum <parameter moreinfo="none">dpfail</parameter></paramdef>
                <paramdef>GLenum <parameter moreinfo="none">dppass</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter moreinfo="none">face</parameter></term>
            <listitem>
                <para>
                    Specifies whether front and/or back stencil state is updated.
                    Three symbolic constants are valid:
                    <constant>GL_FRONT</constant>,
                    <constant>GL_BACK</constant>, and
                    <constant>GL_FRONT_AND_BACK</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">sfail</parameter></term>
            <listitem>
                <para>
                    Specifies the action to take when the stencil test fails.
                    Eight symbolic constants are accepted:
                    <constant>GL_KEEP</constant>,
                    <constant>GL_ZERO</constant>,
                    <constant>GL_REPLACE</constant>,
                    <constant>GL_INCR</constant>,
                    <constant>GL_INCR_WRAP</constant>,
                    <constant>GL_DECR</constant>,
                    <constant>GL_DECR_WRAP</constant>, and
                    <constant>GL_INVERT</constant>. The initial value is <constant>GL_KEEP</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">dpfail</parameter></term>
            <listitem>
                <para>
                    Specifies the stencil action when the stencil test passes,
                    but the depth test fails.
                    <parameter moreinfo="none">dpfail</parameter> accepts the same symbolic constants as <parameter moreinfo="none">sfail</parameter>. The initial value
                    is <constant>GL_KEEP</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter moreinfo="none">dppass</parameter></term>
            <listitem>
                <para>
                    Specifies the stencil action when both the stencil test and the depth
                    test pass, or when the stencil test passes and either there is no
                    depth buffer or depth testing is not enabled.
                    <parameter moreinfo="none">dppass</parameter> accepts the same symbolic constants as <parameter moreinfo="none">sfail</parameter>. The initial value
                    is <constant>GL_KEEP</constant>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            Stenciling,
            like depth-buffering,
            enables and disables drawing on a per-pixel basis.
            You draw into the stencil planes using GL drawing primitives,
            then render geometry and images,
            using the stencil planes to mask out portions of the screen.
            Stenciling is typically used in multipass rendering algorithms
            to achieve special effects,
            such as decals,
            outlining,
            and constructive solid geometry rendering.
        </para>
        <para>
            The stencil test conditionally eliminates a pixel based on the outcome
            of a comparison between the value in the stencil buffer and a
            reference value. To enable and disable the test, call <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry>
            and <citerefentry><refentrytitle>glDisable</refentrytitle></citerefentry> with argument
            <constant>GL_STENCIL_TEST</constant>; to control it, call 
            <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry> or 
            <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry>.
        </para>
        <para>
            There can be two separate sets of <parameter moreinfo="none">sfail</parameter>, <parameter moreinfo="none">dpfail</parameter>, and 
            <parameter moreinfo="none">dppass</parameter> parameters; one affects back-facing polygons, and the other
            affects front-facing polygons as well as other non-polygon primitives. 
            <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry> sets both front
            and back stencil state to the same values, as if 
            <citerefentry><refentrytitle>glStencilOpSeparate</refentrytitle></citerefentry> were called
            with <parameter moreinfo="none">face</parameter> set to <constant>GL_FRONT_AND_BACK</constant>.
        </para>
        <para>
            <function moreinfo="none">glStencilOpSeparate</function> takes three arguments that indicate what happens
            to the stored stencil value while stenciling is enabled.
            If the stencil test fails,
            no change is made to the pixel's color or depth buffers,
            and <parameter moreinfo="none">sfail</parameter> specifies what happens to the stencil buffer contents.
            The following eight actions are possible.
        </para>
        <variablelist>
            <varlistentry>
                <term><constant>GL_KEEP</constant></term>
                <listitem>
                    <para>
                        Keeps the current value.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_ZERO</constant></term>
                <listitem>
                    <para>
                        Sets the stencil buffer value to 0.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_REPLACE</constant></term>
                <listitem>
                    <para>
                        Sets the stencil buffer value to <emphasis>ref</emphasis>,
                        as specified by <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_INCR</constant></term>
                <listitem>
                    <para>
                        Increments the current stencil buffer value.
                        Clamps to the maximum representable unsigned value.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_INCR_WRAP</constant></term>
                <listitem>
                    <para>
                        Increments the current stencil buffer value.
                        Wraps stencil buffer value to zero when incrementing the maximum
                        representable unsigned value.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_DECR</constant></term>
                <listitem>
                    <para>
                        Decrements the current stencil buffer value.
                        Clamps to 0.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_DECR_WRAP</constant></term>
                <listitem>
                    <para>
                        Decrements the current stencil buffer value.
                        Wraps stencil buffer value to the maximum representable unsigned value when
                        decrementing a stencil buffer value of zero.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GL_INVERT</constant></term>
                <listitem>
                    <para>
                        Bitwise inverts the current stencil buffer value.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
        <para>
            Stencil buffer values are treated as unsigned integers.
            When incremented and decremented,
            values are clamped to 0 and 
            <inlineequation><math>
                <!-- eqn: 2 sup n - 1:-->
                <mrow>
                    <msup><mn>2</mn>
                    <mi mathvariant="italic">n</mi>
                    </msup>
                    <mo>-</mo>
                    <mn>1</mn>
                </mrow>
            </math></inlineequation>,
            where 
            <inlineequation><math><mi mathvariant="italic">n</mi></math></inlineequation>
            is the value returned by querying <constant>GL_STENCIL_BITS</constant>.
        </para>
        <para>
            The other two arguments to <function moreinfo="none">glStencilOpSeparate</function> specify stencil buffer actions
            that depend on whether subsequent depth buffer tests succeed (<parameter moreinfo="none">dppass</parameter>)
            or fail (<parameter moreinfo="none">dpfail</parameter>) (see
            <citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>).
            The actions are specified using the same eight symbolic constants as <parameter moreinfo="none">sfail</parameter>.
            Note that <parameter moreinfo="none">dpfail</parameter> is ignored when there is no depth buffer,
            or when the depth buffer is not enabled.
            In these cases, <parameter moreinfo="none">sfail</parameter> and <parameter moreinfo="none">dppass</parameter> specify stencil action when the
            stencil test fails and passes,
            respectively.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
	<para>
            <function moreinfo="none">glStencilOpSeparate</function> is available only if
            the GL version is 2.0 or greater.
        </para>
        <para>
            Initially the stencil test is disabled.
            If there is no stencil buffer,
            no stencil modification can occur
            and it is as if the stencil test always passes.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter moreinfo="none">face</parameter> is any value 
            other than <constant>GL_FRONT</constant>, <constant>GL_BACK</constant>, or <constant>GL_FRONT_AND_BACK</constant>.
        </para>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter moreinfo="none">sfail</parameter>,
            <parameter moreinfo="none">dpfail</parameter>, or <parameter moreinfo="none">dppass</parameter> is any value other than the eight defined constant values.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function moreinfo="none">glStencilOpSeparate</function>
            is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
            and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument 
            <constant>GL_STENCIL_FAIL</constant>, <constant>GL_STENCIL_PASS_DEPTH_PASS</constant>, 
            <constant>GL_STENCIL_PASS_DEPTH_FAIL</constant>, <constant>GL_STENCIL_BACK_FAIL</constant>, 
            <constant>GL_STENCIL_BACK_PASS_DEPTH_PASS</constant>, <constant>GL_STENCIL_BACK_PASS_DEPTH_FAIL</constant>,
            or <constant>GL_STENCIL_BITS</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glIsEnabled</refentrytitle></citerefentry> with argument <constant>GL_STENCIL_TEST</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glAlphaFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glLogicOp</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilFuncSeparate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilMask</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilMaskSeparate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry>
        </para>
    </refsect1>
    
</refentry>
</reference>
</book>