[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glGetTexImage Subroutine


Returns a texture image.


OpenGL C bindings library: libGL.a

C Syntax

void glGetTexImage(GLenum Target, 
       GLint Level,
       GLenum Format, 
       GLenum Type, 
       GLvoid *Pixels)


Target Specifies which texture is to be obtained. GL_TEXTURE_1D, GL_TEXTURE_2D, and GL_TEXTURE_3D_EXT are accepted.
Level Specifies the level-of-detail number of the desired image. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Format Specifies a pixel format for the returned data. The supported formats are GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_RGBA, GL_ABGR_EXT, GL_LUMINANCE, and GL_LUMINANCE_ALPHA.
Type Specifies a pixel type for the returned data. The supported types are GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, and GL_FLOAT.
Pixels Returns the texture image. Should be a pointer to an array of the type specified by the Type parameter.


The glGetTexImage subroutine returns a texture image and places it in the Pixels parameter. Target specifies whether the desired texture image is one specified by glTexImage1D (GL_TEXTURE_1D), TexImage2D (GL_TEXTURE_2D), or by TexImage3DEXT (GL_TEXTURE_3D_EXT). Level specifies the level-of-detail number of the desired image. Format and Type specify the format and type of the desired image array. (See the glTexImage1D and glDrawPixels subroutines for a description of the acceptable values for the Format and Type parameters, respectively.)

Operation of glGetTexImage is best understood by considering the selected internal four-component texture image to be a red, green, blue, alpha (RGBA) color buffer that is the size of the image. The semantics of glGetTexImage are then identical to those of glReadPixels called with the same Format and Type, with x and y set to 0 (zero), Width set to the width of the texture image (including the border if one was specified), and Height set to 1 (one) for one-dimensional (1D) images, or to the height of the texture image (including the border if one was specified) for two-dimensional (2D) images. Because the internal texture image is an RGBA image, pixel formats GL_COLOR_INDEX, GL_STENCIL_INDEX, and GL_DEPTH_COMPONENT are not accepted, and pixel type GL_BITMAP is not accepted.

If the selected texture image does not contain four components, the following mappings are applied:

To determine the required size of Pixels, use the glGetTexLevelParameter subroutine to ascertain the dimensions of the internal texture image, then scale the required number of pixels by the storage required for each pixel, based on Format and Type. Be sure to consider the pixel storage parameters, especially GL_PACK_ALIGNMENT.


If an error is generated, no change is made to the contents of Pixels.

Format of GL_ABGR_EXT is part of the _extname (EXT_abgr) extension, not part of the core GL command set.

Target of GL_TEXTURE_3D_EXT is part of the _extname (EXT_texture3D) extension, not part of the core GL command set.


GL_INVALID_ENUM Either Target, Format, or Type is not an accepted value.
GL_INVALID_VALUE Level is less than 0 or greater than log2max, where max is the returned value of GL_MAX_TEXTURE_SIZE.
GL_INVALID_OPERATION The glGetTexImage subroutine is called between a call to glBegin and the corresponding call to glEnd.

Associated Gets

Associated gets for the glGetTexImage subroutine are as follows. (See the glGet subroutine for more information.)

glGetTexLevelParameter with argument GL_TEXTURE_WIDTH

glGetTexLevelParameter with argument GL_TEXTURE_HEIGHT

glGetTexLevelParameter with argument GL_TEXTURE_BORDER

glGetTexLevelParameter with argument GL_TEXTURE_COMPONENTS

glGet with arguments GL_PACK_ALIGNMENT and others.


/usr/include/GL/gl.h Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glBegin or glEnd subroutine, glDrawPixels subroutine, glReadPixels subroutine, glTexImage1D subroutine, glTexImage2D subroutine.

OpenGL Overview.

[ Previous | Next | Contents | Glossary | Home | Search ]