BufferDescription#

class arcade.gl.BufferDescription(buffer: arcade.gl.buffer.Buffer, formats: str, attributes: Iterable[str], normalized: Optional[Iterable[str]] = None, instanced: bool = False)[source]#

Bases: object

Buffer Object description used with arcade.gl.Geometry.

This class provides a Buffer object with a description of its content, allowing the a Geometry object to correctly map shader attributes to a program/shader.

The formats is a string providing the number and type of each attribute. Currently we only support f (float), i (integer) and B (unsigned byte).

normalized enumerates the attributes which must have their values normalized. This is useful for instance for colors attributes given as unsigned byte and normalized to floats with values between 0.0 and 1.0.

instanced allows this buffer to be used as instanced buffer. Each value will be used once for the whole geometry. The geometry will be repeated a number of times equal to the number of items in the Buffer.

Example:

# Describe my_buffer
# It contains two floating point numbers being a 2d position
# and two floating point numbers being texture coordinates.
# We expect the shader using this buffer to have an in_pos and in_uv attribute (exact name)
BufferDescription(
    my_buffer,
    '2f 2f',
    ['in_pos', 'in_uv'],
)
Parameters
  • buffer (Buffer) – The buffer to describe

  • formats (str) – The format of each attribute

  • attributes (list) – List of attributes names (strings)

  • normalized (list) – list of attribute names that should be normalized

  • instanced (bool) – True if this is per instance data

buffer: arcade.gl.buffer.Buffer#

The Buffer this description object describes

attributes#

List of string attributes

normalized#

List of normalized attributes

instanced: bool#

Instanced flag (bool)

formats: List[arcade.gl.types.AttribFormat]#

Formats of each attribute

stride: int#

The byte stride of the buffer

num_vertices: int#

Number of vertices in the buffer