BufferDescription#

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

基类:object

缓冲区对象描述与一起使用 arcade.gl.Geometry

此类为Buffer对象提供其内容的说明,从而允许 Geometry 对象将着色器属性正确映射到程序/着色器。

格式是提供每个属性的编号和类型的字符串。目前我们只支持f(浮点数)、i(整数)和B(无符号字节)。

normalized 枚举必须规范化其值的属性。例如,对于以无符号字节形式给出并规格化为值介于0.0和1.0之间的浮点数的颜色属性,这很有用。

instanced 允许将此缓冲区用作实例化缓冲区。每个值将在整个几何体中使用一次。几何体将重复与缓冲区中的项数相等的次数。

示例::

# 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'],
)
参数
  • buffer (Buffer) -- 要描述的缓冲区

  • formats (str) -- 每个属性的格式

  • attributes (list) -- 属性名称列表(字符串)

  • normalized (list) -- 应规范化的属性名称列表

  • instanced (bool) -- True 如果这是每实例数据

buffer#

这个 Buffer 此描述对象描述

attributes#

字符串属性列表

normalized#

归一化属性列表

instanced#

实例化标志(Bool)

formats#

每个属性的格式

stride#

缓冲区的字节跨度

num_vertices#

缓冲区中的顶点数