GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


Manpage of GLTEXIMAGE2D

GLTEXIMAGE2D

Index
 

NAME

glTexImage2D - specify a two-dimensional texture image

 

C SPECIFICATION

void f3glTexImage2DfP( GLenum fItargetfP,
f2targetfP
Specifies the target texture.
Must be %f3GL_TEXTURE_2DfP or %f3GL_PROXY_TEXTURE_2DfP.
f2levelfP
Specifies the level-of-detail number. Level 0 is the base image level. Level f2nfP is the f2nfPth mipmap reduction image.
f2internalFormatfP
Specifies the number of color components in the texture. Must be 1, 2, 3, or 4, or one of the following symbolic constants: %f3GL_ALPHAfP, %f3GL_ALPHA4fP, %f3GL_ALPHA8fP, %f3GL_ALPHA12fP, %f3GL_ALPHA16fP, %f3GL_LUMINANCEfP, %f3GL_LUMINANCE4fP, %f3GL_LUMINANCE8fP, %f3GL_LUMINANCE12fP, %f3GL_LUMINANCE16fP, %f3GL_LUMINANCE_ALPHAfP, %f3GL_LUMINANCE4_ALPHA4fP, %f3GL_LUMINANCE6_ALPHA2fP, %f3GL_LUMINANCE8_ALPHA8fP, %f3GL_LUMINANCE12_ALPHA4fP, %f3GL_LUMINANCE12_ALPHA12fP, %f3GL_LUMINANCE16_ALPHA16fP, %f3GL_INTENSITYfP, %f3GL_INTENSITY4fP, %f3GL_INTENSITY8fP, %f3GL_INTENSITY12fP, %f3GL_INTENSITY16fP, %f3GL_R3_G3_B2fP, %f3GL_RGBfP, %f3GL_RGB4fP, %f3GL_RGB5fP, %f3GL_RGB8fP, %f3GL_RGB10fP, %f3GL_RGB12fP, %f3GL_RGB16fP, %f3GL_RGBAfP, %f3GL_RGBA2fP, %f3GL_RGBA4fP, %f3GL_RGB5_A1fP, %f3GL_RGBA8fP, %f3GL_RGB10_A2fP, %f3GL_RGBA12fP, or %f3GL_RGBA16fP.
f2widthfP
Specifies the width of the texture image. Must be $2 sup n ~+~ 2 ( "border" )$ for some integer $n$. All implementations support texture images that are at least 64 texels wide.
f2heightfP
Specifies the height of the texture image. Must be $2 sup m ~+~ 2 ( "border" )$ for some integer $m$. All implementations support texture images that are at least 64 texels high.
f2borderfP
Specifies the width of the border. Must be either 0 or 1.
f2formatfP
Specifies the of the pixel data. The following symbolic values are accepted: %f3GL_COLOR_INDEXfP, %f3GL_REDfP, %f3GL_GREENfP, %f3GL_BLUEfP, %f3GL_ALPHAfP, %f3GL_RGBfP, %f3GL_BGRfP %f3GL_RGBAfP, %f3GL_BGRAfP, %f3GL_LUMINANCEfP, and %f3GL_LUMINANCE_ALPHAfP.
f2typefP
Specifies the data type of the pixel data. The following symbolic values are accepted: %f3GL_UNSIGNED_BYTEfP, %f3GL_BYTEfP, %f3GL_BITMAPfP, %f3GL_UNSIGNED_SHORTfP, %f3GL_SHORTfP, %f3GL_UNSIGNED_INTfP, %f3GL_INTfP, %f3GL_FLOATfP, %f3GL_UNSIGNED_BYTE_3_3_2fP, %f3GL_UNSIGNED_BYTE_2_3_3_REVfP, %f3GL_UNSIGNED_SHORT_5_6_5fP, %f3GL_UNSIGNED_SHORT_5_6_5_REVfP, %f3GL_UNSIGNED_SHORT_4_4_4_4fP, %f3GL_UNSIGNED_SHORT_4_4_4_4_REVfP, %f3GL_UNSIGNED_SHORT_5_5_5_1fP, %f3GL_UNSIGNED_SHORT_1_5_5_5_REVfP, %f3GL_UNSIGNED_INT_8_8_8_8fP, %f3GL_UNSIGNED_INT_8_8_8_8_REVfP, %f3GL_UNSIGNED_INT_10_10_10_2fP, and %f3GL_UNSIGNED_INT_2_10_10_10_REVfP.
f2pixelsfP
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 two-dimensional texturing, call %f3glEnablefP and %f3glDisablefP with argument %f3GL_TEXTURE_2DfP. To define texture images, call %f3glTexImage2DfP. The arguments describe the parameters of the texture image, such as height, width, width of the border, level-of-detail number (see %f3glTexParameterfP), 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 %f3glDrawPixelsfP. If f2targetfP is %f3GL_PROXY_TEXTURE_2DfP, no data is read from f2pixelsfP, 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 %f3glGetErrorfP). To query for an entire mipmap array, use an image array level greater than or equal to 1. If f2targetfP is %f3GL_TEXTURE_2DfP, data is read from f2pixelsfP as a sequence of signed or unsigned bytes, shorts, or longs, or single-precision floating-point values, depending on f2typefP. These values are grouped into sets of one, two, three, or four values, depending on f2formatfP, to form elements. If f2typefP is %f3GL_BITMAPfP, the data is considered as a string of unsigned bytes (and f2formatfP must be %f3GL_COLOR_INDEXfP). Each data byte is treated as eight 1-bit elements, with bit ordering determined by %f3GL_UNPACK_LSB_FIRSTfP (see %f3glPixelStorefP). The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image. f2formatfP determines the composition of each element in f2pixelsfP. It can assume one of eleven symbolic values:
%f3GL_COLOR_INDEXfP
Each element is a single value, a color index. The GL converts it 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 %f3GL_INDEX_SHIFTfP, and added to %f3GL_INDEX_OFFSETfP (see
%f3glPixelTransferfP). The resulting index is converted to a set of color components using the %f3GL_PIXEL_MAP_I_TO_RfP, %f3GL_PIXEL_MAP_I_TO_GfP, %f3GL_PIXEL_MAP_I_TO_BfP, and %f3GL_PIXEL_MAP_I_TO_AfP tables, and clamped to the range [0,1].
%f3GL_REDfP
Each element is a single red component. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for green and blue, and 1 for alpha. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_GREENfP
Each element is a single green component. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for red and blue, and 1 for alpha. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_BLUEfP
Each element is a single blue component. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for red and green, and 1 for alpha. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_ALPHAfP
Each element is a single alpha component. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for red, green, and blue. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_RGBfP
%f3GL_BGRfP
Each element is an RGB triple. The GL converts it to floating point and assembles it into an RGBA element by attaching 1 for alpha. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see
%f3glPixelTransferfP).
%f3GL_RGBAfP
%f3GL_BGRAfP
Each element contains all four components. Each component is multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_LUMINANCEfP
Each element is a single luminance value. The GL converts it to floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue and attaching 1 for alpha. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see %f3glPixelTransferfP).
%f3GL_LUMINANCE_ALPHAfP
Each element is a luminance/alpha pair. The GL converts it to floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue. Each component is then multiplied by the signed scale factor %f3GL_c_SCALEfP, added to the signed bias %f3GL_c_BIASfP, and clamped to the range [0,1] (see
%f3glPixelTransferfP). Refer to the %f3glDrawPixelsfP reference page for a description of the acceptable values for the f2typefP parameter. If an application wants to store the texture at a certain resolution or in a certain , it can request the resolution and with f2internalFormatfP. The GL will choose an internal representation that closely approximates that requested by f2internalFormatfP, but it may not match exactly. (The representations specified by %f3GL_LUMINANCEfP, %f3GL_LUMINANCE_ALPHAfP, %f3GL_RGBfP, and %f3GL_RGBAfP must match exactly. The numeric values 1, 2, 3, and 4 may also be used to specify the above representations.) Use the %f3GL_PROXY_TEXTURE_2DfP target to try out a resolution and update and recompute its best match for the requested storage resolution and . To then query this state, call %f3glGetTexLevelParameterfP. 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 f2pixelsfP. 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. If the %f3GL_ARB_imagingfP extension is supported, RGBA elements may also be processed by the imaging pipeline. The following stages may be applied to an RGBA color before color component clamping to the range [0, 1]:
1. Color component replacement by the color table specified for
%f3GL_COLOR_TABLEfP, if enabled. See %f3glColorTablefP.
2. Two-dimensional Convolution filtering, if enabled. See
%f3glConvolutionFilter1DfP.
If a convolution filter changes the __width of the texture (by processing with a %f3GL_CONVOLUTION_BORDER_MODEfP of %f3GL_REDUCEfP, for example), the f2widthfP must $2 sup n + 2 ( "height" )$, for some integer $n$, and f2heightfP must be $2 sup m + ( "border" )$, for some integer $m$, after filtering.
3. RGBA components may be multiplied by %f3GL_POST_CONVOLUTION_c_SCALEfP,
and added to %f3GL_POST_CONVOLUTION_c_BIASfP, if enabled. See %f3glPixelTransferfP.
4. Color component replacement by the color table specified for
%f3GL_POST_CONVOLUTION_COLOR_TABLEfP, if enabled. See %f3glColorTablefP.
5. Transformation by the color matrix. See %f3glMatrixModefP.
6. RGBA components may be multiplied by %f3GL_POST_COLOR_MATRIX_c_SCALEfP,
and added to %f3GL_POST_COLOR_MATRIX_c_BIASfP, if enabled. See %f3glPixelTransferfP.
7. Color component replacement by the color table specified for
%f3GL_POST_COLOR_MATRIX_COLOR_TABLEfP, if enabled. See %f3glColorTablefP. The texture image can be represented by the same data formats as the pixels in a %f3glDrawPixelsfP command, except that %f3GL_STENCIL_INDEXfP and %f3GL_DEPTH_COMPONENTfP cannot be used. %f3glPixelStorefP and %f3glPixelTransferfP modes affect texture images in exactly the way they affect %f3glDrawPixelsfP. %f3glTexImage2DfP and %f3GL_PROXY_TEXTURE_2DfP are available only if the GL version is 1.1 or greater. Internal formats other than 1, 2, 3, or 4 may be used only if the GL version is 1.1 or greater. In GL version 1.1 or greater, f2pixelsfP may be a null pointer. In this case texture memory is allocated to accommodate a texture of width f2widthfP and height f2heightfP. You can then download subtextures to initialize this texture memory. The image is undefined if the user tries to apply an uninitialized portion of the texture image to a primitive. Formats %f3GL_BGRfP, and %f3GL_BGRAfP and types %f3GL_UNSIGNED_BYTE_3_3_2fP, %f3GL_UNSIGNED_BYTE_2_3_3_REVfP, %f3GL_UNSIGNED_SHORT_5_6_5fP, %f3GL_UNSIGNED_SHORT_5_6_5_REVfP, %f3GL_UNSIGNED_SHORT_4_4_4_4fP, %f3GL_UNSIGNED_SHORT_4_4_4_4_REVfP, %f3GL_UNSIGNED_SHORT_5_5_5_1fP, %f3GL_UNSIGNED_SHORT_1_5_5_5_REVfP, %f3GL_UNSIGNED_INT_8_8_8_8fP, %f3GL_UNSIGNED_INT_8_8_8_8_REVfP, %f3GL_UNSIGNED_INT_10_10_10_2fP, and %f3GL_UNSIGNED_INT_2_10_10_10_REVfP are available only if the GL version is 1.2 or greater. When the %f3GL_ARB_multitexturefP extension is supported, %f3glTexImage2DfP specifies the two-dimensional texture for the current texture unit, specified with %f3glActiveTextureARBfP.
 

