Light | Dark

glCopyBufferSubData

Name

glCopyBufferSubData — copy part of the data store of a buffer object to the data store of another buffer object

C Specification

void glCopyBufferSubData( GLenum readtarget,
  GLenum writetarget,
  GLintptr readoffset,
  GLintptr writeoffset,
  GLsizeiptr size);
 

Parameters

readtarget

Specifies the target from whose data store data should be read.

writetarget

Specifies the target to whose data store data should be written.

readoffset

Specifies the offset, in basic machine units, within the data store of readtarget from which data should be read.

writeoffset

Specifies the offset, in basic machine units, within the data store of writetarget to which data should be written.

size

Specifies the size, in basic machine units, of the data to be copied from readtarget to writetarget.

Description

glCopyBufferSubData copies part of the data store attached to readtarget to the data store attached to writetarget. The number of basic machine units indicated by size is copied from the source, at offset readoffset to the destination at writeoffset, also in basic machine units.

readTarget and writeTarget specify the targets to which the source and destination buffer objects are bound, and must each be one of the buffer binding targets in the following table:

Buffer Binding Target Purpose
GL_ARRAY_BUFFER Vertex attributes
GL_ATOMIC_COUNTER_BUFFER Atomic counter storage
GL_COPY_READ_BUFFER Buffer copy source
GL_COPY_WRITE_BUFFER Buffer copy destination
GL_DISPATCH_INDIRECT_BUFFER Indirect compute dispatch commands
GL_DRAW_INDIRECT_BUFFER Indirect command arguments
GL_ELEMENT_ARRAY_BUFFER Vertex array indices
GL_PIXEL_PACK_BUFFER Pixel read target
GL_PIXEL_UNPACK_BUFFER Texture data source
GL_SHADER_STORAGE_BUFFER Read-write storage for shaders
GL_TEXTURE_BUFFER Texture data buffer
GL_TRANSFORM_FEEDBACK_BUFFER Transform feedback buffer
GL_UNIFORM_BUFFER Uniform block storage

Any of these targets may be used, but the targets GL_COPY_READ_BUFFER and GL_COPY_WRITE_BUFFER are provided specifically to allow copies between buffers without disturbing other GL state.

readoffset, writeoffset and size must all be greater than or equal to zero. Furthermore, readoffset + size must not exceeed the size of the buffer object bound to readtarget, and writeoffset + size must not exceeed the size of the buffer bound to writetarget. If the same buffer object is bound to both readtarget and writetarget, then the ranges specified by readoffset, writeoffset and size must not overlap.

Errors

GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative, if readoffset + size exceeds the size of the buffer object bound to readtarget or if writeoffset + size exceeds the size of the buffer object bound to writetarget.

GL_INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.

GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.

GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.

API Version Support

OpenGL ES API Version
Function Name 2.0 3.0 3.1 3.2
glCopyBufferSubData -
Think you can improve this page? Edit this page on GitHub.