
<refentry id="gluNurbsCallback">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>gluNurbsCallback</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>gluNurbsCallback</refname>
        <refpurpose>define a callback for a NURBS object</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>gluNurbsCallback</function></funcdef>
                <paramdef>GLUnurbs* <parameter>nurb</parameter></paramdef>
                <paramdef>GLenum <parameter>which</parameter></paramdef>
                <paramdef>_GLUfuncptr <parameter>CallBackFunc</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>nurb</parameter></term>
            <listitem>
                <para>
                    Specifies the NURBS object (created with <citerefentry><refentrytitle>gluNewNurbsRenderer</refentrytitle></citerefentry>).
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>which</parameter></term>
            <listitem>
                <para>
                    Specifies the callback being defined. 
                    Valid values are <constant>GLU_NURBS_BEGIN</constant>, <constant>GLU_NURBS_VERTEX</constant>, <constant>GLU_NURBS_NORMAL</constant>, <constant>GLU_NURBS_COLOR</constant>, <constant>GLU_NURBS_TEXTURE_COORD</constant>, <constant>GLU_NURBS_END</constant>, <constant>GLU_NURBS_BEGIN_DATA</constant>, <constant>GLU_NURBS_VERTEX_DATA</constant>, <constant>GLU_NURBS_NORMAL_DATA</constant>, <constant>GLU_NURBS_COLOR_DATA</constant>, <constant>GLU_NURBS_TEXTURE_COORD_DATA</constant>, <constant>GLU_NURBS_END_DATA</constant>, and <constant>GLU_NURBS_ERROR</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>CallBackFunc</parameter></term>
            <listitem>
                <para>
                    Specifies the function that the callback calls.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>gluNurbsCallback</function> is used to define a callback to be used by a NURBS 
            object.
            If the specified callback is already defined, then it is replaced.  If 
            <parameter>CallBackFunc</parameter> is NULL, then this callback will not get
            invoked and the related data, if any, will be lost.
        </para>
        <para>
            Except the error callback, these callbacks are used by NURBS tessellator (when <constant>GLU_NURBS_MODE</constant> is set to be <constant>GLU_NURBS_TESSELLATOR</constant>) to return back the OpenGL
            polygon primitives resulting from the tessellation. Note that there are two
            versions of each callback: one with a user data pointer and one without. If both versions for a particular callback are specified then the callback with 
            the user data pointer will be used. Note that ``userData'' is a copy of the pointer that was specified at the last call to <function>gluNurbsCallbackData</function>.
        </para>
        <para>
            The error callback function is effective no matter which value that
            <constant>GLU_NURBS_MODE</constant> is set to.
            All other callback functions are effective only when <constant>GLU_NURBS_MODE</constant>
            is set to <constant>GLU_NURBS_TESSELLATOR</constant>.
        </para>
        <para>
            The legal callbacks are as follows:
        </para>
        <variablelist>
            <varlistentry>
                <term><constant>GLU_NURBS_BEGIN</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The begin callback indicates the start of a primitive. The function
                        takes a single argument of type GLenum, which can be one of 
                        <constant>GLU_LINES</constant>, <constant>GLU_LINE_STRIP</constant>, <constant>GLU_TRIANGLE_FAN</constant>, <constant>GLU_TRIANGLE_STRIP</constant>, <constant>GLU_TRIANGLES</constant>, or <constant>GLU_QUAD_STRIP</constant>. The
                        default begin callback function is NULL. The function prototype
                        for this callback looks like:
                        <programlisting>
void begin( GLenum type );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_BEGIN_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The same as the <constant>GLU_NURBS_BEGIN</constant> callback except that it takes an
                        additional pointer argument. This pointer is a copy of the pointer that
                        was specified at the last call to <function>gluNurbsCallbackData</function>.  The
                        default callback function is NULL. The function prototype for this
                        callback function looks like:
                        <programlisting>
void beginData(GLenum type, void *userData);
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_VERTEX</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The vertex callback indicates a vertex of the primitive. The
                        coordinates of the vertex are stored in the parameter ``vertex''. All
                        the generated vertices have dimension 3; that is, homogeneous
                        coordinates have been transformed into affine coordinates. The default
                        vertex callback function is NULL. The function prototype for this
                        callback function looks like:
                        <programlisting>
void vertex( GLfloat *vertex );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_VERTEX_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        This is the same as the <constant>GLU_NURBS_VERTEX</constant> callback, except that
                        it takes an additional pointer argument. This pointer is a copy of the
                        pointer that was specified at the last call to
                        <function>gluNurbsCallbackData</function>.  The default callback function is NULL. The
                        function prototype for this callback function looks like:
                        <programlisting>
void vertexData( GLfloat *vertex, void *userData );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_NORMAL</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The normal callback is invoked as the vertex normal is generated.
                        The components of the normal are stored in the parameter ``normal.''
                        In the case of a NURBS curve, the callback function is effective only when 
                        the user provides a normal map (<constant>GLU_MAP1_NORMAL</constant>).
                        In the case of a NURBS surface, if a normal map (<constant>GLU_MAP2_NORMAL</constant>)
                        is provided, then the generated normal is computed from the normal map.
                        If a normal map is not provided, then a surface normal is computed in
                        a manner similar to that described for evaluators when <constant>GLU_AUTO_NORMAL</constant>
                        is enabled. 
                        The default normal callback function is NULL. The function
                        prototype for this callback function looks like:
                        <programlisting>
