Function familiesfamily
glTexSubImage*
Overwrite part of an existing texture; the number is the texture's dimensions, Texture instead of Tex means DSA.
Signature
void glTexSubImage{1D|2D|3D}(GLenum target, GLint level, offsets…, sizes…, GLenum format, GLenum type, const void *pixels); void glTextureSubImage{1D|2D|3D}(GLuint texture, …); void glCompressedTextureSubImage{1D|2D|3D}(GLuint texture, …, GLsizei imageSize, const void *data);
How it works
All of them write pixels into storage that already exists, without reallocating. They differ in three ways that can be read from the name: 1D / 2D / 3D gives the number of offsets and sizes (a texture array counts as 3D, the layer being the third coordinate); glTexture… takes the texture ID instead of a bound target; Compressed… takes ready-made compressed blocks with their byte size instead of format and type.
Reading the name
- 1D / 2D / 3D
- Dimensions: x; x, y; or x, y, z (or layer).
- Tex / Texture
- Bound target (classic) / texture ID (DSA, GL 4.5).
- Compressed
- Pre-compressed blocks (BC7, ASTC…).
Functions in this family
Example
example.cpp
1glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
2glTextureSubImage2D(tex, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // same, by ID