Graphics Reference
In-Depth Information
After uploading a texture image using
glTexImage2D
, it is possible to
update portions of the image. This ability would be useful if you wanted
to update just a subregion of an image. The function to load a portion of a
2D texture image is
glTexSubImage2D
.
void
glTexSubImage2D
(GLenum
target
, GLint
level
,
GLint
xoffset
, GLint
yoffset
,
GLsizei
width
, GLsizei
height
,
GLenum
format
, GLenum
type
,
const void*
pixels
)
target
specifies the texture target, either
GL_TEXTURE_2D
or one of
the cubemap face targets
(
GL_TEXTURE_CUBE_MAP_POSITIVE_X
,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X
, and so on)
level
specifies which mip level to update
xoffset
the
x
index of the texel to start updating from
yoffset
the
y
index of the texel to start updating from
width
the width of the subregion of the image to update
the height of the subregion of the image to update
height
the format of the incoming texture data; can be
GL_RED
,
GL_RED_INTEGER
,
GL_RG
,
GL_RG_INTEGER
,
GL_GL_RGB
,
GL_RGB_INTEGER
,
GL_RGBA
,
GL_RGBA_INTEGER
,
GL_DEPTH_COMPONENT
,
GL_DEPTH_STENCIL
,
GL_LUMINANCE_ALPHA
,
GL_LUMINANCE
, or
GL_ALPHA
format
the type of the incoming pixel data; can be
GL_UNSIGNED_BYTE
,
GL_BYTE
,
GL_UNSIGNED_SHORT
,
GL_SHORT
,
GL_UNSIGNED_INT
,
GL_INT
,
GL_HALF_FLOAT
,
GL_FLOAT
,
GL_UNSIGNED_SHORT_5_6_5
,
GL_UNSIGNED_SHORT_4_4_4_4
,
GL_UNSIGNED_SHORT_5_5_5_l
,
GL_UNSIGNED_INT_2_10_10_10_REV
,
GL_UNSIGNED_INT_10F_11F_11F_REV
,
GL_UNSIGNED_INT_5_9_9_9_REV
,
GL_UNSIGNED_INT_24_8
, or
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
type
contains the actual pixel data for the subregion of the image
pixels