Generic GPU buffer.
A generic buffer is an interface used to upload data to a GPU array buffer
(ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER). It keeps track of
buffer size but does not have any CPU storage. You can consider it as
The set_data is a deferred operation: you can call it even if an OpenGL
context is not available. The update function is responsible to upload
pending data to GPU memory and requires an active GL context.
The Buffer class only deals with data in terms of bytes; it is not
aware of data type or element size.
Buffer byte size.
Buffer size in bytes
Resize this buffer (deferred operation).
New buffer size in bytes.
Set data in the buffer (deferred operation).
This completely resets the size and contents of the buffer.
Data to be uploaded
Since the operation is deferred, data may change before
data is actually uploaded to GPU memory.
Asking explicitly for a copy will prevent this behavior.
Set a sub-region of the buffer (deferred operation).
Offset in buffer where to start copying data (in bytes)
GPU data buffer that is aware of data type and elements size
GLSL declaration strings required for a variable to hold this data.
The total number of bytes required to store the array data
Buffer offset (in bytes) relative to base
Resize the buffer (in-place, deferred operation)
New buffer size in bytes
This clears any pending operations.
Set data (deferred operation)
Offset in buffer where to start copying data (i.e. index of
Additional keyword arguments.
Number of elements in the buffer
Stride of data in memory
View on a sub-region of a DataBuffer.
The buffer accessed by this view.
The index into the base buffer that defines a sub-region of the buffer
to view. String arguments select a single field from multi-field
dtypes, and other allowed types select a subset of rows.
It is generally not necessary to instantiate this class manually; use
Buffer base if this buffer is a view on another buffer.
The glir queue for this object.
The id of this GL object used to reference the GL object
in GLIR. id’s are unique within a process.
Buffer for index data
Buffer for vertex attribute data
Buffer data (optional)