glTexImage1D
NAME
glTexImage1D - specify a one-dimensional texture image
C SPECIFICATION
void glTexImage1D(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels)
PARAMETERS
target
| Specifies the target texture. Must be
GL_TEXTURE_1D or GL_PROXY_TEXTURE_1D.
|
level
| Specifies the level-of-detail number. Level
0 is the base image level. Level n is the
nth mipmap reduction image.
|
internalformat
| Specifies the number of color components in
the texture. Must be 1, 2, 3, or 4, or one
of the following symbolic constants:
GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12,
GL_ALPHA16, GL_LUMINANCE, GL_LUMINANCE4,
GL_LUMINANCE8, GL_LUMINANCE12,
GL_LUMINANCE16, GL_LUMINANCE_ALPHA,
GL_LUMINANCE4_ALPHA4, GL_LUMINANCE6_ALPHA2,
GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4,
GL_LUMINANCE12_ALPHA12,
GL_LUMINANCE16_ALPHA16, GL_INTENSITY,
GL_INTENSITY4, GL_INTENSITY8,
GL_INTENSITY12, GL_INTENSITY16, GL_R3_G3_B2,
GL_RGB, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10,
GL_RGB12, GL_RGB16, GL_RGBA, GL_RGBA2,
GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2,
GL_RGBA12, or GL_RGBA16.
|
width
| Specifies the width of the texture image.
Must be 2n + 2 * border
for some integer n. All
implementations support texture images that
are at least 64 texels wide.
|
border
| Specifies the width of the border. Must be
either 0 or 1.
|
format
| The format of the pixel data. The allowable values are
GL_COLOR_INDEX, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA,
GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
GL_BGR_EXT, GL_BGRA_EXT, GL_ARGB_I3D, GL_422_EXT,
GL_422_REV_EXT, GL_422_AVERAGE_EXT, and GL_422_REV_AVERAGE_EXT.
|
type
| Specifies the data type for pixel data. The allowable values are
GL_BITMAP, GL_UNSIGNED_BYTE, GL_BYTE,
GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2_EXT,
GL_UNSIGNED_BYTE_2_3_3_REV_EXT, GL_UNSIGNED_SHORT_5_6_5_EXT,
GL_UNSIGNED_SHORT_5_6_5_REV_EXT, GL_UNSIGNED_SHORT_4_4_4_4_EXT,
GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_SHORT_5_5_5_1_EXT,
GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_INT_8_8_8_8_EXT,
GL_UNSIGNED_INT_8_8_8_8_REV_EXT, GL_UNSIGNED_INT_10_10_10_2_EXT,
and GL_UNSIGNED_INT_2_10_10_10_REV_EXT.
|
pixels
| Specifies a pointer to the image data in memory.
|
DESCRIPTION
Texturing maps a portion of a specified texture image onto
each graphical primitive for which texturing is enabled. To
enable and disable one-dimensional texturing, call
glEnable and
glDisable with argument GL_TEXTURE_1D.
Texture images are defined with glTexImage1D. The arguments
describe the parameters of the texture image, such as
width, width of the border, level-of-detail number
(see glTexParameter), and number of color components
provided. The last three arguments describe how the image
is represented in memory; they are identical to the pixel
formats used for glDrawPixels.
If target is GL_PROXY_TEXTURE_1D, no data is read from
pixels, but all of the texture image state is recalculated,
checked for consistency, and checked against the
implementation's capabilities. If the implementation cannot
handle a texture of the requested texture size, it sets all
of the image state to 0, but does not generate an error (see
glGetError). To query for an entire mipmap array, use an
image array level greater than or equal to 1.
If target is GL_TEXTURE_1D, data is read from pixels as a
sequence of signed or unsigned bytes, shorts, or longs, or
single-precision floating-point values, depending on type.
These values are grouped into sets of one, two, three, or
four values, depending on format, to form elements. If type
is GL_BITMAP, the data is considered as a string of unsigned
bytes (and format must be GL_COLOR_INDEX). Each data byte is
treated as eight 1-bit elements, with bit ordering
determined by GL_UNPACK_LSB_FIRST (see glPixelStore).
The first element corresponds to the left end of
the texture image. Subsequent elements progress left-to-
right through the remaining texels. The final
element corresponds to the right end of the texture image.
The format parameter determines the composition of each element in pixels.
- GL_COLOR_INDEX
-
Each element is a single value, a color index. The
value is converted to fixed point (with an unspecified
number of zero bits to the right of the binary
point), shifted left or right depending on the
value and sign of GL_INDEX_SHIFT, and added to
GL_INDEX_OFFSET (see glPixelTransfer).
The resulting index is converted
to a set of color components using the
GL_PIXEL_MAP_I_TO_R, GL_PIXEL_MAP_I_TO_G,
GL_PIXEL_MAP_I_TO_B, and GL_PIXEL_MAP_I_TO_A
tables, and clamped to the range [0,1].
- GL_RGBA
-
Each pixel is a four-component group: for GL_RGBA, the
red component is first, followed by green, followed by
blue, followed by alpha. Floating-point values are
converted directly to an internal floating-point format
with unspecified precision. Signed integer values are
mapped linearly to the internal floating-point format
such that the most positive representable integer value
maps to 1.0, and the most negative representable value
maps to -1.0. (Note that this mapping does not convert
0 precisely to 0.0.) Unsigned integer data is mapped
similarly: the largest integer value maps to 1.0, and
0 maps to 0.0. The resulting floating-point color
values are then multiplied by GL_c_SCALE and added to
GL_c_BIAS, where c is RED, GREEN,
BLUE, and ALPHA for the respective color
components.
If GL_MAP_COLOR is true, each color component is
clamped to the range [0,1] and scaled
by the size of lookup table GL_PIXEL_MAP_c_TO_c, then
replaced by the value that it references in that table.
c is R, G, B, or A respectively.
If GL_COLOR_TABLE_EXT is true, each color component is
clamped to the range [0,1] and scaled
by the size of the GL_COLOR_TABLE_EXT, then replaced by the value
that it references in that table according to the format of the color
table (see glColorTableEXT).
If GL_CONVOLUTION_1D_EXT is true
one-dimensional convolution will be performed on each color component
according to the format of the convolution filter (see
glConvolutionFilter1DEXT).
If the convolution border mode is such that the image is reduced, the resulting
image must be a valid texture image size.
If GL_POST_CONVOLUTION_COLOR_TABLE_EXT is true, each color component is
clamped to the range [0,1] and scaled
by the size of the GL_POST_CONVOLUTION_COLOR_TABLE_EXT, then replaced
by the value that it references in that table according to the format of the color
table (see glColorTableEXT).
Each color is then transformed by the color matrix
(see glMatrixMode).
If GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT is true, each color component is
clamped to the range [0,1] and scaled
by the size of the GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT, then replaced
by the value that it references in that table according to the format of the color
table (see glColorTableEXT).
Each color is then clamped to the color clamp values
(see glPixelTransfer).
- GL_RED
-
Each pixel is a single red component. This component
is converted to the internal floating-point format in
the same way the red component of an RGBA pixel is. It
is then converted to an RGBA pixel with green and blue
set to 0, and alpha set to 1. After this conversion,
the pixel is treated as if it had been read as an RGBA
pixel.
- GL_GREEN
-
Each pixel is a single green component. This component
is converted to the internal floating-point format in
the same way the green component of an RGBA pixel is.
It is then converted to an RGBA pixel with red and blue
set to 0, and alpha set to 1. After this conversion,
the pixel is treated as if it had been read as an RGBA
pixel.
- GL_BLUE
-
Each pixel is a single blue component. This component
is converted to the internal floating-point format in
the same way the blue component of an RGBA pixel is.
It is then converted to an RGBA pixel with red and
green set to 0, and alpha set to 1. After this
conversion, the pixel is treated as if it had been read
as an RGBA pixel.
- GL_ALPHA
-
Each pixel is a single alpha component. This component
is converted to the internal floating-point format in
the same way the alpha component of an RGBA pixel is.
It is then converted to an RGBA pixel with red, green,
and blue set to 0. After this conversion, the pixel is
treated as if it had been read as an RGBA pixel.
- GL_LUMINANCE
-
Each pixel is a single luminance component. This
component is converted to the internal floating-point
format in the same way the red component of an RGBA
pixel is. It is then converted to an RGBA pixel with
red, green, and blue set to the converted luminance
value, and alpha set to 1. After this conversion, the
pixel is treated as if it had been read as an RGBA
pixel.
- GL_LUMINANCE_ALPHA
-
Each pixel is a two-component group: luminance first,
followed by alpha. The two components are converted to
the internal floating-point format in the same way the
red component of an RGBA pixel is. They are then
converted to an RGBA pixel with red, green, and blue
set to the converted luminance value, and alpha set to
the converted alpha value. After this conversion, the
pixel is treated as if it had been read as an RGBA
pixel.
- GL_RGB
-
Each pixel is a three-component group: red first,
followed by green, followed by blue. Each component is
converted to the internal floating-point format in the
same way the red, green, and blue components of an RGBA
pixel are. The color triple is converted to an RGBA
pixel with alpha set to 1. After this conversion, the
pixel is treated as if it had been read as an RGBA
pixel.
- GL_BGR_EXT
-
Each pixel is a three-component group: blue first,
followed by green, followed by red. Each component is
converted to the internal floating-point format in the
same way the red, green, and blue components of an RGBA
pixel are. The color triple is converted to an RGBA
pixel with alpha set to 1. After this conversion, the
pixel is treated as if it had been read as an RGBA
pixel.
- GL_BGRA_EXT
-
Each pixel is a four-component group: blue first,
followed by green, followed by red, followed by alpha.
Each component is converted to the internal floating-point format in the
same way the red, green, and blue components of an RGBA
pixel are. The pixel is then treated as if it had been read
as an RGBA pixel.
- GL_ARGB_I3D
-
Each pixel is a four-component group: alpha first,
followed by red, followed by green, followed by blue.
Each component is converted to the internal floating-point format in the
same way the red, green, and blue components of an RGBA
pixel are. The pixel is then treated as if it had been read
as an RGBA pixel.
- GL_422_EXT
-
Each pixel is a two-component group: chrominance first,
followed by luminance. Only an even number of pixels are
processed. Luminance is present on all pixels; a full
chrominance value requires two pixels. Each component
is converted to the internal floating-point format in the
same way the red component of an RGBA pixel is. They are then
converted to an RGBA pixel with red set to converted luminance
value, green set to the even pixel's converted chrominance
value, blue set to the odd pixel's converted chrominance
value, and alpha set to 1. After this conversion, the pixel
is treated as if it had been read as an RGBA pixel.
- GL_422_REV_EXT
-
Each pixel is a two-component group: luminance first,
followed by chrominance. Conversion to RGBA then follows
the conversion of the GL_422_EXT format.
- GL_422_AVERAGE_EXT
-
Each pixel is a two-component group: chrominance first,
followed by luminance. Only an even number of pixels are
processed. Luminance is present on all pixels; a full
chrominance value requires two pixels. Each component
is converted to the internal floating-point format in the
same way the red component of an RGBA pixel is. They are then
converted to an RGBA pixel according to the following.
For even pixels, red is set to converted luminance
value, green is set to the even pixel's converted chrominance
value, blue is set to the odd pixel's converted chrominance
value, and alpha is set to 1.
For odd pixels, red is set to converted luminance
value, green is set to the average of the even pixel's
converted chrominance and the next even pixel's converted
chrominance value, blue is set to the average of the
odd pixel's converted chrominance and the next odd pixel's
converted chrominance, and alpha is set to 1. If the
next even or odd pixel does not exist, the behavior of
the odd pixel is the same as the GL_422_EXT format.
- GL_422_REV_AVERAGE_EXT
-
Each pixel is a two-component group: luminance first,
followed by chrominance. Conversion to RGBA then follows
the conversion of the GL_422_AVERAGE_EXT format.
Refer to the glDrawPixels
reference page for a description of the acceptable values
for the type parameter.
If an application wants to store the texture at a certain
resolution or in a certain format, it can request the
resolution and format with internalformat. The GL will
choose an internal representation that closely approximates
that requested by internalformat, but it may not match
exactly. (The representations specified by GL_LUMINANCE,
GL_LUMINANCE_ALPHA, GL_RGB (or GL_BGR_EXT), and GL_RGBA (or
GL_BGRA_EXT or GL_ARGB_I3D) must match exactly.
The numeric values 1, 2, 3, and 4 may also be used to
specify the above representations.)
Use the GL_PROXY_TEXTURE_1D target to try out a resolution
and format. The implementation will update and recompute its
best match for the requested storage resolution and format.
To then query this state, call glGetTexLevelParameter. If
the texture cannot be accommodated, texture state is set to 0.
A one-component texture image uses only the red component of
the RGBA color extracted from pixels. A two-component image
uses the R and A values. A three-component image uses the
R, G, and B values. A four-component image uses all of the
RGBA components.
NOTES
Texturing has no effect in color index mode.
A texture image with width specified
as a value of 0 indicates the null texture. If the null texture is specified
for level-of-detail 0, it is as if texturing were disabled.
The texture image can be represented by the same data
formats as the pixels in a glDrawPixels command, except that
GL_STENCIL_INDEX and GL_DEPTH_COMPONENT cannot be used.
glPixelStore and
glPixelTransfer modes affect texture images
in exactly the way they affect glDrawPixels.
glTexImage1D and GL_PROXY_TEXTURE_1D are only available if
the GL version is 1.1 or greater.
Internal formats other than 1, 2, 3, or 4 may only be used
if the GL version is 1.1 or greater.
In GL version 1.1 or greater, pixels may be a null pointer.
In this case texture memory is allocated to accommodate a
texture of width width.
Subtextures can be used to initialize the texture memory. The
image is undefined if the user tries to apply an
uninitialized portion of the texture image to a primitive.
EXTENSIONS
Some routines and constants for this function are part of an extension, not part of the
core GL command set. The following extension names must be present in the string returned by
glGetString when called with argument GL_EXTENSIONS
to use these routines and constants.
- GL_EXT_422_pixels
-
GL_422_EXT, GL_422_REV_EXT,
GL_422_AVERAGE_EXT, and GL_422_REV_AVERAGE_EXT
are part of the EXT_422_pixels extension.
- GL_I3D_argb
- GL_ARGB_I3D is part of the I3D_argb
extension.
- GL_EXT_bgra
-
GL_BGR_EXT and GL_BGRA_EXT
are part of the EXT_bgra extension.
- GL_I3D_color_clamp
-
The color clamp
is part of the I3D_color_clamp extension.
- GL_EXT_color_matrix
-
The color matrix
is part of the EXT_color_matrix extension.
- GL_EXT_color_table
-
GL_COLOR_TABLE_EXT, GL_POST_CONVOLUTION_COLOR_TABLE_EXT, and
GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT
are part of the EXT_color_table extension.
- GL_EXT_convolution
-
GL_CONVOLUTION_1D_EXT
is part of the EXT_convolution extension.
- GL_EXT_packed_pixels
-
GL_UNSIGNED_BYTE_3_3_2_EXT, GL_UNSIGNED_BYTE_2_3_3_REV_EXT,
GL_UNSIGNED_SHORT_5_6_5_EXT, GL_UNSIGNED_SHORT_5_6_5_REV_EXT,
GL_UNSIGNED_SHORT_4_4_4_4_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT,
GL_UNSIGNED_SHORT_5_5_5_1_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT,
GL_UNSIGNED_INT_8_8_8_8_EXT, GL_UNSIGNED_INT_8_8_8_8_REV_EXT,
GL_UNSIGNED_INT_10_10_10_2_EXT, and GL_UNSIGNED_INT_2_10_10_10_REV_EXT
are part of the EXT_packed_pixels extension.
ERRORS
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_1D
or GL_PROXY_TEXTURE_1D.
GL_INVALID_ENUM is generated if format is not an accepted
format constant. Format constants other than
GL_STENCIL_INDEX and GL_DEPTH_COMPONENT are accepted.
GL_INVALID_ENUM is generated if type is not a type constant.
GL_INVALID_ENUM is generated if type is GL_BITMAP and format
is not GL_COLOR_INDEX.
GL_INVALID_VALUE is generated if level is less than 0.
GL_INVALID_VALUE may be generated if level is greater than
LOG2(max), where max is the returned value of
GL_MAX_TEXTURE_SIZE.
GL_INVALID_VALUE is generated if internalformat is not 1, 2,
3, 4, or one of the accepted resolution and format symbolic
constants.
GL_INVALID_VALUE is generated if width is less
than 0 or greater than 2 + GL_MAX_TEXTURE_SIZE, or if either
cannot be represented as 2k + 2 * border for some integer value
of k.
GL_INVALID_VALUE is generated if border is not 0 or 1.
GL_INVALID_OPERATION is generated if glTexImage1D is
executed between the execution of glBegin and the
corresponding execution of glEnd.
ASSOCIATED GETS
glGetTexImage
glIsEnabled with argument GL_TEXTURE_1D
SEE ALSO
glCopyPixels,
glCopyTexImage1D,
glCopyTexImage2D,
glCopyTexSubImage1D,
glCopyTexSubImage2D,
glDrawPixels,
glPixelStore,
glPixelTransfer,
glTexEnv,
glTexGen,
glTexImage2D,
glTexImage3DEXT,
glTexSubImage1D,
glTexSubImage2D,
glTexSubImage3DEXT,
glTexParameter