glTexImage2D

specify a two-dimensional texture image

Signature

glTexImage2D( GLenum ( target ) , GLint ( level ) , GLint ( internalFormat ) , GLsizei ( width ) , GLsizei ( height ) , GLint ( border ) , GLenum ( format ) , GLenum ( type ) , const GLvoid * ( data ) )-> void
glTexImage2D( target , level , internalformat , width , height , border , format , type , pixels )
glTexImage2Df( target , level , internalformat , border , format , pixels )
glTexImage2Di( target , level , internalformat , border , format , pixels )
glTexImage2Ds( target , level , internalformat , border , format , pixels )
glTexImage2Dui( target , level , internalformat , border , format , pixels )
glTexImage2Dus( target , level , internalformat , border , format , pixels )

Parameters

VariablesDescription
target
Specifies the target texture. Must be GL_TEXTURE_2D , GL_PROXY_TEXTURE_2D , GL_TEXTURE_1D_ARRAY , GL_PROXY_TEXTURE_1D_ARRAY , GL_TEXTURE_RECTANGLE , GL_PROXY_TEXTURE_RECTANGLE , GL_TEXTURE_CUBE_MAP_POSITIVE_X , GL_TEXTURE_CUBE_MAP_NEGATIVE_X , GL_TEXTURE_CUBE_MAP_POSITIVE_Y , GL_TEXTURE_CUBE_MAP_NEGATIVE_Y , GL_TEXTURE_CUBE_MAP_POSITIVE_Z , GL_TEXTURE_CUBE_MAP_NEGATIVE_Z , or GL_PROXY_TEXTURE_CUBE_MAP .
level
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the n th mipmap reduction image. If target is GL_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_RECTANGLE , level must be 0.
internalFormat
Specifies the number of color components in the texture. Must be one of base internal formats given in Table 1, one of the sized internal formats given in Table 2, or one of the compressed internal formats given in Table 3, below.
width
Specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide.
height
Specifies the height of the texture image, or the number of layers in a texture array, in the case of the GL_TEXTURE_1D_ARRAY and GL_PROXY_TEXTURE_1D_ARRAY targets. All implementations support 2D texture images that are at least 1024 texels high, and texture arrays that are at least 256 layers deep.
border
This value must be 0.
format
Specifies the format of the pixel data. The following symbolic values are accepted: GL_RED , GL_RG , GL_RGB , GL_BGR , GL_RGBA , GL_BGRA , GL_RED_INTEGER , GL_RG_INTEGER , GL_RGB_INTEGER , GL_BGR_INTEGER , GL_RGBA_INTEGER , GL_BGRA_INTEGER , GL_STENCIL_INDEX , GL_DEPTH_COMPONENT , GL_DEPTH_STENCIL .
type
Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE , GL_BYTE , GL_UNSIGNED_SHORT , GL_SHORT , GL_UNSIGNED_INT , GL_INT , GL_FLOAT , GL_UNSIGNED_BYTE_3_3_2 , GL_UNSIGNED_BYTE_2_3_3_REV , GL_UNSIGNED_SHORT_5_6_5 , GL_UNSIGNED_SHORT_5_6_5_REV , GL_UNSIGNED_SHORT_4_4_4_4 , GL_UNSIGNED_SHORT_4_4_4_4_REV , GL_UNSIGNED_SHORT_5_5_5_1 , GL_UNSIGNED_SHORT_1_5_5_5_REV , GL_UNSIGNED_INT_8_8_8_8 , GL_UNSIGNED_INT_8_8_8_8_REV , GL_UNSIGNED_INT_10_10_10_2 , and GL_UNSIGNED_INT_2_10_10_10_REV .
data
Specifies a pointer to the image data in memory.

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glTexImage2D
OpenGLContext tests/dek_texturesurf.py Lines: 110
OpenGLContext tests/nehe7.py Lines: 102, 110
OpenGLContext tests/nehe6_convolve.py Lines: 128
OpenGLContext tests/shadow_1.py Lines: 524
OpenGLContext tests/nehe8.py Lines: 136, 144
OpenGLContext tests/shadow_2.py Lines: 74
OpenGLContext tests/nehe6.py Lines: 54
OpenGLContext OpenGLContext/texture.py Lines: 87, 258
OpenGL-Demo PyOpenGL-Demo/dek/tile.py Lines: 60
OpenGL-Demo PyOpenGL-Demo/dek/texturesurf.py Lines: 84
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 169
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 149
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 71
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 74
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 74, 87
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 209
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 72
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 39
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 36
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 41
{LGPL} PyUI pyui/renderers/openglPygame.py Lines: 153, 277
{LGPL} PyUI pyui/renderers/openglGlut.py Lines: 209
{LGPL} PyUI2 renderers/openglPygame.py Lines: 156, 280
{LGPL} PyUI2 renderers/openglGlut.py Lines: 209
{LGPL} PyUI2 system/openglgraphics.py Lines: 226, 332
{LGPL} VisionEgg VisionEgg/SphereMap.py Lines: 1030, 1047
{LGPL} VisionEgg VisionEgg/Textures.py Lines: 697, 744
{LGPL} PyMT pymt/texture.py Lines: 17, 256
{LGPL} Pyggel pyggel/data.py Lines: 152
{LGPL} pygl2d pygl2d/image.py Lines: 52
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 85
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 135, 143
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Display3D.py Lines: 450
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/TexPlane.py Lines: 236
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Button3D.py Lines: 137
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 496
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/TexPlane.py Lines: 99
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Button.py Lines: 173
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Label.py Lines: 207
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 883
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/TexPlane.py Lines: 139
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Button.py Lines: 270
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Utils/Particles3D.py Lines: 120
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Display3D.py Lines: 450
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/TexPlane.py Lines: 236
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Button3D.py Lines: 137
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 496
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/TexPlane.py Lines: 99
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Button.py Lines: 173
{LGPL or GPL or MPL} Kamaelia Sketches/MH/OpenGL/3dFolding.py Lines: 172
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/Label.py Lines: 207
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 882
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/TexPlane.py Lines: 139
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/Button.py Lines: 259
Visvis core/line.py Lines: 73
Visvis core/baseTexture.py Lines: 423, 448
Visvis text/text_base.py Lines: 76