Buffer (base)
- class arcade.gl.buffer.Buffer(ctx: Context)[source]
Bases:
ABCOpenGL 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
dataparameter 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 – The context this buffer belongs to
data – The data this buffer should contain. It can be a
bytesinstance or any object supporting the buffer protocol.reserve – Create a buffer of a specific byte size
usage – A hit of this buffer is
staticordynamic(can mostly be ignored)
- abstract delete() None[source]
Destroy the underlying native buffer resource.
Warning
Don’t use this unless you know exactly what you are doing.
- abstract read(size: int = -1, offset: int = 0) bytes[source]
Read data from the buffer.
- Parameters:
size – The bytes to read. -1 means the entire buffer (default)
offset – Byte read offset
- abstract write(data: ByteString | memoryview | array | Array, offset: int = 0)[source]
Write byte data to the buffer from a buffer protocol object.
The
datavalue 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.
- Parameters:
data – The byte data to write. This can be bytes or any object supporting the buffer protocol.
offset – The byte offset
- abstract copy_from_buffer(source: Buffer, size=-1, offset=0, source_offset=0)[source]
Copy data into this buffer from another buffer.
- Parameters:
source – The buffer to copy from
size – The amount of bytes to copy
offset – The byte offset to write the data in this buffer
source_offset – The byte offset to read from the source buffer
- abstract 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.
- Parameters:
size – New size of buffer. -1 will retain the current size. Takes precedence over
doubleparameter if specified.double – Is passed in with True the buffer size will be doubled from its current size.
- abstract bind_to_uniform_block(binding: int = 0, offset: int = 0, size: int = -1)[source]
Bind this buffer to a uniform block location. In most cases it will be sufficient to only provide a binding location.
- Parameters:
binding – The binding location
offset – Byte offset
size – Size of the buffer to bind.