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

NAME

6       glTexImage2D - specify a two-dimensional texture image
7
8

C SPECIFICATION

10       void glTexImage2D( GLenum target,
11                          GLint level,
12                          GLint internalFormat,
13                          GLsizei width,
14                          GLsizei height,
15                          GLint border,
16                          GLenum format,
17                          GLenum type,
18                          const GLvoid *pixels )
19
20

PARAMETERS

22       target          Specifies the target texture.  Must be GL_TEXTURE_2D or
23                       GL_PROXY_TEXTURE_2D.
24
25       level           Specifies the level-of-detail number.  Level 0  is  the
26                       base  image level.  Level n is the nth mipmap reduction
27                       image.
28
29       internalFormat  Specifies the number of color components  in  the  tex‐
30                       ture.   Must  be 1, 2, 3, or 4, or one of the following
31                       symbolic  constants:  GL_ALPHA,  GL_ALPHA4,  GL_ALPHA8,
32                       GL_ALPHA12,  GL_ALPHA16,  GL_LUMINANCE,  GL_LUMINANCE4,
33                       GL_LUMINANCE8,     GL_LUMINANCE12,      GL_LUMINANCE16,
34                       GL_LUMINANCE_ALPHA,               GL_LUMINANCE4_ALPHA4,
35                       GL_LUMINANCE6_ALPHA2,             GL_LUMINANCE8_ALPHA8,
36                       GL_LUMINANCE12_ALPHA4,          GL_LUMINANCE12_ALPHA12,
37                       GL_LUMINANCE16_ALPHA16,  GL_INTENSITY,   GL_INTENSITY4,
38                       GL_INTENSITY8,      GL_INTENSITY12,     GL_INTENSITY16,
39                       GL_R3_G3_B2,   GL_RGB,   GL_RGB4,   GL_RGB5,   GL_RGB8,
40                       GL_RGB10,   GL_RGB12,   GL_RGB16,   GL_RGBA,  GL_RGBA2,
41                       GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGBA12,
42                       or GL_RGBA16.
43
44       width           Specifies  the  width  of  the  texture image.  Must be
45                       2n+2(border) for some integer  n.  All  implementations
46                       support  texture  images  that  are  at least 64 texels
47                       wide.
48
49       height          Specifies the height of the  texture  image.   Must  be
50                       2m+2(border)  for  some  integer m. All implementations
51                       support texture images that  are  at  least  64  texels
52                       high.
53
54       border          Specifies the width of the border.  Must be either 0 or
55                       1.
56
57       format          Specifies the  of the pixel data.  The  following  sym‐
58                       bolic  values  are  accepted:  GL_COLOR_INDEX,  GL_RED,
59                       GL_GREEN, GL_BLUE, GL_ALPHA,  GL_RGB,  GL_BGR  GL_RGBA,
60                       GL_BGRA, GL_LUMINANCE, and GL_LUMINANCE_ALPHA.
61
62       type            Specifies the data type of the pixel data.  The follow‐
63                       ing symbolic  values  are  accepted:  GL_UNSIGNED_BYTE,
64                       GL_BYTE,    GL_BITMAP,   GL_UNSIGNED_SHORT,   GL_SHORT,
65                       GL_UNSIGNED_INT,           GL_INT,            GL_FLOAT,
66                       GL_UNSIGNED_BYTE_3_3_2,     GL_UNSIGNED_BYTE_2_3_3_REV,
67                       GL_UNSIGNED_SHORT_5_6_5,   GL_UNSIGNED_SHORT_5_6_5_REV,
68                       GL_UNSIGNED_SHORT_4_4_4_4,
69                       GL_UNSIGNED_SHORT_4_4_4_4_REV,
70                       GL_UNSIGNED_SHORT_5_5_5_1,
71                       GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8,
72                       GL_UNSIGNED_INT_8_8_8_8_REV,
73                       GL_UNSIGNED_INT_10_10_10_2,                         and
74                       GL_UNSIGNED_INT_2_10_10_10_REV.
75
76       pixels          Specifies a pointer to the image data in memory.
77

DESCRIPTION

