1GLTEXIMAGE2D(3G)                 OpenGL Manual                GLTEXIMAGE2D(3G)
2
3
4

NAME

6       glTexImage2D - specify a two-dimensional texture image
7

C SPECIFICATION

9       void glTexImage2D(GLenum target, GLint level, GLint internalFormat,
10                         GLsizei width, GLsizei height, GLint border,
11                         GLenum format, GLenum type, const GLvoid * data);
12

PARAMETERS

14       target
15           Specifies the target texture. Must be GL_TEXTURE_2D,
16           GL_PROXY_TEXTURE_2D, GL_TEXTURE_1D_ARRAY,
17           GL_PROXY_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE,
18           GL_PROXY_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
19           GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
20           GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
21           GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, or GL_PROXY_TEXTURE_CUBE_MAP.
22
23       level
24           Specifies the level-of-detail number. Level 0 is the base image
25           level. Level n is the nth mipmap reduction image. If target is
26           GL_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_RECTANGLE, level must be
27           0.
28
29       internalFormat
30           Specifies the number of color components in the texture. Must be
31           one of base internal formats given in Table 1, one of the sized
32           internal formats given in Table 2, or one of the compressed
33           internal formats given in Table 3, below.
34
35       width
36           Specifies the width of the texture image. All implementations
37           support texture images that are at least 1024 texels wide.
38
39       height
40           Specifies the height of the texture image, or the number of layers
41           in a texture array, in the case of the GL_TEXTURE_1D_ARRAY and
42           GL_PROXY_TEXTURE_1D_ARRAY targets. All implementations support 2D
43           texture images that are at least 1024 texels high, and texture
44           arrays that are at least 256 layers deep.
45
46       border
47           This value must be 0.
48
49       format
50           Specifies the format of the pixel data. The following symbolic
51           values are accepted: GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and
52           GL_BGRA.
53
54       type
55           Specifies the data type of the pixel data. The following symbolic
56           values are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT,
57           GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_FLOAT,
58           GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
59           GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
60           GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
61           GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
62           GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
63           GL_UNSIGNED_INT_10_10_10_2, and GL_UNSIGNED_INT_2_10_10_10_REV.
64
65       data
66           Specifies a pointer to the image data in memory.
67

DESCRIPTION

