Buffer#
- class arcade.gl.Buffer(ctx: Context, data: ByteString | memoryview | array | None = None, reserve: int = 0, usage: str = 'static')[source]#
Bases:
object
OpenGL buffer object. Buffers store byte data and upload it to graphics memory so shader programs can process the data. They are used for storage of vertex data, element data (vertex indexing), uniform block data etc.
The
data
parameter can be anything that implements the Buffer Protocol.This includes
bytes
,bytearray
,array.array
, and more. You may need to use typing workarounds for non-builtin types. See Writing Raw Bytes to GL Buffers & Textures for more information.Warning
Buffer objects should be created using
arcade.gl.Context.buffer()
- Parameters:
ctx (Context) – The context this buffer belongs to
data (BufferProtocol) – The data this buffer should contain. It can be a
bytes
instance or any object supporting the buffer protocol.reserve (int) – Create a buffer of a specific byte size
usage (str) – A hit of this buffer is
static
ordynamic
(can mostly be ignored)
- delete()[source]#
Destroy the underlying OpenGL resource. Don’t use this unless you know exactly what you are doing.
- static delete_glo(ctx: Context, glo: c_uint)[source]#
Release/delete open gl buffer. This is automatically called when the object is garbage collected.
- write(data: ByteString | memoryview | array, offset: int = 0)[source]#
Write byte data to the buffer from a buffer protocol object.
The
data
value can be anything that implements the Buffer Protocol.This includes
bytes
,bytearray
,array.array
, and more. You may need to use typing workarounds for non-builtin types. See Writing Raw Bytes to GL Buffers & Textures for more information.If the supplied data is larger than the buffer, it will be truncated to fit. If the supplied data is smaller than the buffer, the remaining bytes will be left unchanged.
- copy_from_buffer(source: Buffer, size=-1, offset=0, source_offset=0)[source]#
Copy data into this buffer from another buffer
- orphan(size: int = -1, double: bool = False)[source]#
Re-allocate the entire buffer memory. This can be used to resize a buffer or for re-specification (orphan the buffer to avoid blocking).
If the current buffer is busy in rendering operations it will be deallocated by OpenGL when completed.