void normal( GLfloat *normal );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_NORMAL_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The same as the <constant>GLU_NURBS_NORMAL</constant> callback except that it
                        takes an additional pointer argument. This pointer is a copy of the pointer
                        that was specified at the last call to <function>gluNurbsCallbackData</function>.  The default callback function is NULL. The function prototype for this callback function looks like:
                        <programlisting>
void normalData( GLfloat *normal, void *userData );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_COLOR</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The color callback is invoked as the color of a vertex is generated.
                        The components of the color are stored in the parameter ``color.''
                        This callback is effective only when the user provides a color map
                        (<constant>GLU_MAP1_COLOR_4</constant> or <constant>GLU_MAP2_COLOR_4</constant>). ``color'' contains four
                        components: R, G, B, A. The default color callback function is NULL.
                        The prototype for this callback function looks like:
                        <programlisting>
void color( GLfloat *color );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_COLOR_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The same as the <constant>GLU_NURBS_COLOR</constant> callback except that it
                        takes an additional pointer argument. This pointer is a copy of the pointer
                        that was specified at the last call to <function>gluNurbsCallbackData</function>.  The default callback function is NULL. The function prototype for this callback function looks like:
                        <programlisting>
void colorData( GLfloat *color, void *userData );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_TEXTURE_COORD</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The texture callback is invoked as the texture coordinates 
                        of a vertex are generated. These coordinates are stored in the parameter
                        ``texCoord.'' The number of texture coordinates can be 1, 2, 3, or 4 depending
                        on which type of texture map is specified 
                        (<constant>GLU_MAP1_TEXTURE_COORD_1</constant>,
                        <constant>GLU_MAP1_TEXTURE_COORD_2</constant>,
                        <constant>GLU_MAP1_TEXTURE_COORD_3</constant>,
                        <constant>GLU_MAP1_TEXTURE_COORD_4</constant>,
                        <constant>GLU_MAP2_TEXTURE_COORD_1</constant>,
                        <constant>GLU_MAP2_TEXTURE_COORD_2</constant>,
                        <constant>GLU_MAP2_TEXTURE_COORD_3</constant>,
                        <constant>GLU_MAP2_TEXTURE_COORD_4</constant>).
                        If no texture map is specified, this callback function will not be called.
                        The default texture callback function is NULL. The function prototype
                        for this callback function looks like:
                        <programlisting>
void texCoord( GLfloat *texCoord );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term> <constant>GLU_NURBS_TEXTURE_COORD_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        This is the same as the <constant>GLU_NURBS_TEXTURE_COORD</constant> callback, except that it
                        takes an additional pointer argument. This pointer is a copy of the pointer
                        that was specified at the last call to <function>gluNurbsCallbackData</function>.  The default callback function is NULL. The function prototype for this callback function looks like:
                        <programlisting>
void texCoordData( GLfloat *texCoord, void *userData );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_END</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The end callback is invoked at the end of a primitive. The default end callback function is NULL. The function prototype for this callback function looks like:
                        <programlisting>
void end( void );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_END_DATA</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        This is the same as the <constant>GLU_NURBS_END</constant> callback, except that it
                        takes an additional pointer argument. This pointer is a copy of the pointer
                        that was specified at the last call to <function>gluNurbsCallbackData</function>.  The default callback function is NULL. The function prototype for this callback function looks like:
                        <programlisting>
void endData( void  *userData );
                        </programlisting>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term><constant>GLU_NURBS_ERROR</constant></term>
                <listitem>
                    <para>
                    </para>
                    <para>
                        The error function is called when an error is encountered.
                        Its single argument
                        is of type GLenum, and it indicates the specific error that occurred.
                        There are 37 errors unique to NURBS, named
                        <constant>GLU_NURBS_ERROR1</constant> through <constant>GLU_NURBS_ERROR37</constant>. 
                        Character strings describing these errors can be retrieved with
                        <citerefentry><refentrytitle>gluErrorString</refentrytitle></citerefentry>.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <function>gluNurbsCallback</function> is available only if the GLU version is 1.2 or greater.
        </para>
        <para>
            GLU version 1.2 supports only the <constant>GLU_ERROR</constant> parameter for
            <parameter>which</parameter>. The <constant>GLU_ERROR</constant> value is deprecated in GLU version 1.3 in
            favor of <constant>GLU_NURBS_ERROR</constant>.  All other accepted values for <parameter>CallBackFunc</parameter>
            are available only if the GLU version is 1.3 or greater.
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>gluErrorString</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>gluNewNurbsRenderer</refentrytitle></citerefentry>,
            <function>gluNurbsCallbackData</function>,
            <citerefentry><refentrytitle>gluNurbsProperty</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 1991-2006
            Silicon Graphics, Inc. This document is licensed under the SGI
            Free Software B License. For details, see
            <ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
        </para>
    </refsect1>
</refentry>
