glTexImage3DEXT

NAME

glTexImage3DEXT - specify a three-dimensional texture image

C SPECIFICATION

void glTexImage3DEXT(GLenum target,
                     GLint level,
                     GLenum internalformat,
                     GLsizei width,
                     GLsizei height,
                     GLsizei depth,
                     GLint border,
                     GLenum format,
                     GLenum type,
                     const GLvoid *pixels)

PARAMETERS

target Specifies the target texture. Must be GL_TEXTURE_3D_EXT or GL_PROXY_TEXTURE_3D_EXT.
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 internal storage format of the texture image. it must be one of the following symbolic constants: GL_ALPHA, GL_ALPHA4_EXT, GL_ALPHA8_EXT, GL_ALPHA12_EXT, GL_ALPHA16_EXT, GL_LUMINANCE, GL_LUMINANCE4_EXT, GL_LUMINANCE8_EXT, GL_LUMINANCE12_EXT, GL_LUMINANCE16_EXT, GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4_EXT, GL_LUMINANCE6_ALPHA2_EXT, GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE12_ALPHA4_EXT, GL_LUMINANCE12_ALPHA12_EXT, GL_LUMINANCE16_ALPHA16_EXT, GL_INTENSITY_EXT, GL_INTENSITY4_EXT, GL_INTENSITY8_EXT, GL_INTENSITY12_EXT, GL_INTENSITY16_EXT, GL_RGB, GL_RGB2_EXT, GL_RGB4_EXT, GL_RGB5_EXT, GL_RGB8_EXT, GL_RGB10_EXT, GL_RGB12_EXT, GL_RGB16_EXT, GL_RGBA, GL_RGBA2_EXT, GL_RGBA4_EXT, GL_RGB5_A1_EXT, GL_RGBA8_EXT, GL_RGB10_A2_EXT, GL_RGBA12_EXT, or GL_RGBA16_EXT.
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 16 texels wide.
height Specifies the height of the texture image. Must be 2m + 2 * border for some integer m. If GL_INTERLACE_EXT is enabled, the height must be 2m + border since the height will be doubled. All implementations support texture images that are at least 16 texels high.
depth Specifies the depth of the texture image. Must be 2l + 2 * border for some integer l. All implementations support texture images that are at least 16 texels deep.
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. Three-dimensional texturing is enabled and disabled using glEnable and glDisable with argument GL_TEXTURE_3D_EXT.

Texture images are defined with glTexImage3DEXT. The arguments describe the parameters of the texture image, such as height, width, depth, width of the border, level-of-detail number (see glTexParameter), and the internal resolution and format used to store the image. The last three arguments describe the way the image is represented in memory, and they are identical to the pixel formats used for glDrawPixels.

If target is GL_PROXY_TEXTURE_3D_EXT 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 will set all of the texture 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_3D_EXT, 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 lower-left-rear corner of the texture volume. Subsequent elements progress left-to-right through the remaining texels in the lowest-rear row of the texture volume, then in successively higher rows of the rear 2D slice of the texture volume, then in successively closer 2D slices of the texture volume. The final element corresponds to the upper-right-front corner of the texture volume.

When GL_INTERLACE_EXT is enabled, only rows (0,2,4,...) of each S-T slice (where the border is considered part of the slice) are defined. Rows (1,3,5,...) are left undefined and can only be defined using glTexSubImage3DEXT or glCopyTexSubImage3DEXT.

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).

Convolution is not supported for three-dimensional textures.

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.)

Use the GL_PROXY_TEXTURE_2D 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, height, or depth 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.

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.

EXT_interlace
GL_INTERLACE_EXT is part of the EXT_interlace 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.

GL_EXT_texture3D
glTexImage3DEXT, GL_TEXTURE_3D_EXT, and GL_PROXY_TEXTURE_3D_EXT are part of the EXT_texture3D extension.

ERRORS

GL_INVALID_ENUM is generated when target is not an accepted value.

GL_INVALID_ENUM is generated when format is not an accepted value.

GL_INVALID_ENUM is generated when type is not an accepted value.

GL_INVALID_VALUE is generated if level is less than zero or greater than LOG2(max), where max is the returned value of GL_MAX_3D_TEXTURE_SIZE_EXT.

GL_INVALID_VALUE is generated if internalformat is not an accepted value.

GL_INVALID_VALUE is generated if width, height, or depth is less than zero or greater than 2 + GL_MAX_3D_TEXTURE_SIZE_EXT, when width, or depth cannot be represented as 2k + 2 * border for some integer k, or when height cannot be represented as 2k + I * border, where I is 1 when GL_INTERLACE_EXT is enabled and 2 otherwise.

GL_INVALID_VALUE is generated if border is not 0 or 1.

GL_INVALID_OPERATION is generated if glTexImage3DEXT is executed between the execution of glBegin and the corresponding execution of glEnd.

GL_TEXTURE_TOO_LARGE_EXT is generated if the implementation cannot accommodate a texture of the size requested.

ASSOCIATED GETS

glGetTexImage
glIsEnabled with argument GL_TEXTURE_3D_EXT
glGetTexLevelParameter with a first argument of GL_PROXY_TEXTURE_3D_EXT and a third argument of GL_TEXTURE_RED_SIZE_EXT, GL_TEXTURE_GREEN_SIZE_EXT, GL_TEXTURE_BLUE_SIZE_EXT, GL_TEXTURE_ALPHA_SIZE_EXT, GL_TEXTURE_LUMINANCE_SIZE_EXT, GL_TEXTURE_INTENSITY_SIZE_EXT, GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT, GL_TEXTURE_DEPTH_EXT, GL_TEXTURE_BORDER, or GL_TEXTURE_COMPONENTS.

SEE ALSO

glCopyTexSubImage3DEXT, glDrawPixels, glFog, glPixelStore, glPixelTransfer, glTexEnv, glTexGen, glTexImage1D, glTexImage2D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3DEXT, glTexParameter