79       Texturing maps a portion of a specified texture image onto each graphi‐
80       cal primitive for which texturing is enabled.  To  enable  and  disable
81       two-dimensional  texturing,  call  glEnable and glDisable with argument
82       GL_TEXTURE_2D.
83
84       To define texture images, call glTexImage2D.   The  arguments  describe
85       the  parameters  of  the texture image, such as height, width, width of
86       the border, level-of-detail number (see glTexParameter), and number  of
87       color  components  provided.  The last three arguments describe how the
88       image is represented in memory; they are identical to the pixel formats
89       used for glDrawPixels.
90
91       If  target is GL_PROXY_TEXTURE_2D, no data is read from pixels, but all
92       of the texture image state is recalculated,  checked  for  consistency,
93       and checked against the implementation's capabilities. If the implemen‐
94       tation cannot handle a texture of the requested texture size,  it  sets
95       all  of  the  image  state  to  0,  but does not generate an error (see
96       glGetError). To query for an entire mipmap array, use  an  image  array
97       level greater than or equal to 1.
98
99       If  target  is GL_TEXTURE_2D, data is read from pixels as a sequence of
100       signed or unsigned bytes, shorts, or longs, or single-precision  float‐
101       ing-point  values,  depending  on  type.  These values are grouped into
102       sets of one, two, three, or four values, depending on format,  to  form
103       elements.   If type is GL_BITMAP, the data is considered as a string of
104       unsigned bytes (and format must be GL_COLOR_INDEX).
105       Each data byte is treated as eight 1-bit elements,  with  bit  ordering
106       determined by GL_UNPACK_LSB_FIRST (see glPixelStore).
107
108       The  first  element corresponds to the lower left corner of the texture
109       image.  Subsequent elements progress left-to-right through the  remain‐
110       ing  texels in the lowest row of the texture image, and then in succes‐
111       sively higher rows of the texture image.  The final element corresponds
112       to the upper right corner of the texture image.
113
114       format  determines  the  composition of each element in pixels.  It can
115       assume one of eleven symbolic values:
116
117       GL_COLOR_INDEX
118                 Each element is a single value, a color index.  The  GL  con‐
119                 verts  it  to fixed point (with an unspecified number of zero
120                 bits to the right of the binary point), shifted left or right
121                 depending  on the value and sign of GL_INDEX_SHIFT, and added
122                 to GL_INDEX_OFFSET (see
123                 glPixelTransfer).  The resulting index is converted to a  set
124                 of    color   components   using   the   GL_PIXEL_MAP_I_TO_R,
125                 GL_PIXEL_MAP_I_TO_G,         GL_PIXEL_MAP_I_TO_B,         and
126                 GL_PIXEL_MAP_I_TO_A tables, and clamped to the range [0,1].
127
128       GL_RED    Each  element  is a single red component.  The GL converts it
129                 to floating point and assembles it into an  RGBA  element  by
130                 attaching 0 for green and blue, and 1 for alpha.  Each compo‐
131                 nent  is  then  multiplied  by  the   signed   scale   factor
132                 GL_c_SCALE,  added  to the signed bias GL_c_BIAS, and clamped
133                 to the range [0,1] (see glPixelTransfer).
134
135       GL_GREEN  Each element is a single green component.  The GL converts it
136                 to  floating  point  and assembles it into an RGBA element by
137                 attaching 0 for red and blue, and 1 for alpha.   Each  compo‐
138                 nent   is   then   multiplied  by  the  signed  scale  factor
139                 GL_c_SCALE, added to the signed bias GL_c_BIAS,  and  clamped
140                 to the range [0,1] (see glPixelTransfer).
141
142       GL_BLUE   Each  element is a single blue component.  The GL converts it
143                 to floating point and assembles it into an  RGBA  element  by
144                 attaching  0 for red and green, and 1 for alpha.  Each compo‐
145                 nent  is  then  multiplied  by  the   signed   scale   factor
146                 GL_c_SCALE,  added  to the signed bias GL_c_BIAS, and clamped
147                 to the range [0,1] (see glPixelTransfer).
148
149       GL_ALPHA  Each element is a single alpha component.  The GL converts it
150                 to  floating  point  and assembles it into an RGBA element by
151                 attaching 0 for red, green, and blue.  Each component is then
152                 multiplied  by  the  signed scale factor GL_c_SCALE, added to
153                 the signed bias GL_c_BIAS, and clamped  to  the  range  [0,1]
154                 (see glPixelTransfer).
155
156       GL_RGB
157
158       GL_BGR    Each  element is an RGB triple.  The GL converts it to float‐
159                 ing point and assembles it into an RGBA element by  attaching
160                 1 for alpha.  Each component is then multiplied by the signed
161                 scale factor GL_c_SCALE, added to the signed bias  GL_c_BIAS,
162                 and clamped to the range [0,1] (see
163                 glPixelTransfer).
164
165       GL_RGBA
166
167       GL_BGRA   Each element contains all four components.  Each component is
168                 multiplied by the signed scale factor  GL_c_SCALE,  added  to
169                 the  signed  bias  GL_c_BIAS,  and clamped to the range [0,1]
170                 (see glPixelTransfer).
171
172       GL_LUMINANCE
173                 Each element is a single luminance value.  The GL converts it
174                 to  floating point, then assembles it into an RGBA element by
175                 replicating the luminance value three times for  red,  green,
176                 and  blue  and attaching 1 for alpha.  Each component is then
177                 multiplied by the signed scale factor  GL_c_SCALE,  added  to
178                 the  signed  bias  GL_c_BIAS,  and clamped to the range [0,1]
179                 (see glPixelTransfer).
180
181       GL_LUMINANCE_ALPHA
182                 Each element is a luminance/alpha pair.  The GL  converts  it
183                 to  floating point, then assembles it into an RGBA element by
184                 replicating the luminance value three times for  red,  green,
185                 and  blue.   Each  component is then multiplied by the signed
186                 scale factor GL_c_SCALE, added to the signed bias  GL_c_BIAS,
187                 and clamped to the range [0,1] (see
188                 glPixelTransfer).
189
190       Refer  to  the  glDrawPixels  reference  page  for a description of the
191       acceptable values for the type parameter.
192
193       If an application wants to store the texture at a certain resolution or
194       in  a certain , it can request the resolution and  with internalFormat.
195       The GL will choose an internal representation that closely approximates
196       that  requested  by internalFormat, but it may not match exactly.  (The
197       representations specified by GL_LUMINANCE, GL_LUMINANCE_ALPHA,  GL_RGB,
198       and  GL_RGBA  must match exactly. The numeric values 1, 2, 3, and 4 may
199       also be used to specify the above representations.)
200
201       Use the GL_PROXY_TEXTURE_2D target to try out a resolution  and  update
202       and recompute its best match for the requested storage resolution and .
203       To then query this state, call glGetTexLevelParameter.  If the  texture
204       cannot be accommodated, texture state is set to 0.
205
206       A  one-component  texture image uses only the red component of the RGBA
207       color extracted from pixels.  A two-component image uses the  R  and  A
208       values.   A three-component image uses the R, G, and B values.  A four-
209       component image uses all of the RGBA components.
210

