Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.gl.Mesh class

Mesh

Buffer ownership and reference counting

Unlike in C++, where a GL::Buffer is either std::move()d into the mesh or referenced externally (with the user being responsible for its lifetime), the gl.Mesh object keeps references to all buffers added to it.

Methods

def add_vertex_buffer(self, buffer: Buffer, offset: int, stride: int, attribute: Attribute) -> None
Add vertex buffer
def set_index_buffer(self, buffer: Buffer, offset: int, type: MeshIndexType) -> None
Set index buffer
def set_index_buffer(self, buffer: Buffer, offset: int, type: magnum.MeshIndexType) -> None
Set index buffer

Special methods

def __init__(self, primitive: MeshPrimitive = MeshPrimitive.TRIANGLES) -> None
Constructor
def __init__(self, primitive: magnum.MeshPrimitive) -> None
Constructor

Properties

buffers: list[object] get
Buffer objects referenced by the mesh
count: int get set
Vertex/index count
id: int get
OpenGL vertex array ID
index_type: MeshIndexType get
Index type
is_indexed: bool get
Whether the mesh is indexed
primitive: MeshPrimitive get set
Primitive type

Property documentation

magnum.gl.Mesh.primitive: MeshPrimitive get set

Primitive type

While querying this property will always give back a gl.MeshPrimitive, this property can be set using either magnum.MeshPrimitive or gl.MeshPrimitive, similarly to how the overloaded GL::Mesh::setPrimitive() works.