69       Texturing allows elements of an image array to be read by shaders.
70
71       To define texture images, call glTexImage2D. The arguments describe the
72       parameters of the texture image, such as height, width, width of the
73       border, level-of-detail number (see glTexParameter()), and number of
74       color components provided. The last three arguments describe how the
75       image is represented in memory.
76
77       If target is GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_1D_ARRAY,
78       GL_PROXY_TEXTURE_CUBE_MAP, or GL_PROXY_TEXTURE_RECTANGLE, no data is
79       read from data, but all of the texture image state is recalculated,
80       checked for consistency, and checked against the implementation's
81       capabilities. If the implementation cannot handle a texture of the
82       requested texture size, it sets all of the image state to 0, but does
83       not generate an error (see glGetError()). To query for an entire mipmap
84       array, use an image array level greater than or equal to 1.
85
86       If target is GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE or one of the
87       GL_TEXTURE_CUBE_MAP targets, data is read from data as a sequence of
88       signed or unsigned bytes, shorts, or longs, or single-precision
89       floating-point values, depending on type. These values are grouped into
90       sets of one, two, three, or four values, depending on format, to form
91       elements. Each data byte is treated as eight 1-bit elements, with bit
92       ordering determined by GL_UNPACK_LSB_FIRST (see glPixelStore()).
93
94       If target is GL_TEXTURE_1D_ARRAY, data is interpreted as an array of
95       one-dimensional images.
96
97       If a non-zero named buffer object is bound to the
98       GL_PIXEL_UNPACK_BUFFER target (see glBindBuffer()) while a texture
99       image is specified, data is treated as a byte offset into the buffer
100       object's data store.
101
102       The first element corresponds to the lower left corner of the texture
103       image. Subsequent elements progress left-to-right through the remaining
104       texels in the lowest row of the texture image, and then in successively
105       higher rows of the texture image. The final element corresponds to the
106       upper right corner of the texture image.
107
108       format determines the composition of each element in data. It can
109       assume one of these symbolic values:
110
111       GL_RED
112           Each element is a single red component. The GL converts it to
113           floating point and assembles it into an RGBA element by attaching 0
114           for green and blue, and 1 for alpha. Each component is then
115           multiplied by the signed scale factor GL_c_SCALE, added to the
116           signed bias GL_c_BIAS, and clamped to the range [0,1].
117
118       GL_RG
119           Each element is a red/green double. The GL converts it to floating
120           point and assembles it into an RGBA element by attaching 0 for
121           blue, and 1 for alpha. Each component is then multiplied by the
122           signed scale factor GL_c_SCALE, added to the signed bias GL_c_BIAS,
123           and clamped to the range [0,1].
124
125       GL_RGB
126
127       GL_BGR
128           Each element is an RGB triple. The GL converts it to floating point
129           and assembles it into an RGBA element by attaching 1 for alpha.
130           Each component is then multiplied by the signed scale factor
131           GL_c_SCALE, added to the signed bias GL_c_BIAS, and clamped to the
132           range [0,1].
133
134       GL_RGBA
135
136       GL_BGRA
137           Each element contains all four components. Each component is
138           multiplied by the signed scale factor GL_c_SCALE, added to the
139           signed bias GL_c_BIAS, and clamped to the range [0,1].
140
141       GL_DEPTH_COMPONENT
142           Each element is a single depth value. The GL converts it to
143           floating point, multiplies by the signed scale factor
144           GL_DEPTH_SCALE, adds the signed bias GL_DEPTH_BIAS, and clamps to
145           the range [0,1].
146
147       GL_DEPTH_STENCIL
148           Each element is a pair of depth and stencil values. The depth
149           component of the pair is interpreted as in GL_DEPTH_COMPONENT. The
150           stencil component is interpreted based on specified the depth +
151           stencil internal format.
152
153       If an application wants to store the texture at a certain resolution or
154       in a certain format, it can request the resolution and format with
155       internalFormat. The GL will choose an internal representation that
156       closely approximates that requested by internalFormat, but it may not
157       match exactly. (The representations specified by GL_RED, GL_RG, GL_RGB,
158       and GL_RGBA must match exactly.)
159
160       internalFormat may be one of the base internal formats shown in Table
161       1, below
162
163       <xi:include></xi:include>
164
165       internalFormat may also be one of the sized internal formats shown in
166       Table 2, below
167
168       <xi:include></xi:include>
169
170       Finally, internalFormat may also be one of the generic or compressed
171       compressed texture formats shown in Table 3 below
172
173       <xi:include></xi:include>
174
175       If the internalFormat parameter is one of the generic compressed
176       formats, GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, or
177       GL_COMPRESSED_RGBA, the GL will replace the internal format with the
178       symbolic constant for a specific internal format and compress the
179       texture before storage. If no corresponding internal format is
180       available, or the GL can not compress that image for any reason, the
181       internal format is instead replaced with a corresponding base internal
182       format.
183
184       If the internalFormat parameter is GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or
185       GL_SRGB8_ALPHA8, the texture is treated as if the red, green, or blue
186       components are encoded in the sRGB color space. Any alpha component is
187       left unchanged. The conversion from the sRGB encoded component c s to a
188       linear component c l is:
189
190       c l = { c s 12.92 if c s ≤ 0.04045 ( c s + 0.055 1.055 ) 2.4 if c s >
191       0.04045
192
193       Assume c s is the sRGB component in the range [0,1].
194
195       Use the GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_1D_ARRAY,
196       GL_PROXY_TEXTURE_RECTANGLE, or GL_PROXY_TEXTURE_CUBE_MAP target to try
197       out a resolution and format. The implementation will update and
198       recompute its best match for the requested storage resolution and
199       format. To then query this state, call glGetTexLevelParameter(). If the
200       texture cannot be accommodated, texture state is set to 0.
201
202       A one-component texture image uses only the red component of the RGBA
203       color extracted from data. A two-component image uses the R and G
204       values. A three-component image uses the R, G, and B values. A
205       four-component image uses all of the RGBA components.
206
207       Image-based shadowing can be enabled by comparing texture r coordinates
208       to depth texture values to generate a boolean result. See
209       glTexParameter() for details on texture comparison.
210

NOTES

212       The glPixelStore() mode affects texture images.
213
214       data may be a null pointer. In this case, texture memory is allocated
215       to accommodate a texture of width width and height height. You can then
216       download subtextures to initialize this texture memory. The image is
217       undefined if the user tries to apply an uninitialized portion of the
218       texture image to a primitive.
219
220       glTexImage2D specifies the two-dimensional texture for the current
221       texture unit, specified with glActiveTexture().
222

ERRORS

224       GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D,
225       GL_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_2D,
226       GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_RECTANGLE,
227       GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
228       GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
229       GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, or
230       GL_TEXTURE_CUBE_MAP_NEGATIVE_Z.
231
232       GL_INVALID_ENUM is generated if target is one of the six cube map 2D
233       image targets and the width and height parameters are not equal.
234
235       GL_INVALID_ENUM is generated if type is not a type constant.
236
237       GL_INVALID_VALUE is generated if width is less than 0 or greater than
238       GL_MAX_TEXTURE_SIZE.
239
240       GL_INVALID_VALUE is generated if target is not GL_TEXTURE_1D_ARRAY or
241       GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than
242       GL_MAX_TEXTURE_SIZE.
243
244       GL_INVALID_VALUE is generated if target is GL_TEXTURE_1D_ARRAY or
245       GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than
246       GL_MAX_ARRAY_TEXTURE_LAYERS.
247
248       GL_INVALID_VALUE is generated if level is less than 0.
249
250       GL_INVALID_VALUE may be generated if level is greater than log 2 ⁡ max,
251       where max is the returned value of GL_MAX_TEXTURE_SIZE.
252
253       GL_INVALID_VALUE is generated if internalFormat is not one of the
254       accepted resolution and format symbolic constants.
255
256       GL_INVALID_VALUE is generated if width or height is less than 0 or
257       greater than GL_MAX_TEXTURE_SIZE.
258
259       GL_INVALID_VALUE is generated if non-power-of-two textures are not
260       supported and the width or height cannot be represented as 2 k + 2 ⁡
261       border for some integer value of k.
262
263       GL_INVALID_VALUE is generated if border is not 0.
264
265       GL_INVALID_OPERATION is generated if type is one of
266       GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
267       GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, or
268       GL_UNSIGNED_INT_10F_11F_11F_REV, and format is not GL_RGB.
269
270       GL_INVALID_OPERATION is generated if type is one of
271       GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
272       GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
273       GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
274       GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV, or
275       GL_UNSIGNED_INT_5_9_9_9_REV, and format is neither GL_RGBA nor GL_BGRA.
276
277       GL_INVALID_OPERATION is generated if target is not GL_TEXTURE_2D,
278       GL_PROXY_TEXTURE_2D, GL_TEXTURE_RECTANGLE, or
279       GL_PROXY_TEXTURE_RECTANGLE, and internalFormat is GL_DEPTH_COMPONENT,
280       GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F.
281
282       GL_INVALID_OPERATION is generated if format is GL_DEPTH_COMPONENT and
283       internalFormat is not GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16,
284       GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F.
285
286       GL_INVALID_OPERATION is generated if internalFormat is
287       GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or
288       GL_DEPTH_COMPONENT32F, and format is not GL_DEPTH_COMPONENT.
289
290       GL_INVALID_OPERATION is generated if a non-zero buffer object name is
291       bound to the GL_PIXEL_UNPACK_BUFFER target and the buffer object's data
292       store is currently mapped.
293
294       GL_INVALID_OPERATION is generated if a non-zero buffer object name is
295       bound to the GL_PIXEL_UNPACK_BUFFER target and the data would be
296       unpacked from the buffer object such that the memory reads required
297       would exceed the data store size.
298
299       GL_INVALID_OPERATION is generated if a non-zero buffer object name is
300       bound to the GL_PIXEL_UNPACK_BUFFER target and data is not evenly
301       divisible into the number of bytes needed to store in memory a datum
302       indicated by type.
303
304       GL_INVALID_VALUE is generated if target is GL_TEXTURE_RECTANGLE or
305       GL_PROXY_TEXTURE_RECTANGLE and level is not 0.
306

ASSOCIATED GETS

308       glGetTexImage()
309
310       glGet() with argument GL_PIXEL_UNPACK_BUFFER_BINDING
311

SEE ALSO

313       glActiveTexture(), glCopyTexImage1D(), glCopyTexImage2D(),
314       glCopyTexSubImage1D(), glCopyTexSubImage2D(), glCopyTexSubImage3D(),
315       glPixelStore(), glTexImage1D(), glTexImage3D(), glTexSubImage1D(),
316       glTexSubImage2D(), glTexSubImage3D(), glTexParameter()
317
319       Copyright © 1991-2006 Silicon Graphics, Inc. Copyright © 2011 Khronos
320       Group. This document is licensed under the SGI Free Software B License.
321       For details, see http://oss.sgi.com/projects/FreeB/.
322

AUTHORS

324       opengl.org
325
326
327
328opengl.org                        06/10/2014                  GLTEXIMAGE2D(3G)
Impressum