<?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>glGetTexImage</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-GL.xml" title="GL"/><link rel="previous" href="glGetTexGen.3G.xml" title="glGetTexGen"/><link rel="next" href="glGetTexLevelParameter.3G.xml" title="glGetTexLevelParameter"/></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">glGetTexImage</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="glGetTexGen.3G.xml">Prev</a> </td><th width="60%" align="center">GL</th><td width="20%" align="right"> <a accesskey="n" href="glGetTexLevelParameter.3G.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="glGetTexImage.3G"/><div class="titlepage"/><div class="refnamediv"><a name="glGetTexImage.3G-name"/><h2>Name</h2><p>glGetTexImage, glGetTexImageb, glGetTexImaged, glGetTexImagef, glGetTexImagei, glGetTexImages, glGetTexImageub, glGetTexImageui, glGetTexImageus &#8212; return a texture image</p></div><div class="refsynopsisdiv"><a name="glGetTexImage.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>glGetTexImage</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>target</tt></i>, GLint <i><tt>level</tt></i>, GLenum <i><tt>format</tt></i>, GLenum <i><tt>type</tt></i>, GLvoid *<i><tt>pixels</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="glGetTexImage.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>glGetTexImage</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>, <i><tt>type</tt></i>) &#8594; <i><tt>pixels</tt></i></code></td></tr><tr><td valign="top"><code><tt>glGetTexImageb</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImaged</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImagef</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImagei</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImages</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImageub</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImageui</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glGetTexImageus</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>target</tt></i>, <i><tt>level</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr></table></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>target</tt></i></span></dt><dd>
						Specifies which texture is to be obtained. <tt>GL_TEXTURE_1D</tt>,
						<tt>GL_TEXTURE_2D</tt>, and <tt>GL_TEXTURE_3D</tt> are accepted.
					</dd><dt><span class="term"><i><tt>level</tt></i></span></dt><dd>
						Specifies the level-of-detail number of the desired image. Level 0 is the base image level. Level
						<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>n</mml:mi>
							</mml:math> is the <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>n</mml:mi>
							</mml:math>th mipmap reduction image.
					</dd><dt><span class="term"><i><tt>format</tt></i></span></dt><dd>
						Specifies a pixel for the returned data. The supported formats are <tt>GL_RED</tt>,
						<tt>GL_GREEN</tt>, <tt>GL_BLUE</tt>, <tt>GL_ALPHA</tt>,
						<tt>GL_RGB</tt>, <tt>GL_BGR</tt>, <tt>GL_RGBA</tt>,
						<tt>GL_BGRA</tt>, <tt>GL_LUMINANCE</tt>, and
						<tt>GL_LUMINANCE_ALPHA</tt>.
					</dd><dt><span class="term"><i><tt>type</tt></i></span></dt><dd>
						Specifies a pixel type for the returned data. The supported types are
						<tt>GL_UNSIGNED_BYTE</tt>, <tt>GL_BYTE</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>, and <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt>.
					</dd><dt><span class="term"><i><tt>pixels</tt></i></span></dt><dd>
						Returns the texture image. Should be a pointer to an array of the type specified by
						<i><tt>type</tt></i>.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-description"/><h2>Description</h2><p>
			<tt>glGetTexImage</tt> returns a texture image into <i><tt>pixels</tt></i>.
			<i><tt>target</tt></i> specifies whether the desired texture image is one specified by <a href="glTexImage1D.3G.xml"><tt>glTexImage1D</tt></a> (<tt>GL_TEXTURE_1D</tt>), <a href="glTexImage2D.3G.xml"><tt>glTexImage2D</tt></a> (<tt>GL_TEXTURE_2D</tt>), or <a href="glTexImage3D.3G.xml"><tt>glTexImage3D</tt></a> (<tt>GL_TEXTURE_3D</tt>). <i><tt>level</tt></i>
			specifies the level-of-detail number of the desired image. <i><tt>format</tt></i> and
			<i><tt>type</tt></i> specify the and type of the desired image array. See the reference pages <a href="glTexImage1D.3G.xml"><tt>glTexImage1D</tt></a> and <a href="glDrawPixels.3G.xml"><tt>glDrawPixels</tt></a> for a description
			of the acceptable values for the <i><tt>format</tt></i> and <i><tt>type</tt></i> parameters,
			respectively.
		</p><p>
			To understand the operation of <tt>glGetTexImage</tt>, consider the selected internal four-component
			texture image to be an RGBA color buffer the size of the image. The semantics of <tt>glGetTexImage</tt> are
			then identical to those of <a href="glReadPixels.3G.xml"><tt>glReadPixels</tt></a>, with the exception that no pixel
			transfer operations are performed, when called with the same <i><tt>format</tt></i> and
			<i><tt>type</tt></i>, with <i><tt>x</tt></i> and <i><tt>y</tt></i> set to 0,
			<i><tt>width</tt></i> set to the width of the texture image (including border if one was specified), and
			<i><tt>height</tt></i> set to 1 for 1D images, or to the height of the texture image (including border if one
			was specified) for 2D images. Because the internal texture image is an RGBA image, pixel formats
			<tt>GL_COLOR_INDEX</tt>, <tt>GL_STENCIL_INDEX</tt>, and <tt>GL_DEPTH_COMPONENT</tt>
			are not accepted, and pixel type <tt>GL_BITMAP</tt> is not accepted.
		</p><p>
			If the selected texture image does not contain four components, the following mappings are applied. Single-component
			textures are treated as RGBA buffers with red set to the single-component value, green set to 0, blue set to 0, and
			alpha set to 1. Two-component textures are treated as RGBA buffers with red set to the value of component zero, alpha
			set to the value of component one, and green and blue set to 0. Finally, three-component textures are treated as RGBA
			buffers with red set to component zero, green set to component one, blue set to component two, and alpha set to 1.
		</p><p>
			To determine the required size of <i><tt>pixels</tt></i>, use <tt>glGetTexLevelParameter</tt> to determine the dimensions of the internal texture image, then
			scale the required number of pixels by the storage required for each pixel, based on <i><tt>format</tt></i> and
			<i><tt>type</tt></i>. Be sure to take the pixel storage parameters into account, especially
			<tt>GL_PACK_ALIGNMENT</tt>.
		</p></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-notes"/><h2>Notes</h2><p>
			If an error is generated, no change is made to the contents of <i><tt>pixels</tt></i>.
		</p><p>
			When the <tt>GL_ARB_multitexture</tt> extension is supported, <tt>glGetTexImage</tt> returns
			the texture image for the active texture unit.
		</p><p>
			The 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>, <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt>, and the formats
			<tt>GL_BGR</tt>, and <tt>GL_BGRA</tt> are available only if the GL version is 1.2 or greater.
		</p></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-errors"/><h2>Errors</h2><p>
			<tt>GL_INVALID_ENUM</tt> is generated if <i><tt>target</tt></i>, <i><tt>format</tt></i>, or
			<i><tt>type</tt></i> is not an accepted value.
		</p><p>
			<tt>GL_INVALID_VALUE</tt> is generated if <i><tt>level</tt></i> is less than 0.
		</p><p>
			<tt>GL_INVALID_VALUE</tt> may be generated if <i><tt>level</tt></i> is greater than <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:mi>max</mml:mi>
					</mml:mrow>
				</mml:math>, where <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>max</mml:mi>
				</mml:math> is the returned value of <tt>GL_MAX_TEXTURE_SIZE</tt>.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <tt>glGetTexImage</tt> is executed between the
			execution of <a href="glBegin.3G.xml"><tt>glBegin</tt></a> and the corresponding execution of <a href="glBegin.3G.xml"><tt>glEnd</tt></a>.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is one of
			<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>, 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>GL_INVALID_OPERATION</tt> is returned if <i><tt>type</tt></i> is one of
			<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>, and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> or <tt>GL_BGRA</tt>.
		</p></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-associated_gets"/><h2>Associated Gets</h2><p>
			<tt>glGetTexLevelParameter</tt> with argument <tt>GL_TEXTURE_WIDTH</tt>
		</p><p>
			<tt>glGetTexLevelParameter</tt> with argument <tt>GL_TEXTURE_HEIGHT</tt>
		</p><p>
			<tt>glGetTexLevelParameter</tt> with argument <tt>GL_TEXTURE_BORDER</tt>
		</p><p>
			<tt>glGetTexLevelParameter</tt> with argument
			<tt>GL_TEXTURE_INTERNALFORMAT</tt>
		</p><p>
			<tt>glGet</tt> with arguments <tt>GL_PACK_ALIGNMENT</tt> and others
		</p></div><div class="refsect1" lang="en"><a name="glGetTexImage.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glActiveTextureARB.3G.xml">glActiveTextureARB</a>, <a href="glDrawPixels.3G.xml">glDrawPixels</a>, <a href="glReadPixels.3G.xml">glReadPixels</a>, <a href="glTexEnv.3G.xml">glTexEnv</a>, <a href="glTexGen.3G.xml">glTexGen</a>, <a href="glTexImage1D.3G.xml">glTexImage1D</a>, <a href="glTexImage2D.3G.xml">glTexImage2D</a>, <a href="glTexImage3D.3G.xml">glTexImage3D</a>, <a href="glTexSubImage1D.3G.xml">glTexSubImage1D</a>, <a href="glTexSubImage2D.3G.xml">glTexSubImage2D</a>, <a href="glTexSubImage3D.3G.xml">glTexSubImage3D</a>, <a href="glTexParameter.3G.xml">glTexParameter</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="glGetTexGen.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GL.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="glGetTexLevelParameter.3G.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">glGetTexGen </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> glGetTexLevelParameter</td></tr></table></div></body></html>