NOTES

212       Texturing has no effect in color index mode.
213
214       If the GL_ARB_imaging extension is supported, RGBA elements may also be
215       processed by the imaging pipeline.  The following stages may be applied
216       to an RGBA color before color component clamping to the range [0, 1]:
217
218       1. Color component replacement by the color table specified for
219          GL_COLOR_TABLE, if enabled. See glColorTable.
220
221       2. Two-dimensional Convolution filtering, if enabled. See
222          glConvolutionFilter1D.
223
224          If a convolution filter changes the __width of the texture (by  pro‐
225          cessing  with  a  GL_CONVOLUTION_BORDER_MODE of GL_REDUCE, for exam‐
226          ple), the width must 2n+2(height), for some integer  n,  and  height
227          must be 2m+(border), for some integer m,  after filtering.
228
229       3. RGBA components may be multiplied by GL_POST_CONVOLUTION_c_SCALE,
230          and   added   to   GL_POST_CONVOLUTION_c_BIAS,   if   enabled.   See
231          glPixelTransfer.
232
233       4. Color component replacement by the color table specified for
234          GL_POST_CONVOLUTION_COLOR_TABLE, if enabled.  See glColorTable.
235
236       5. Transformation by the color matrix.  See glMatrixMode.
237
238       6. RGBA components may be multiplied by GL_POST_COLOR_MATRIX_c_SCALE,
239          and  added  to   GL_POST_COLOR_MATRIX_c_BIAS,   if   enabled.    See
240          glPixelTransfer.
241
242       7. Color component replacement by the color table specified for
243          GL_POST_COLOR_MATRIX_COLOR_TABLE, if enabled.  See glColorTable.
244
245       The  texture  image  can be represented by the same data formats as the
246       pixels in a glDrawPixels  command,  except  that  GL_STENCIL_INDEX  and
247       GL_DEPTH_COMPONENT  cannot  be  used.  glPixelStore and glPixelTransfer
248       modes  affect  texture  images  in  exactly   the   way   they   affect
249       glDrawPixels.
250
251       glTexImage2D  and GL_PROXY_TEXTURE_2D are available only if the GL ver‐
252       sion is 1.1 or greater.
253
254       Internal formats other than 1, 2, 3, or 4 may be used only  if  the  GL
255       version is 1.1 or greater.
256
257       In  GL  version  1.1 or greater, pixels may be a null pointer.  In this
258       case texture memory is allocated to  accommodate  a  texture  of  width
259       width and height height.  You can then download subtextures to initial‐
260       ize this texture memory.  The image is undefined if the user  tries  to
261       apply an uninitialized portion of the texture image to a primitive.
262
263       Formats   GL_BGR,   and   GL_BGRA   and  types  GL_UNSIGNED_BYTE_3_3_2,
264       GL_UNSIGNED_BYTE_2_3_3_REV,                    GL_UNSIGNED_SHORT_5_6_5,
265       GL_UNSIGNED_SHORT_5_6_5_REV,                 GL_UNSIGNED_SHORT_4_4_4_4,
266       GL_UNSIGNED_SHORT_4_4_4_4_REV,               GL_UNSIGNED_SHORT_5_5_5_1,
267       GL_UNSIGNED_SHORT_1_5_5_5_REV,                 GL_UNSIGNED_INT_8_8_8_8,
268       GL_UNSIGNED_INT_8_8_8_8_REV,      GL_UNSIGNED_INT_10_10_10_2,       and
269       GL_UNSIGNED_INT_2_10_10_10_REV  are available only if the GL version is
270       1.2 or greater.
271
272       When the GL_ARB_multitexture extension is supported, glTexImage2D spec‐
273       ifies  the two-dimensional texture for the current texture unit, speci‐
274       fied with glActiveTextureARB.
275

