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.
void glTexImage2D( GLenum target,
GLint level,
GLint components,
GLsizei width, GLsizei height, GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels )
target
Specifies the target texture. Must be GL_TEXTURE_2D.
level
Specifies the level-of-detail number. Level 0 is the base image level.
Level n is the nth mipmap reduction image.
components
Specifies the number of (internal) color components in the texture.
Must be 1, 2, 3, or 4.
width
Specifies the width of the texture image. Must be 2n + 2 ( border ) for some
integer n.
height
Specifies the height of the texture image.
Must be 2m + 2 ( border ) for some integer m.
border
Specifies the width of the border. Must be either 0 or 1.
format
Specifies the (external) format of the pixel data.
The following symbolic values are accepted:
GL_COLOR_INDEX, GL_RED, GL_GREEN, GL_BLUE,
GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, and GL_LUMINANCE_ALPHA.
type
Specifies the data type of the pixel data.
The following symbolic values are accepted:
GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT,
GL_UNSIGNED_INT, GL_INT, and GL_FLOAT.
pixels
Specifies a pointer to the image data in memory.
Example:
gl.glTexImage2D( target, 0, // Mipmap level. GL.GL_RGBA,// GL.GL_RGBA, // Internal Texel Format, texture.getWidth(), texture.getHeight(), 0, //Border GL.GL_RGB, // External format from image, GL.GL_UNSIGNED_BYTE, texture.getPixels() // Imagedata );