ERRORS

%f3GL_INVALID_ENUMfP is generated if f2targetfP is not %f3GL_TEXTURE_2DfP or %f3GL_PROXY_TEXTURE_2DfP. %f3GL_INVALID_ENUMfP is generated if f2formatfP is not an accepted
 constant. Format constants other than %f3GL_STENCIL_INDEXfP and %f3GL_DEPTH_COMPONENTfP are accepted. %f3GL_INVALID_ENUMfP is generated if f2typefP is not a type constant. %f3GL_INVALID_ENUMfP is generated if f2typefP is %f3GL_BITMAPfP and f2formatfP is not %f3GL_COLOR_INDEXfP. %f3GL_INVALID_VALUEfP is generated if f2levelfP is less than 0. %f3GL_INVALID_VALUEfP may be generated if f2levelfP is greater than $log sub 2$f2maxfP, where f2maxfP is the returned value of %f3GL_MAX_TEXTURE_SIZEfP. %f3GL_INVALID_VALUEfP is generated if f2internalFormatfP is not 1, 2, 3, 4, or one of the accepted resolution and symbolic constants. %f3GL_INVALID_VALUEfP is generated if f2widthfP or f2heightfP is less than 0 or greater than 2 + %f3GL_MAX_TEXTURE_SIZEfP, or if either cannot be represented as $2 sup k ~+~ 2("border")$ for some integer value of f2kfP. %f3GL_INVALID_VALUEfP is generated if f2borderfP is not 0 or 1. %f3GL_INVALID_OPERATIONfP is generated if %f3glTexImage2DfP is executed between the execution of %f3glBeginfP and the corresponding execution of %f3glEndfP. %f3GL_INVALID_OPERATIONfP is generated if f2typefP is one of %f3GL_UNSIGNED_BYTE_3_3_2fP, %f3GL_UNSIGNED_BYTE_2_3_3_REVfP, %f3GL_UNSIGNED_SHORT_5_6_5fP, or %f3GL_UNSIGNED_SHORT_5_6_5_REVfP and f2formatfP is not %f3GL_RGBfP. %f3GL_INVALID_OPERATIONfP is generated if f2typefP is one of %f3GL_UNSIGNED_SHORT_4_4_4_4fP, %f3GL_UNSIGNED_SHORT_4_4_4_4_REVfP, %f3GL_UNSIGNED_SHORT_5_5_5_1fP, %f3GL_UNSIGNED_SHORT_1_5_5_5_REVfP, %f3GL_UNSIGNED_INT_8_8_8_8fP, %f3GL_UNSIGNED_INT_8_8_8_8_REVfP, %f3GL_UNSIGNED_INT_10_10_10_2fP, or %f3GL_UNSIGNED_INT_2_10_10_10_REVfP and f2formatfP is neither %f3GL_RGBAfP nor %f3GL_BGRAfP.  

ASSOCIATED GETS

%f3glGetTexImagefP
%f3glIsEnabledfP with argument %f3GL_TEXTURE_2DfP  

SEE ALSO

%f3glColorTable(3G)fP, %f3glConvolutionFilter2D(3G)fP, %f3glCopyPixels(3G)fP, %f3glCopyTexImage1D(3G)fP, %f3glCopyTexImage2D(3G)fP, %f3glCopyTexSubImage1D(3G)fP, %f3glCopyTexSubImage2D(3G)fP, %f3glCopyTexSubImage3D(3G)fP, %f3glDrawPixels(3G)fP, %f3glMatrixMode(3G)fP, %f3glPixelStore(3G)fP, %f3glPixelTransfer(3G)fP, %f3glSeparableFilter2D(3G)fP, %f3glTexEnv(3G)fP, %f3glTexGen(3G)fP, %f3glTexImage1D(3G)fP, %f3glTexImage3D(3G)fP, %f3glTexSubImage1D(3G)fP, %f3glTexSubImage2D(3G)fP, %f3glTexSubImage3D(3G)fP, %f3glTexParameter(3G)fP


 

Index

NAME
C SPECIFICATION
DESCRIPTION
NOTES
ERRORS
ASSOCIATED GETS
SEE ALSO