<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:mml="http://www.w3.org/1998/Math/MathML"
><head><title>gluBuild3DMipmaps</title><link rel="stylesheet" href="style.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"/><link rel="home" href="index.xml" title="PyOpenGL 2.0.1.07 Man Pages"/><link rel="up" href="reference-GLU.xml" title="GLU"/><link rel="previous" href="gluBuild3DMipmapLevels.3G.xml" title="gluBuild3DMipmapLevels"/><link rel="next" href="gluCheckExtension.3G.xml" title="gluCheckExtension"/></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gluBuild3DMipmaps</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gluBuild3DMipmapLevels.3G.xml">Prev</a> </td><th width="60%" align="center">GLU</th><td width="20%" align="right"> <a accesskey="n" href="gluCheckExtension.3G.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="gluBuild3DMipmaps.3G"/><div class="titlepage"/><div class="refnamediv"><a name="gluBuild3DMipmaps.3G-name"/><h2>Name</h2><p>gluBuild3DMipmaps, gluBuild3DMipmapsb, gluBuild3DMipmapsf, gluBuild3DMipmapsi, gluBuild3DMipmapss, gluBuild3DMipmapsub, gluBuild3DMipmapsui, gluBuild3DMipmapsus &#8212; builds a three-dimensional mipmap</p></div><div class="refsynopsisdiv"><a name="gluBuild3DMipmaps.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>GLint <tt>gluBuild3DMipmaps</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>target</tt></i>, GLint <i><tt>internalFormat</tt></i>, GLsizei <i><tt>width</tt></i>, GLsizei <i><tt>height</tt></i>, GLsizei <i><tt>depth</tt></i>, GLenum <i><tt>format</tt></i>, GLenum <i><tt>type</tt></i>, const void *<i><tt>data</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="gluBuild3DMipmaps.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>gluBuild3DMipmaps</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>depth</tt></i>, <i><tt>format</tt></i>, <i><tt>type</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsb</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsf</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsi</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapss</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsub</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsui</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>gluBuild3DMipmapsus</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>internalFormat</tt></i>, <i><tt>format</tt></i>, <i><tt>data</tt></i>) &#8594; <tt>None</tt></code></td></tr></table></div><div class="refsect1" lang="en"><a name="gluBuild3DMipmaps.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>target</tt></i></span></dt><dd>
						Specifies the target texture. Must be <tt>GL_TEXTURE_3D</tt>.
					</dd><dt><span class="term"><i><tt>internalFormat</tt></i></span></dt><dd>
						Requests the internal storage format of the texture image. Must be 1, 2, 3, 4, or one of the following
						symbolic constants: <tt>GL_ALPHA</tt>, <tt>GL_ALPHA4</tt>,
						<tt>GL_ALPHA8</tt>, <tt>GL_ALPHA12</tt>, <tt>GL_ALPHA16</tt>,
						<tt>GL_LUMINANCE</tt>, <tt>GL_LUMINANCE4</tt>, <tt>GL_LUMINANCE8</tt>,
						<tt>GL_LUMINANCE12</tt>, <tt>GL_LUMINANCE16</tt>,
						<tt>GL_LUMINANCE_ALPHA</tt>, <tt>GL_LUMINANCE4_ALPHA4</tt>,
						<tt>GL_LUMINANCE6_ALPHA2</tt>, <tt>GL_LUMINANCE8_ALPHA8</tt>,
						<tt>GL_LUMINANCE12_ALPHA4</tt>, <tt>GL_LUMINANCE12_ALPHA12</tt>,
						<tt>GL_LUMINANCE16_ALPHA16</tt>, <tt>GL_INTENSITY</tt>,
						<tt>GL_INTENSITY4</tt>, <tt>GL_INTENSITY8</tt>,
						<tt>GL_INTENSITY12</tt>, <tt>GL_INTENSITY16</tt>, <tt>GL_RGB</tt>,
						<tt>GL_R3_G3_B2</tt>, <tt>GL_RGB4</tt>, <tt>GL_RGB5</tt>,
						<tt>GL_RGB8</tt>, <tt>GL_RGB10</tt>, <tt>GL_RGB12</tt>,
						<tt>GL_RGB16</tt>, <tt>GL_RGBA</tt>, <tt>GL_RGBA2</tt>,
						<tt>GL_RGBA4</tt>, <tt>GL_RGB5_A1</tt>, <tt>GL_RGBA8</tt>,
						<tt>GL_RGB10_A2</tt>, <tt>GL_RGBA12</tt>, or <tt>GL_RGBA16</tt>.
					</dd><dt><span class="term"><i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>depth</tt></i></span></dt><dd>
						Specifies in pixels the width, height and depth respectively, in pixels of the texture image.
					</dd><dt><span class="term"><i><tt>format</tt></i></span></dt><dd>
						Specifies the format of the pixel data. Must be one of <tt>GL_COLOR_INDEX</tt>,
						<tt>GL_DEPTH_COMPONENT</tt>, <tt>GL_RED</tt>, <tt>GL_GREEN</tt>,
						<tt>GL_BLUE</tt>, <tt>GL_ALPHA</tt>, <tt>GL_RGB</tt>,
						<tt>GL_RGBA</tt>, <tt>GL_BGR</tt>, <tt>GL_BGRA</tt>,
						<tt>GL_LUMINANCE</tt>, or <tt>GL_LUMINANCE_ALPHA</tt>.
					</dd><dt><span class="term"><i><tt>type</tt></i></span></dt><dd>
						Specifies the data type for <i><tt>data</tt></i>. Must be one of:
						<tt>GL_UNSIGNED_BYTE</tt>, <tt>GL_BYTE</tt>, <tt>GL_BITMAP</tt>,
						<tt>GL_UNSIGNED_SHORT</tt>, <tt>GL_SHORT</tt>,
						<tt>GL_UNSIGNED_INT</tt>, <tt>GL_INT</tt>, <tt>GL_FLOAT</tt>,
						<tt>GL_UNSIGNED_BYTE_3_3_2</tt>, <tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt>,
						<tt>GL_UNSIGNED_SHORT_5_6_5</tt>, <tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt>,
						<tt>GL_UNSIGNED_SHORT_4_4_4_4</tt>, <tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt>,
						<tt>GL_UNSIGNED_SHORT_5_5_5_1</tt>, <tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt>,
						<tt>GL_UNSIGNED_INT_8_8_8_8</tt>, <tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt>,
						<tt>GL_UNSIGNED_INT_10_10_10_2</tt>, or <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt>.
					</dd><dt><span class="term"><i><tt>data</tt></i></span></dt><dd>
						Specifies a pointer to the image data in memory.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="gluBuild3DMipmaps.3G-description"/><h2>Description</h2><p>
			<tt>gluBuild3DMipmaps</tt> builds a series of prefiltered three-dimensional texture maps of decreasing
			resolutions called a mipmap. This is used for the antialiasing of texture-mapped primitives.
		</p><p>
			A return value of zero indicates success, otherwise a GLU error code is returned (see <a href="gluErrorString.3G.xml">gluErrorString</a>).
		</p><p>
			Initially, the <i><tt>width</tt></i>, <i><tt>height</tt></i> and <i><tt>depth</tt></i> of
			<i><tt>data</tt></i> are checked to see if they are a power of 2. If not, a copy of <i><tt>data</tt></i>
			(not <i><tt>data</tt></i>), is scaled up or down to the nearest power of 2. (If <i><tt>width</tt></i>,
			<i><tt>height</tt></i> or <i><tt>depth</tt></i> is exactly between powers of 2, then the copy of
			<i><tt>data</tt></i> will scale upwards.) This copy will be used for subsequent mipmapping operations described
			below. For example, if <i><tt>width</tt></i> is 57, <i><tt>height</tt></i> is 23 and
			<i><tt>depth</tt></i> is 24 then a copy of <i><tt>data</tt></i> will scale up to 64 in width, down to 16
			in height and up to 32 in depth, before mipmapping takes place.
		</p><p>
			Then, proxy textures (see <a href="glTexImage3D.3G.xml">glTexImage3D</a>) are used to determine if the implementation can fit the requested texture. If not, all three
			dimensions are continually halved until it fits.
		</p><p>
			Next, a series of mipmap levels is built by decimating a copy of <i><tt>data</tt></i> in half along all three
			dimensions until size <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
					</mml:mrow>
				</mml:math> is reached. At each level, each texel in the halved mipmap level is an average of the corresponding
			eight texels in the larger mipmap level. (If exactly one of the dimensions is 1, four texels are averaged. If exactly
			two of the dimensions are 1, two texels are averaged.)
		</p><p>
			<a href="glTexImage3D.3G.xml"><tt>glTexImage3D</tt></a> is called to load each of these mipmap levels. Level 0 is a copy
			of <i><tt>data</tt></i>. The highest level is <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:msub>
							<mml:mi>log</mml:mi>
							<mml:mn>2</mml:mn>
						</mml:msub>
						<mml:mo>(</mml:mo>
						<mml:mi>max</mml:mi>
						<mml:mo>(</mml:mo>
						<mml:mi>width</mml:mi>
						<mml:mi>height</mml:mi>
						<mml:mi>depth</mml:mi>
						<mml:mo>)</mml:mo>
						<mml:mo>)</mml:mo>
					</mml:mrow>
				</mml:math>. For example, if <i><tt>width</tt></i> is 64, <i><tt>height</tt></i> is 16 and
			<i><tt>depth</tt></i> is 32, and the implementation can store a texture of this size, the following mipmap
			levels are built: <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>64</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>16</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>32</mml:mn>
					</mml:mrow>
				</mml:math>, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>32</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>8</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>16</mml:mn>
					</mml:mrow>
				</mml:math>, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>16</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>4</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>8</mml:mn>
					</mml:mrow>
				</mml:math>, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>8</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>2</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>4</mml:mn>
					</mml:mrow>
				</mml:math>, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>4</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>2</mml:mn>
					</mml:mrow>
				</mml:math>, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>2</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
					</mml:mrow>
				</mml:math> and <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
						<mml:mo>×</mml:mo>
						<mml:mn>1</mml:mn>
					</mml:mrow>
				</mml:math>. These correspond to levels 0 through 6, respectively.
		</p><p>
			See the <a href="glTexImage1D.3G.xml"><tt>glTexImage1D</tt></a> reference page for a description of the acceptable values
			for <i><tt>format</tt></i> parameter. See the <a href="glDrawPixels.3G.xml"><tt>glDrawPixels</tt></a> reference
			page for a description of the acceptable values for <i><tt>type</tt></i> parameter.
		</p></div><div class="refsect1" lang="en"><a name="gluBuild3DMipmaps.3G-notes"/><h2>Notes</h2><p>
			Note that there is no direct way of querying the maximum level. This can be derived indirectly via <tt>glGetTexLevelParameter</tt>. First, query for the width, height and depth actually used at
			level 0. (The width, height and depth may not be equal to <i><tt>width</tt></i>, <i><tt>height</tt></i>
			and <i><tt>depth</tt></i> respectively since proxy textures might have scaled them to fit the implementation.)
			Then the maximum level can be derived from the formula <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:msub>
							<mml:mi>log</mml:mi>
							<mml:mn>2</mml:mn>
						</mml:msub>
						<mml:mo>(</mml:mo>
						<mml:mi>max</mml:mi>
						<mml:mo>(</mml:mo>
						<mml:mi>width</mml:mi>
						<mml:mi>height</mml:mi>
						<mml:mi>depth</mml:mi>
						<mml:mo>)</mml:mo>
						<mml:mo>)</mml:mo>
					</mml:mrow>
				</mml:math>.
		</p><p>
			<tt>gluBuild3DMipmaps</tt> is only available if the GLU version is 1.3 or greater.
		</p><p>
			Formats <tt>GL_BGR</tt>, and <tt>GL_BGRA</tt>, and types
			<tt>GL_UNSIGNED_BYTE_3_3_2</tt>, <tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_6_5</tt>, <tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_4_4_4_4</tt>, <tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_5_5_1</tt>, <tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt>,
			<tt>GL_UNSIGNED_INT_8_8_8_8</tt>, <tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt>,
			<tt>GL_UNSIGNED_INT_10_10_10_2</tt>, and <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt> are only
			available if the GL version is 1.2 or greater.
		</p></div><div class="refsect1" lang="en"><a name="gluBuild3DMipmaps.3G-errors"/><h2>Errors</h2><p>
			<tt>GLU_INVALID_VALUE</tt> is returned if <i><tt>width</tt></i>, <i><tt>height</tt></i>, or
			<i><tt>depth</tt></i> is &lt; 1.
		</p><p>
			<tt>GLU_INVALID_ENUM</tt> is returned if <i><tt>internalFormat</tt></i>,
			<i><tt>format</tt></i>, or <i><tt>type</tt></i> is not legal.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_BYTE_3_3_2</tt> or <tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt> and
			<i><tt>format</tt></i> is not <tt>GL_RGB</tt>.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_SHORT_5_6_5</tt> or <tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt> and
			<i><tt>format</tt></i> is not <tt>GL_RGB</tt>.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_SHORT_4_4_4_4</tt> or <tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt> and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> nor <tt>GL_BGRA</tt>.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_SHORT_5_5_5_1</tt> or <tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt> and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> nor <tt>GL_BGRA</tt>.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_INT_8_8_8_8</tt> or <tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt> and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> nor <tt>GL_BGRA</tt>.
		</p><p>
			<tt>GLU_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is
			<tt>GL_UNSIGNED_INT_10_10_10_2</tt> or <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt> and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> nor <tt>GL_BGRA</tt>.
		</p></div><div class="refsect1" lang="en"><a name="gluBuild3DMipmaps.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glDrawPixels.3G.xml">glDrawPixels</a>, <a href="glTexImage1D.3G.xml">glTexImage1D</a>, <a href="glTexImage2D.3G.xml">glTexImage2D</a>, <a href="glTexImage3D.3G.xml">glTexImage3D</a>, <a href="gluBuild1DMipmaps.3G.xml">gluBuild1DMipmaps</a>, <a href="gluBuild3DMipmaps.3G.xml">gluBuild3DMipmaps</a>, <a href="gluErrorString.3G.xml">gluErrorString</a>, <a href="glGetTexImage.3G.xml">glGetTexImage</a>, <a href="glGetTexLevelParameter.3G.xml">glGetTexLevelParameter</a>, <a href="gluBuild1DMipmapLevels.3G.xml">gluBuild1DMipmapLevels</a>, <a href="gluBuild2DMipmapLevels.3G.xml">gluBuild2DMipmapLevels</a>, <a href="gluBuild3DMipmapLevels.3G.xml">gluBuild3DMipmapLevels</a></span>
		</p></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gluBuild3DMipmapLevels.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GLU.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="gluCheckExtension.3G.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gluBuild3DMipmapLevels </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> gluCheckExtension</td></tr></table></div></body></html>