ERRORS

277       GL_INVALID_ENUM  is  generated  if  target  is  not  GL_TEXTURE_2D   or
278       GL_PROXY_TEXTURE_2D.
279
280       GL_INVALID_ENUM is generated if format is not an accepted
281        constant.    Format   constants   other   than   GL_STENCIL_INDEX  and
282       GL_DEPTH_COMPONENT are accepted.
283
284       GL_INVALID_ENUM is generated if type is not a type constant.
285
286       GL_INVALID_ENUM is generated if type is GL_BITMAP  and  format  is  not
287       GL_COLOR_INDEX.
288
289       GL_INVALID_VALUE is generated if level is less than 0.
290
291       GL_INVALID_VALUE  may  be  generated  if level is greater than log2max,
292       where max is the returned value of GL_MAX_TEXTURE_SIZE.
293
294       GL_INVALID_VALUE is generated if internalFormat is not 1, 2, 3,  4,  or
295       one of the accepted resolution and  symbolic constants.
296
297       GL_INVALID_VALUE  is  generated  if  width  or height is less than 0 or
298       greater than 2 + GL_MAX_TEXTURE_SIZE, or if  either  cannot  be  repre‐
299       sented as 2k+2(border) for some integer value of k.
300
301       GL_INVALID_VALUE is generated if border is not 0 or 1.
302
303       GL_INVALID_OPERATION  is  generated if glTexImage2D is executed between
304       the execution of glBegin and the corresponding execution of glEnd.
305
306       GL_INVALID_OPERATION   is    generated    if    type    is    one    of
307       GL_UNSIGNED_BYTE_3_3_2,                     GL_UNSIGNED_BYTE_2_3_3_REV,
308       GL_UNSIGNED_SHORT_5_6_5, or GL_UNSIGNED_SHORT_5_6_5_REV and  format  is
309       not GL_RGB.
310
311       GL_INVALID_OPERATION    is    generated    if    type    is    one   of
312       GL_UNSIGNED_SHORT_4_4_4_4,               GL_UNSIGNED_SHORT_4_4_4_4_REV,
313       GL_UNSIGNED_SHORT_5_5_5_1,               GL_UNSIGNED_SHORT_1_5_5_5_REV,
314       GL_UNSIGNED_INT_8_8_8_8,                   GL_UNSIGNED_INT_8_8_8_8_REV,
315       GL_UNSIGNED_INT_10_10_10_2,  or GL_UNSIGNED_INT_2_10_10_10_REV and for‐
316       mat is neither GL_RGBA nor GL_BGRA.
317

ASSOCIATED GETS

319       glGetTexImage
320       glIsEnabled with argument GL_TEXTURE_2D
321

SEE ALSO

323       glColorTable(3G),     glConvolutionFilter2D(3G),      glCopyPixels(3G),
324       glCopyTexImage1D(3G),   glCopyTexImage2D(3G),  glCopyTexSubImage1D(3G),
325       glCopyTexSubImage2D(3G),   glCopyTexSubImage3D(3G),   glDrawPixels(3G),
326       glMatrixMode(3G),         glPixelStore(3G),        glPixelTransfer(3G),
327       glSeparableFilter2D(3G), glTexEnv(3G), glTexGen(3G),  glTexImage1D(3G),
328       glTexImage3D(3G),       glTexSubImage1D(3G),       glTexSubImage2D(3G),
329       glTexSubImage3D(3G), glTexParameter(3G)
330
331
332
333
334                                                              GLTEXIMAGE2D(3G)
Impressum