Updating a Subregion of a Buffer
In many cases, avoiding fragmentation means placing multiple objects into the same shared buffer, or reusing a buffer by deleting or overwriting an older object with a newer one. OpenGL ES provides a method for updating an arbitrary section of allocated VBOs, textures, and surfaces:
glBufferSubData(enum target, intptr offset, sizeiptr size,
const void *data, enum usage)
glTexSubImage2D(enum target, int level, int xoffset, int yoffset,
sizei width, sizei height, enum format, enum type, const void *pixels)
glCopyTexSubImage2D(enum target, int level, int xoffset, int yoffset,
int x, int y, sizei width, sizei height)
glScissor(int left, int bottom, sizei width, sizei height);
glViewport(int x, int y, sizei w, sizei h)
The glTexSubImage2D
and glCopyTexSubImage2D
function update a subregion of the target texture image. In the first case, the source comes from an application buffer; in the second, from a rendering surface.
The glScissor
and glViewport
functions limit rendering to a subregion of a rendering surface. The first specifies the region of the buffer that the glClear
function will affect; the second updates the transforms to limit rendered OpenGL ES primitives to the specified subregion.