<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
              "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id="gluBuild1DMipmaps">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>gluBuild1DMipmaps</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>gluBuild1DMipmaps</refname>
        <refpurpose>builds a one-dimensional mipmap</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>GLint <function>gluBuild1DMipmaps</function></funcdef>
                <paramdef>GLenum <parameter>target</parameter></paramdef>
                <paramdef>GLint <parameter>internalFormat</parameter></paramdef>
                <paramdef>GLsizei <parameter>width</parameter></paramdef>
                <paramdef>GLenum <parameter>format</parameter></paramdef>
                <paramdef>GLenum <parameter>type</parameter></paramdef>
                <paramdef>const void * <parameter>data</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>target</parameter></term>
            <listitem>
                <para>
                    Specifies the target texture.  Must be <constant>GLU_TEXTURE_1D</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>internalFormat</parameter></term>
            <listitem>
                <para>
                    Requests the internal storage format of the texture image.  The most
                    current version of the SGI implementation of GLU does not check this
                    value for validity before passing it on to the underlying OpenGL
                    implementation.  A value that is not accepted by the OpenGL
                    implementation will lead to an OpenGL error.  The benefit of not
                    checking this value at the GLU level is that OpenGL extensions can add
                    new internal texture formats without requiring a revision of the GLU
                    implementation.  Older implementations of GLU check this value and
                    raise a GLU error if it is not 1, 2, 3, or 4 or one of the following
                    symbolic constants:
                    <constant>GLU_ALPHA</constant>,
                    <constant>GLU_ALPHA4</constant>,
                    <constant>GLU_ALPHA8</constant>,
                    <constant>GLU_ALPHA12</constant>,
                    <constant>GLU_ALPHA16</constant>,
                    <constant>GLU_LUMINANCE</constant>,
                    <constant>GLU_LUMINANCE4</constant>,
                    <constant>GLU_LUMINANCE8</constant>,
                    <constant>GLU_LUMINANCE12</constant>,
                    <constant>GLU_LUMINANCE16</constant>,
                    <constant>GLU_LUMINANCE_ALPHA</constant>,
                    <constant>GLU_LUMINANCE4_ALPHA4</constant>,
                    <constant>GLU_LUMINANCE6_ALPHA2</constant>,
                    <constant>GLU_LUMINANCE8_ALPHA8</constant>,
                    <constant>GLU_LUMINANCE12_ALPHA4</constant>,
                    <constant>GLU_LUMINANCE12_ALPHA12</constant>,
                    <constant>GLU_LUMINANCE16_ALPHA16</constant>,
                    <constant>GLU_INTENSITY</constant>,
                    <constant>GLU_INTENSITY4</constant>,
                    <constant>GLU_INTENSITY8</constant>,
                    <constant>GLU_INTENSITY12</constant>,
                    <constant>GLU_INTENSITY16</constant>,
                    <constant>GLU_RGB</constant>,
                    <constant>GLU_R3_G3_B2</constant>,
                    <constant>GLU_RGB4</constant>,
                    <constant>GLU_RGB5</constant>,
                    <constant>GLU_RGB8</constant>,
                    <constant>GLU_RGB10</constant>,
                    <constant>GLU_RGB12</constant>,
                    <constant>GLU_RGB16</constant>,
                    <constant>GLU_RGBA</constant>,
                    <constant>GLU_RGBA2</constant>,
                    <constant>GLU_RGBA4</constant>,
                    <constant>GLU_RGB5_A1</constant>,
                    <constant>GLU_RGBA8</constant>,
                    <constant>GLU_RGB10_A2</constant>,
                    <constant>GLU_RGBA12</constant>, or
                    <constant>GLU_RGBA16</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>width</parameter></term>
            <listitem>
                <para>
                    Specifies the width, in pixels, of the texture image. 
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>format</parameter></term>
            <listitem>
                <para>
                    Specifies the format of the pixel data.
                    Must be one of
                    <constant>GLU_COLOR_INDEX</constant>,
                    <constant>GLU_DEPTH_COMPONENT</constant>,
                    <constant>GLU_RED</constant>,
                    <constant>GLU_GREEN</constant>,
                    <constant>GLU_BLUE</constant>,
                    <constant>GLU_ALPHA</constant>,
                    <constant>GLU_RGB</constant>,
                    <constant>GLU_RGBA</constant>,
                    <constant>GLU_BGR</constant>,
                    <constant>GLU_BGRA</constant>,
                    <constant>GLU_LUMINANCE</constant>, or
                    <constant>GLU_LUMINANCE_ALPHA</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>type</parameter></term>
            <listitem>
                <para>
                    Specifies the data type for <parameter>data</parameter>.
                    Must be one of
                    <constant>GLU_UNSIGNED_BYTE</constant>,
                    <constant>GLU_BYTE</constant>,
                    <constant>GLU_BITMAP</constant>,
                    <constant>GLU_UNSIGNED_SHORT</constant>,
                    <constant>GLU_SHORT</constant>,
                    <constant>GLU_UNSIGNED_INT</constant>,
                    <constant>GLU_INT</constant>, 
                    <constant>GLU_FLOAT</constant>, 
                    <constant>GLU_UNSIGNED_BYTE_3_3_2</constant>,
                    <constant>GLU_UNSIGNED_BYTE_2_3_3_REV</constant>,
                    <constant>GLU_UNSIGNED_SHORT_5_6_5</constant>,
                    <constant>GLU_UNSIGNED_SHORT_5_6_5_REV</constant>,
                    <constant>GLU_UNSIGNED_SHORT_4_4_4_4</constant>,
                    <constant>GLU_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
                    <constant>GLU_UNSIGNED_SHORT_5_5_5_1</constant>,
                    <constant>GLU_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
                    <constant>GLU_UNSIGNED_INT_8_8_8_8</constant>,
                    <constant>GLU_UNSIGNED_INT_8_8_8_8_REV</constant>,
                    <constant>GLU_UNSIGNED_INT_10_10_10_2</constant>, or
                    <constant>GLU_UNSIGNED_INT_2_10_10_10_REV</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>data</parameter></term>
            <listitem>
                <para>
                    Specifies a pointer to the image data in memory.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>gluBuild1DMipmaps</function> builds a series of prefiltered one-dimensional texture maps of decreasing
            resolutions called a mipmap. This is used for the antialiasing of
            texture mapped primitives.
        </para>
        <para>
            A return value of zero indicates success, otherwise a GLU error code is
            returned (see <citerefentry><refentrytitle>gluErrorString</refentrytitle></citerefentry>).
        </para>
        <para>
            Initially, the <parameter>width</parameter> of <parameter>data</parameter> is checked to see if it is
            a power of 2. If not, a copy of <parameter>data</parameter> is scaled up or down to the
            nearest power of 2. (If <parameter>width</parameter> is exactly between powers of 2, then
            the copy of <parameter>data</parameter> will scale upwards.)  This copy will be used for
            subsequent mipmapping operations described below. 
            For example, if <parameter>width</parameter> is 57, then a copy of <parameter>data</parameter>
            will scale up to 64 before mipmapping
            takes place.
        </para>
        <para>
            Then, proxy textures (see <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry>) are used to determine if
            the implementation can fit the requested texture. If not, <parameter>width</parameter> is
            continually halved until it fits.
        </para>
        <para>
            Next, a series of mipmap levels is built by decimating a copy of
            <parameter>data</parameter> in half
            until size 
            <inlineequation><mml:math>
                <!-- eqn: 1  times  1:-->
                <mml:mrow>
                    <mml:mn>1</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>
            is reached. At each level, each texel in the
            halved mipmap level is an average of the corresponding two texels in the larger
            mipmap level.
        </para>
        <para>
            <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry> is called to load each of these mipmap levels.
            Level 0 is a copy of <parameter>data</parameter>. 
            The highest level is 
            <inlineequation><mml:math>
                <!-- eqn: {log sub 2}(width):-->
                <mml:mrow>
                    <mml:mfenced open="" close="">
                        <mml:msub><mml:mi mathvariant="italic">log</mml:mi>
                        <mml:mn>2</mml:mn>
                        </mml:msub>
                    </mml:mfenced>
                    <mml:mo>&af;</mml:mo>
                    <mml:mfenced open="(" close=")">
                        <mml:mi mathvariant="italic">width</mml:mi>
                    </mml:mfenced>
                </mml:mrow>
            </mml:math></inlineequation>.
            For example, if <parameter>width</parameter> is 64 and the implementation can store a texture of
            this size, the following mipmap levels are
            built: 
            <inlineequation><mml:math>
                <!-- eqn: 64  times  1:-->
                <mml:mrow>
                    <mml:mn>64</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>, 
            <inlineequation><mml:math>
                <!-- eqn: 32  times  1:-->
                <mml:mrow>
                    <mml:mn>32</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>, 
            <inlineequation><mml:math>
                <!-- eqn: 16  times  1:-->
                <mml:mrow>
                    <mml:mn>16</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>, 
            <inlineequation><mml:math>
                <!-- eqn: 8  times  1:-->
                <mml:mrow>
                    <mml:mn>8</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>,
            <inlineequation><mml:math>
                <!-- eqn: 4  times  1:-->
                <mml:mrow>
                    <mml:mn>4</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>, 
            <inlineequation><mml:math>
                <!-- eqn: 2  times  1:-->
                <mml:mrow>
                    <mml:mn>2</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>,
            and 
            <inlineequation><mml:math>
                <!-- eqn: 1  times  1:-->
                <mml:mrow>
                    <mml:mn>1</mml:mn>
                    <mml:mo>&times;</mml:mo>
                    <mml:mn>1</mml:mn>
                </mml:mrow>
            </mml:math></inlineequation>.
            These correspond to 
            levels 0 through 6, respectively.
        </para>
        <para>
            See the <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry> reference page for a description of the
            acceptable values for the <parameter>type</parameter> parameter. See the <citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry> 
            reference page for a description of the acceptable values 
            for the <parameter>data</parameter> parameter.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            Note that there is no direct way of querying the maximum level. This can
            be derived indirectly via <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry>. First, query
            for the
            width actually used at level 0. 
            (The width may not be equal to <parameter>width</parameter> since
            proxy textures might have scaled it to fit the implementation.)
            Then the maximum
            level can be derived from the formula 
            <inlineequation><mml:math>
                <!-- eqn: {log sub 2}(width):-->
                <mml:mrow>
                    <mml:mfenced open="" close="">
                        <mml:msub><mml:mi mathvariant="italic">log</mml:mi>
                        <mml:mn>2</mml:mn>
                        </mml:msub>
                    </mml:mfenced>
                    <mml:mo>&af;</mml:mo>
                    <mml:mfenced open="(" close=")">
                        <mml:mi mathvariant="italic">width</mml:mi>
                    </mml:mfenced>
                </mml:mrow>
            </mml:math></inlineequation>.
        </para>
        <para>
            Formats <constant>GLU_BGR</constant>, and <constant>GLU_BGRA</constant>, and types 
            <constant>GLU_UNSIGNED_BYTE_3_3_2</constant>,
            <constant>GLU_UNSIGNED_BYTE_2_3_3_REV</constant>,
            <constant>GLU_UNSIGNED_SHORT_5_6_5</constant>,
            <constant>GLU_UNSIGNED_SHORT_5_6_5_REV</constant>,
            <constant>GLU_UNSIGNED_SHORT_4_4_4_4</constant>,
            <constant>GLU_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
            <constant>GLU_UNSIGNED_SHORT_5_5_5_1</constant>,
            <constant>GLU_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
            <constant>GLU_UNSIGNED_INT_8_8_8_8</constant>,
            <constant>GLU_UNSIGNED_INT_8_8_8_8_REV</constant>,
            <constant>GLU_UNSIGNED_INT_10_10_10_2</constant>, and
            <constant>GLU_UNSIGNED_INT_2_10_10_10_REV</constant> are only available if the GL version 
            is 1.2 or greater, and if the GLU version is 1.3 or greater.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GLU_INVALID_VALUE</constant> is returned if <parameter>width</parameter> is &lt; 1.
        </para>
        <para>
            <constant>GLU_INVALID_ENUM</constant> is returned if <parameter>format</parameter> or <parameter>type</parameter> are not legal.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_BYTE_3_3_2</constant> or <constant>GLU_UNSIGNED_BYTE_2_3_3_REV</constant>
            and <parameter>format</parameter> is not <constant>GLU_RGB</constant>.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_SHORT_5_6_5</constant> or <constant>GLU_UNSIGNED_SHORT_5_6_5_REV</constant>
            and <parameter>format</parameter> is not <constant>GLU_RGB</constant>.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_SHORT_4_4_4_4</constant> or <constant>GLU_UNSIGNED_SHORT_4_4_4_4_REV</constant>
            and <parameter>format</parameter> is neither <constant>GLU_RGBA</constant> nor <constant>GLU_BGRA</constant>.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_SHORT_5_5_5_1</constant> or <constant>GLU_UNSIGNED_SHORT_1_5_5_5_REV</constant>
            and <parameter>format</parameter> is neither <constant>GLU_RGBA</constant> nor <constant>GLU_BGRA</constant>.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_INT_8_8_8_8</constant> or <constant>GLU_UNSIGNED_INT_8_8_8_8_REV</constant>
            and <parameter>format</parameter> is neither <constant>GLU_RGBA</constant> nor <constant>GLU_BGRA</constant>.
        </para>
        <para>
            <constant>GLU_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is <constant>GLU_UNSIGNED_INT_10_10_10_2</constant> or <constant>GLU_UNSIGNED_INT_2_10_10_10_REV</constant>
            and <parameter>format</parameter> is neither <constant>GLU_RGBA</constant> nor <constant>GLU_BGRA</constant>.
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>gluBuild1DMipmapLevels</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>gluBuild2DMipmapLevels</refentrytitle></citerefentry>, 
            <citerefentry><refentrytitle>gluBuild2DMipmaps</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>gluBuild3DMipmapLevels</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>gluBuild3DMipmaps</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>gluErrorString</refentrytitle></citerefentry>, 
            <citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetTexImage</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry>, 
            <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry>, 
            <citerefentry><refentrytitle>glTexImage3D</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>