
<refentry id="glMapGrid">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glMapGrid</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glMapGrid</refname>
        <refpurpose>define a one- or two-dimensional mesh</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glMapGrid1d</function></funcdef>
                <paramdef>GLint <parameter>un</parameter></paramdef>
                <paramdef>GLdouble <parameter>u1</parameter></paramdef>
                <paramdef>GLdouble <parameter>u2</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glMapGrid1f</function></funcdef>
                <paramdef>GLint <parameter>un</parameter></paramdef>
                <paramdef>GLfloat <parameter>u1</parameter></paramdef>
                <paramdef>GLfloat <parameter>u2</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glMapGrid2d</function></funcdef>
                <paramdef>GLint <parameter>un</parameter></paramdef>
                <paramdef>GLdouble <parameter>u1</parameter></paramdef>
                <paramdef>GLdouble <parameter>u2</parameter></paramdef>
                <paramdef>GLint <parameter>vn</parameter></paramdef>
                <paramdef>GLdouble <parameter>v1</parameter></paramdef>
                <paramdef>GLdouble <parameter>v2</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glMapGrid2f</function></funcdef>
                <paramdef>GLint <parameter>un</parameter></paramdef>
                <paramdef>GLfloat <parameter>u1</parameter></paramdef>
                <paramdef>GLfloat <parameter>u2</parameter></paramdef>
                <paramdef>GLint <parameter>vn</parameter></paramdef>
                <paramdef>GLfloat <parameter>v1</parameter></paramdef>
                <paramdef>GLfloat <parameter>v2</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>un</parameter></term>
            <listitem>
                <para>
                    Specifies the number of partitions in the grid range interval
                    [<parameter>u1</parameter>, <parameter>u2</parameter>].
                    Must be positive.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>u1</parameter></term>
            <term><parameter>u2</parameter></term>
            <listitem>
                <para>
                    Specify the mappings for integer grid domain values 
                    <inlineequation><mml:math>
                        <!-- eqn: i = 0:-->
                        <mml:mrow>
                            <mml:mi mathvariant="italic">i</mml:mi>
                            <mml:mo>=</mml:mo>
                            <mml:mn>0</mml:mn>
                        </mml:mrow>
                    </mml:math></inlineequation>
                    and 
                    <inlineequation><mml:math>
                        <!-- eqn: i = un:-->
                        <mml:mrow>
                            <mml:mi mathvariant="italic">i</mml:mi>
                            <mml:mo>=</mml:mo>
                            <mml:mi mathvariant="italic">un</mml:mi>
                        </mml:mrow>
                    </mml:math></inlineequation>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>vn</parameter></term>
            <listitem>
                <para>
                    Specifies the number of partitions in the grid range interval
                    [<parameter>v1</parameter>, <parameter>v2</parameter>]
                    (<function>glMapGrid2</function> only).
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>v1</parameter></term>
            <term><parameter>v2</parameter></term>
            <listitem>
                <para>
                    Specify the mappings for integer grid domain values 
                    <inlineequation><mml:math>
                        <!-- eqn: j = 0:-->
                        <mml:mrow>
                            <mml:mi mathvariant="italic">j</mml:mi>
                            <mml:mo>=</mml:mo>
                            <mml:mn>0</mml:mn>
                        </mml:mrow>
                    </mml:math></inlineequation>
                    and 
                    <inlineequation><mml:math>
                        <!-- eqn: j = vn:-->
                        <mml:mrow>
                            <mml:mi mathvariant="italic">j</mml:mi>
                            <mml:mo>=</mml:mo>
                            <mml:mi mathvariant="italic">vn</mml:mi>
                        </mml:mrow>
                    </mml:math></inlineequation>
                    (<function>glMapGrid2</function> only).
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glMapGrid</function> and <citerefentry><refentrytitle>glEvalMesh</refentrytitle></citerefentry> are used together to efficiently
            generate and evaluate a series of evenly-spaced map domain values.
            <citerefentry><refentrytitle>glEvalMesh</refentrytitle></citerefentry> steps through the integer domain
            of a one- or two-dimensional grid,
            whose range is the domain of the evaluation maps specified by
            <citerefentry><refentrytitle>glMap1</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glMap2</refentrytitle></citerefentry>.
        </para>
        <para>
            <function>glMapGrid1</function> and <function>glMapGrid2</function> specify the linear grid mappings
            between the 
            <inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>
            (or 
            <inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>
            and 
            <inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>)
            integer grid coordinates,
            to the 
            <inlineequation><mml:math><mml:mi mathvariant="italic">u</mml:mi></mml:math></inlineequation>
            (or 
            <inlineequation><mml:math><mml:mi mathvariant="italic">u</mml:mi></mml:math></inlineequation>
            and 
            <inlineequation><mml:math><mml:mi mathvariant="italic">v</mml:mi></mml:math></inlineequation>)
            floating-point evaluation map coordinates.
            See <citerefentry><refentrytitle>glMap1</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glMap2</refentrytitle></citerefentry> for details of how 
            <inlineequation><mml:math><mml:mi mathvariant="italic">u</mml:mi></mml:math></inlineequation>
            and 
            <inlineequation><mml:math><mml:mi mathvariant="italic">v</mml:mi></mml:math></inlineequation>
            coordinates
            are evaluated.
        </para>
        <para>
            <function>glMapGrid1</function> specifies a single linear mapping
            such that integer grid coordinate 0 maps exactly to <parameter>u1</parameter>,
            and integer grid coordinate <parameter>un</parameter> maps exactly to <parameter>u2</parameter>.
            All other integer grid coordinates 
            <inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>
            are mapped so that
        </para>
        <para>
            <informalequation><mml:math>
                <!-- eqn: u  =  i (u2 - u1) / un  +  u1:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">u</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:mfrac>
                            <mml:mrow>
                                <mml:mi mathvariant="italic">i</mml:mi>
                                <mml:mo>&af;</mml:mo>
                                <mml:mfenced open="(" close=")">
                                    <mml:mrow>
                                        <mml:mi mathvariant="italic">u2</mml:mi>
                                        <mml:mo>-</mml:mo>
                                        <mml:mi mathvariant="italic">u1</mml:mi>
                                    </mml:mrow>
                                </mml:mfenced>
                            </mml:mrow>
                            <mml:mi mathvariant="italic">un</mml:mi>
                        </mml:mfrac>
                        <mml:mo>+</mml:mo>
                        <mml:mi mathvariant="italic">u1</mml:mi>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></informalequation>
        </para>
        <para>
            <function>glMapGrid2</function> specifies two such linear mappings.
            One maps integer grid coordinate 
            <inlineequation><mml:math>
                <!-- eqn: i = 0:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">i</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mn>0</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>
            exactly to <parameter>u1</parameter>,
            and integer grid coordinate 
            <inlineequation><mml:math>
                <!-- eqn: i = un:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">i</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mi mathvariant="italic">un</mml:mi>
                </mml:mrow>
            </mml:math></inlineequation>
            exactly to <parameter>u2</parameter>.
            The other maps integer grid coordinate 
            <inlineequation><mml:math>
                <!-- eqn: j = 0:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">j</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mn>0</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>
            exactly to <parameter>v1</parameter>,
            and integer grid coordinate 
            <inlineequation><mml:math>
                <!-- eqn: j = vn:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">j</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mi mathvariant="italic">vn</mml:mi>
                </mml:mrow>
            </mml:math></inlineequation>
            exactly to <parameter>v2</parameter>.
            Other integer grid coordinates 
            <inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>
            and 
            <inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>
            are mapped such that
        </para>
        <para>
            <informalequation><mml:math>
                <!-- eqn: u  =  i (u2 - u1) / un  +  u1:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">u</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:mfrac>
                            <mml:mrow>
                                <mml:mi mathvariant="italic">i</mml:mi>
                                <mml:mo>&af;</mml:mo>
                                <mml:mfenced open="(" close=")">
                                    <mml:mrow>
                                        <mml:mi mathvariant="italic">u2</mml:mi>
                                        <mml:mo>-</mml:mo>
                                        <mml:mi mathvariant="italic">u1</mml:mi>
                                    </mml:mrow>
                                </mml:mfenced>
                            </mml:mrow>
                            <mml:mi mathvariant="italic">un</mml:mi>
                        </mml:mfrac>
                        <mml:mo>+</mml:mo>
                        <mml:mi mathvariant="italic">u1</mml:mi>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></informalequation>
        </para>
        <para>
            <informalequation><mml:math>
                <!-- eqn: v  =  j (v2 - v1) / vn  +  v1:-->
                <mml:mrow>
                    <mml:mi mathvariant="italic">v</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:mfrac>
                            <mml:mrow>
                                <mml:mi mathvariant="italic">j</mml:mi>
                                <mml:mo>&af;</mml:mo>
                                <mml:mfenced open="(" close=")">
                                    <mml:mrow>
                                        <mml:mi mathvariant="italic">v2</mml:mi>
                                        <mml:mo>-</mml:mo>
                                        <mml:mi mathvariant="italic">v1</mml:mi>
                                    </mml:mrow>
                                </mml:mfenced>
                            </mml:mrow>
                            <mml:mi mathvariant="italic">vn</mml:mi>
                        </mml:mfrac>
                        <mml:mo>+</mml:mo>
                        <mml:mi mathvariant="italic">v1</mml:mi>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></informalequation>
        </para>
        <para>
            The mappings specified by <function>glMapGrid</function> are used identically by
            <citerefentry><refentrytitle>glEvalMesh</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glEvalPoint</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if either <parameter>un</parameter> or <parameter>vn</parameter> is not
            positive.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function>glMapGrid</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_MAP1_GRID_DOMAIN</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAP2_GRID_DOMAIN</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAP1_GRID_SEGMENTS</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAP2_GRID_SEGMENTS</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glEvalCoord</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glEvalMesh</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glEvalPoint</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glMap1</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glMap2</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>
