<!DOCTYPE refentry [ <!ENTITY % mathent SYSTEM "math.ent"> %mathent; ]>

<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="glGenerateMipmap">
    <info>
        <copyright>
            <year>2010-2014</year>
            <holder>Khronos Group</holder>
        </copyright>
    </info>
    <refmeta>
        <refentrytitle>glGenerateMipmap</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glGenerateMipmap</refname>
        <refname>glGenerateTextureMipmap</refname>
        <refpurpose>generate mipmaps for a specified texture object</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glGenerateMipmap</function></funcdef>
                <paramdef>GLenum <parameter>target</parameter></paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>void <function>glGenerateTextureMipmap</function></funcdef>
                <paramdef>GLuint <parameter>texture</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 xml:id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>target</parameter></term>
            <listitem>
                <para>
                    Specifies the target to which the texture object is
                    bound for <function>glGenerateMipmap</function>. Must be
                    one of <constant>GL_TEXTURE_1D</constant>,
                    <constant>GL_TEXTURE_2D</constant>,
                    <constant>GL_TEXTURE_3D</constant>,
                    <constant>GL_TEXTURE_1D_ARRAY</constant>,
                    <constant>GL_TEXTURE_2D_ARRAY</constant>,
                    <constant>GL_TEXTURE_CUBE_MAP</constant>, or
                    <constant>GL_TEXTURE_CUBE_MAP_ARRAY</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>texture</parameter></term>
            <listitem>
                <para>
                    Specifies the texture object name for
                    <function>glGenerateTextureMipmap</function>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 xml:id="description"><title>Description</title>
        <para>
            <function>glGenerateMipmap</function> and
            <function>glGenerateTextureMipmap</function> generates mipmaps
            for the specified texture object. For
            <function>glGenerateMipmap</function>, the texture object
            that is bound to <parameter>target</parameter>. For
            <function>glGenerateTextureMipmap</function>,
            <parameter>texture</parameter> is the name of the texture
            object.
        </para>
        <para>
            For cube map and cube map array textures, the texture object
            must be cube complete or cube array complete respectively.
        </para>
        <para>
            Mipmap generation replaces texel image levels $level_{base} + 1$
            through $q$ with images derived from the $level_{base}$ image,
            regardless of their previous contents. All other mimap images,
            including the $level_{base}+1$ image, are left unchanged by this
            computation.
        </para>
        <para>
            The internal formats of the derived mipmap images all match
            those of the $level_{base}$ image. The contents of the derived
            images are computed by repeated, filtered reduction of the
            $level_{base} + 1$ image. For one- and two-dimensional array and
            cube map array textures, each layer is filtered independently.
        </para>
    </refsect1>
    <refsect1 xml:id="notes"><title>Notes</title>
        <para>
            Cube map array textures are accepted only if the GL version is
            4.0 or higher.
        </para>
    </refsect1>
    <refsect1 xml:id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated by
            <function>glGenerateMipmap</function> if
            <parameter>target</parameter> is not one of the accepted texture
            targets.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated by
            <function>glGenerateTextureMipmap</function> if
            <parameter>texture</parameter> is not the name of an existing
            texture object.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if
            <parameter>target</parameter> is
            <constant>GL_TEXTURE_CUBE_MAP</constant> or
            <constant>GL_TEXTURE_CUBE_MAP_ARRAY</constant>, and the
            specified texture object is not cube complete or cube array
            complete, respectively.
        </para>
    </refsect1>
    <refsect1 xml:id="versions"><title>Version Support</title>
        <informaltable>
            <tgroup cols="13" align="left">
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="apifunchead.xml" xpointer="xpointer(/*/*)"/>
                <tbody>
                    <row>
                        <entry><function>glGenerateMipmap</function></entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="apiversion.xml" xpointer="xpointer(/*/*[@role='30']/*)"/>
                    </row>
                    <row>
                        <entry><function>glGenerateTextureMipmap</function></entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="apiversion.xml" xpointer="xpointer(/*/*[@role='45']/*)"/>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
    </refsect1>
    <refsect1 xml:id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBindTexture</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGenTextures</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 xml:id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"/> 2010-2014 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://opencontent.org/openpub/">http://opencontent.org/openpub/</link>.
        </para>
    </refsect1>
</refentry>
