rename upstream-man-pages to upstream-doc
[clinton/guile-figl.git] / upstream-doc / man2 / glGetTexImage.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id="glGetTexImage">
5 <refmeta>
6 <refmetainfo>
7 <copyright>
8 <year>1991-2006</year>
9 <holder>Silicon Graphics, Inc.</holder>
10 </copyright>
11 </refmetainfo>
12 <refentrytitle>glGetTexImage</refentrytitle>
13 <manvolnum>3G</manvolnum>
14 </refmeta>
15 <refnamediv>
16 <refname>glGetTexImage</refname>
17 <refpurpose>return a texture image</refpurpose>
18 </refnamediv>
19 <refsynopsisdiv><title>C Specification</title>
20 <funcsynopsis>
21 <funcprototype>
22 <funcdef>void <function>glGetTexImage</function></funcdef>
23 <paramdef>GLenum <parameter>target</parameter></paramdef>
24 <paramdef>GLint <parameter>level</parameter></paramdef>
25 <paramdef>GLenum <parameter>format</parameter></paramdef>
26 <paramdef>GLenum <parameter>type</parameter></paramdef>
27 <paramdef>GLvoid * <parameter>img</parameter></paramdef>
28 </funcprototype>
29 </funcsynopsis>
30 </refsynopsisdiv>
31 <!-- eqn: ignoring delim $$ -->
32 <refsect1 id="parameters"><title>Parameters</title>
33 <variablelist>
34 <varlistentry>
35 <term><parameter>target</parameter></term>
36 <listitem>
37 <para>
38 Specifies which texture is to be obtained.
39 <constant>GL_TEXTURE_1D</constant>, <constant>GL_TEXTURE_2D</constant>, <constant>GL_TEXTURE_3D</constant>,
40 <constant>GL_TEXTURE_CUBE_MAP_POSITIVE_X</constant>,
41 <constant>GL_TEXTURE_CUBE_MAP_NEGATIVE_X</constant>,
42 <constant>GL_TEXTURE_CUBE_MAP_POSITIVE_Y</constant>,
43 <constant>GL_TEXTURE_CUBE_MAP_NEGATIVE_Y</constant>,
44 <constant>GL_TEXTURE_CUBE_MAP_POSITIVE_Z</constant>, and
45 <constant>GL_TEXTURE_CUBE_MAP_NEGATIVE_Z</constant>
46 are accepted.
47 </para>
48 </listitem>
49 </varlistentry>
50 <varlistentry>
51 <term><parameter>level</parameter></term>
52 <listitem>
53 <para>
54 Specifies the level-of-detail number of the desired image.
55 Level 0 is the base image level.
56 Level
57 <inlineequation><mml:math><mml:mi mathvariant="italic">n</mml:mi></mml:math></inlineequation>
58 is the
59 <inlineequation><mml:math><mml:mi mathvariant="italic">n</mml:mi></mml:math></inlineequation>th
60 mipmap reduction image.
61 </para>
62 </listitem>
63 </varlistentry>
64 <varlistentry>
65 <term><parameter>format</parameter></term>
66 <listitem>
67 <para>
68 Specifies a pixel format for the returned data.
69 The supported formats are
70 <constant>GL_RED</constant>,
71 <constant>GL_GREEN</constant>,
72 <constant>GL_BLUE</constant>,
73 <constant>GL_ALPHA</constant>,
74 <constant>GL_RGB</constant>,
75 <constant>GL_BGR</constant>,
76 <constant>GL_RGBA</constant>,
77 <constant>GL_BGRA</constant>,
78 <constant>GL_LUMINANCE</constant>, and
79 <constant>GL_LUMINANCE_ALPHA</constant>.
80 </para>
81 </listitem>
82 </varlistentry>
83 <varlistentry>
84 <term><parameter>type</parameter></term>
85 <listitem>
86 <para>
87 Specifies a pixel type for the returned data.
88 The supported types are
89 <constant>GL_UNSIGNED_BYTE</constant>,
90 <constant>GL_BYTE</constant>,
91 <constant>GL_UNSIGNED_SHORT</constant>,
92 <constant>GL_SHORT</constant>,
93 <constant>GL_UNSIGNED_INT</constant>,
94 <constant>GL_INT</constant>,
95 <constant>GL_FLOAT</constant>,
96 <constant>GL_UNSIGNED_BYTE_3_3_2</constant>,
97 <constant>GL_UNSIGNED_BYTE_2_3_3_REV</constant>,
98 <constant>GL_UNSIGNED_SHORT_5_6_5</constant>,
99 <constant>GL_UNSIGNED_SHORT_5_6_5_REV</constant>,
100 <constant>GL_UNSIGNED_SHORT_4_4_4_4</constant>,
101 <constant>GL_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
102 <constant>GL_UNSIGNED_SHORT_5_5_5_1</constant>,
103 <constant>GL_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
104 <constant>GL_UNSIGNED_INT_8_8_8_8</constant>,
105 <constant>GL_UNSIGNED_INT_8_8_8_8_REV</constant>,
106 <constant>GL_UNSIGNED_INT_10_10_10_2</constant>, and
107 <constant>GL_UNSIGNED_INT_2_10_10_10_REV</constant>.
108 </para>
109 </listitem>
110 </varlistentry>
111 <varlistentry>
112 <term><parameter>img</parameter></term>
113 <listitem>
114 <para>
115 Returns the texture image.
116 Should be a pointer to an array of the type specified by <parameter>type</parameter>.
117 </para>
118 </listitem>
119 </varlistentry>
120 </variablelist>
121 </refsect1>
122 <refsect1 id="description"><title>Description</title>
123 <para>
124 <function>glGetTexImage</function> returns a texture image into <parameter>img</parameter>.
125 <parameter>target</parameter> specifies whether the desired texture image is one specified by
126 <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry> (<constant>GL_TEXTURE_1D</constant>),
127 <citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry> (<constant>GL_TEXTURE_2D</constant> or any of
128 <constant>GL_TEXTURE_CUBE_MAP_*</constant>),
129 or
130 <citerefentry><refentrytitle>glTexImage3D</refentrytitle></citerefentry> (<constant>GL_TEXTURE_3D</constant>).
131 <parameter>level</parameter> specifies the level-of-detail number of the desired image.
132 <parameter>format</parameter> and <parameter>type</parameter> specify the format and type of the desired image array.
133 See the reference pages <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry>
134 for a description of the acceptable values for the <parameter>format</parameter> and <parameter>type</parameter>
135 parameters, respectively.
136 </para>
137 <para>
138 If a non-zero named buffer object is bound to the <constant>GL_PIXEL_PACK_BUFFER</constant> target
139 (see <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>) while a texture image is
140 requested, <parameter>img</parameter> is treated as a byte offset into the buffer object's data store.
141 </para>
142 <para>
143 To understand the operation of <function>glGetTexImage</function>, consider the selected internal
144 four-component texture image to be an RGBA color buffer the size of the image.
145 The semantics of <function>glGetTexImage</function> are then identical to those of <citerefentry><refentrytitle>glReadPixels</refentrytitle></citerefentry>,
146 with the exception that no pixel transfer operations are performed,
147 when called with the same <parameter>format</parameter> and <parameter>type</parameter>,
148 with <emphasis>x</emphasis> and <emphasis>y</emphasis> set to 0,
149 <emphasis>width</emphasis> set to the width of the texture image
150 (including border if one was specified),
151 and <emphasis>height</emphasis> set to 1 for 1D images,
152 or to the height of the texture image
153 (including border if one was specified)
154 for 2D images.
155 Because the internal texture image is an RGBA image,
156 pixel formats <constant>GL_COLOR_INDEX</constant>,
157 <constant>GL_STENCIL_INDEX</constant>,
158 and <constant>GL_DEPTH_COMPONENT</constant> are not accepted,
159 and pixel type <constant>GL_BITMAP</constant> is not accepted.
160 </para>
161 <para>
162 If the selected texture image does not contain four components,
163 the following mappings are applied.
164 Single-component textures are treated as RGBA buffers with red set
165 to the single-component value,
166 green set to 0, blue set to 0, and alpha set to 1.
167 Two-component textures are treated as RGBA buffers with red set to
168 the value of component zero,
169 alpha set to the value of component one,
170 and green and blue set to 0.
171 Finally,
172 three-component textures are treated as RGBA buffers with red set to
173 component zero,
174 green set to component one,
175 blue set to component two,
176 and alpha set to 1.
177 </para>
178 <para>
179 To determine the required size of <parameter>img</parameter>,
180 use <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry> to determine the dimensions of the
181 internal texture image,
182 then scale the required number of pixels by the storage required for
183 each pixel,
184 based on <parameter>format</parameter> and <parameter>type</parameter>.
185 Be sure to take the pixel storage parameters into account,
186 especially <constant>GL_PACK_ALIGNMENT</constant>.
187 </para>
188 </refsect1>
189 <refsect1 id="notes"><title>Notes</title>
190 <para>
191 If an error is generated,
192 no change is made to the contents of <parameter>img</parameter>.
193 </para>
194 <para>
195 The types <constant>GL_UNSIGNED_BYTE_3_3_2</constant>,
196 <constant>GL_UNSIGNED_BYTE_2_3_3_REV</constant>,
197 <constant>GL_UNSIGNED_SHORT_5_6_5</constant>,
198 <constant>GL_UNSIGNED_SHORT_5_6_5_REV</constant>,
199 <constant>GL_UNSIGNED_SHORT_4_4_4_4</constant>,
200 <constant>GL_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
201 <constant>GL_UNSIGNED_SHORT_5_5_5_1</constant>,
202 <constant>GL_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
203 <constant>GL_UNSIGNED_INT_8_8_8_8</constant>,
204 <constant>GL_UNSIGNED_INT_8_8_8_8_REV</constant>,
205 <constant>GL_UNSIGNED_INT_10_10_10_2</constant>,
206 <constant>GL_UNSIGNED_INT_2_10_10_10_REV</constant>,
207 and the formats
208 <constant>GL_BGR</constant>, and <constant>GL_BGRA</constant> are available only if the GL version is
209 1.2 or greater.
210 </para>
211 <para>
212 For OpenGL versions 1.3 and greater, or when the <code>ARB_multitexture</code> extension is supported, <function>glGetTexImage</function> returns
213 the texture image for the active texture unit.
214 </para>
215 </refsect1>
216 <refsect1 id="errors"><title>Errors</title>
217 <para>
218 <constant>GL_INVALID_ENUM</constant> is generated if <parameter>target</parameter>, <parameter>format</parameter>, or <parameter>type</parameter> is not
219 an accepted value.
220 </para>
221 <para>
222 <constant>GL_INVALID_VALUE</constant> is generated if <parameter>level</parameter> is less than 0.
223 </para>
224 <para>
225 <constant>GL_INVALID_VALUE</constant> may be generated if <parameter>level</parameter> is greater
226 than
227 <inlineequation><mml:math>
228 <!-- eqn: log sub 2 (max):-->
229 <mml:mrow>
230 <mml:msub><mml:mi mathvariant="italic">log</mml:mi>
231 <mml:mn>2</mml:mn>
232 </mml:msub>
233 <mml:mo>&af;</mml:mo>
234 <mml:mfenced open="(" close=")">
235 <mml:mi mathvariant="italic">max</mml:mi>
236 </mml:mfenced>
237 </mml:mrow>
238 </mml:math></inlineequation>,
239 where
240 <inlineequation><mml:math><mml:mi mathvariant="italic">max</mml:mi></mml:math></inlineequation>
241 is the returned value of <constant>GL_MAX_TEXTURE_SIZE</constant>.
242 </para>
243 <para>
244 <constant>GL_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is one of
245 <constant>GL_UNSIGNED_BYTE_3_3_2</constant>,
246 <constant>GL_UNSIGNED_BYTE_2_3_3_REV</constant>,
247 <constant>GL_UNSIGNED_SHORT_5_6_5</constant>, or
248 <constant>GL_UNSIGNED_SHORT_5_6_5_REV</constant> and <parameter>format</parameter> is not <constant>GL_RGB</constant>.
249 </para>
250 <para>
251 <constant>GL_INVALID_OPERATION</constant> is returned if <parameter>type</parameter> is one of
252 <constant>GL_UNSIGNED_SHORT_4_4_4_4</constant>,
253 <constant>GL_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
254 <constant>GL_UNSIGNED_SHORT_5_5_5_1</constant>,
255 <constant>GL_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
256 <constant>GL_UNSIGNED_INT_8_8_8_8</constant>,
257 <constant>GL_UNSIGNED_INT_8_8_8_8_REV</constant>,
258 <constant>GL_UNSIGNED_INT_10_10_10_2</constant>, or
259 <constant>GL_UNSIGNED_INT_2_10_10_10_REV</constant>, and <parameter>format</parameter> is neither <constant>GL_RGBA</constant>
260 or <constant>GL_BGRA</constant>.
261 </para>
262 <para>
263 <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
264 <constant>GL_PIXEL_PACK_BUFFER</constant> target and the buffer object's data store is currently mapped.
265 </para>
266 <para>
267 <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
268 <constant>GL_PIXEL_PACK_BUFFER</constant> target and the data would be packed to the buffer
269 object such that the memory writes required would exceed the data store size.
270 </para>
271 <para>
272 <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
273 <constant>GL_PIXEL_PACK_BUFFER</constant> target and <parameter>img</parameter> is not evenly divisible
274 into the number of bytes needed to store in memory a datum indicated by <parameter>type</parameter>.
275 </para>
276 <para>
277 <constant>GL_INVALID_OPERATION</constant> is generated if <function>glGetTexImage</function>
278 is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
279 and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
280 </para>
281 </refsect1>
282 <refsect1 id="associatedgets"><title>Associated Gets</title>
283 <para>
284 <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_WIDTH</constant>
285 </para>
286 <para>
287 <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_HEIGHT</constant>
288 </para>
289 <para>
290 <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_BORDER</constant>
291 </para>
292 <para>
293 <citerefentry><refentrytitle>glGetTexLevelParameter</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_INTERNAL_FORMAT</constant>
294 </para>
295 <para>
296 <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with arguments <constant>GL_PACK_ALIGNMENT</constant> and others
297 </para>
298 <para>
299 <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_PIXEL_PACK_BUFFER_BINDING</constant>
300 </para>
301 </refsect1>
302 <refsect1 id="seealso"><title>See Also</title>
303 <para>
304 <citerefentry><refentrytitle>glActiveTexture</refentrytitle></citerefentry>,
305 <citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry>,
306 <citerefentry><refentrytitle>glReadPixels</refentrytitle></citerefentry>,
307 <citerefentry><refentrytitle>glTexEnv</refentrytitle></citerefentry>,
308 <citerefentry><refentrytitle>glTexGen</refentrytitle></citerefentry>,
309 <citerefentry><refentrytitle>glTexImage1D</refentrytitle></citerefentry>,
310 <citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry>,
311 <citerefentry><refentrytitle>glTexImage3D</refentrytitle></citerefentry>,
312 <citerefentry><refentrytitle>glTexSubImage1D</refentrytitle></citerefentry>,
313 <citerefentry><refentrytitle>glTexSubImage2D</refentrytitle></citerefentry>,
314 <citerefentry><refentrytitle>glTexSubImage3D</refentrytitle></citerefentry>,
315 <citerefentry><refentrytitle>glTexParameter</refentrytitle></citerefentry>
316 </para>
317 </refsect1>
318 <refsect1 id="Copyright"><title>Copyright</title>
319 <para>
320 Copyright <trademark class="copyright"></trademark> 1991-2006
321 Silicon Graphics, Inc. This document is licensed under the SGI
322 Free Software B License. For details, see
323 <ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
324 </para>
325 </refsect1>
326 </refentry>