vispy.gloo.buffer module#
- class vispy.gloo.buffer.Buffer(data=None, nbytes=None)#
Bases:
GLObject
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 write-only.
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.
- Parameters:
- datandarray | None
Buffer data.
- nbytesint | None
Buffer byte size.
- property nbytes#
Buffer size in bytes
- resize_bytes(size)#
Resize this buffer (deferred operation).
- Parameters:
- sizeint
New buffer size in bytes.
- set_data(data, copy=False)#
Set data in the buffer (deferred operation).
This completely resets the size and contents of the buffer.
- Parameters:
- datandarray
Data to be uploaded
- copy: bool
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_subdata(data, offset=0, copy=False)#
Set a sub-region of the buffer (deferred operation).
- Parameters:
- datandarray
Data to be uploaded
- offset: int
Offset in buffer where to start copying data (in bytes)
- copy: bool
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.
- class vispy.gloo.buffer.DataBuffer(data=None)#
Bases:
Buffer
GPU data buffer that is aware of data type and elements size
- Parameters:
- datandarray | None
Buffer data.
- property dtype#
Buffer dtype
- property glsl_type#
GLSL declaration strings required for a variable to hold this data.
- property itemsize#
The total number of bytes required to store the array data
- property offset#
Buffer offset (in bytes) relative to base
- resize_bytes(size)#
Resize the buffer (in-place, deferred operation)
- Parameters:
- sizeinteger
New buffer size in bytes
Notes
This clears any pending operations.
- set_data(data, copy=False, **kwargs)#
Set data (deferred operation)
- Parameters:
- datandarray
Data to be uploaded
- copy: bool
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.
- **kwargsdict
Additional arguments.
- set_subdata(data, offset=0, copy=False, **kwargs)#
Set a sub-region of the buffer (deferred operation).
- Parameters:
- datandarray
Data to be uploaded
- offset: int
Offset in buffer where to start copying data (i.e. index of starting element).
- copy: bool
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.
- **kwargsdict
Additional keyword arguments.
- property size#
Number of elements in the buffer
- property stride#
Stride of data in memory
- class vispy.gloo.buffer.DataBufferView(base, key)#
Bases:
DataBuffer
View on a sub-region of a DataBuffer.
- Parameters:
- baseDataBuffer
The buffer accessed by this view.
- keystr, int, slice, or Ellpsis
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.
Notes
It is generally not necessary to instantiate this class manually; use
base_buffer[key]
instead.- property base#
Buffer base if this buffer is a view on another buffer.
- property glir#
The glir queue for this object.
- property id#
The id of this GL object used to reference the GL object in GLIR. id’s are unique within a process.
- property offset#
Buffer offset (in bytes) relative to base
- resize_bytes(size)#
Resize the buffer (in-place, deferred operation)
- Parameters:
- sizeinteger
New buffer size in bytes
Notes
This clears any pending operations.
- set_data(data, copy=False, **kwargs)#
Set data (deferred operation)
- Parameters:
- datandarray
Data to be uploaded
- copy: bool
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.
- **kwargsdict
Additional arguments.
- set_subdata(data, offset=0, copy=False, **kwargs)#
Set a sub-region of the buffer (deferred operation).
- Parameters:
- datandarray
Data to be uploaded
- offset: int
Offset in buffer where to start copying data (i.e. index of starting element).
- copy: bool
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.
- **kwargsdict
Additional keyword arguments.
- class vispy.gloo.buffer.IndexBuffer(data=None)#
Bases:
DataBuffer
Buffer for index data
- Parameters:
- datandarray | None
Buffer data.
- class vispy.gloo.buffer.VertexBuffer(data=None, divisor=None)#
Bases:
DataBuffer
Buffer for vertex attribute data
- Parameters:
- datandarray
Buffer data (optional)
- property divisor#