picogl.renderer.glmesh

Classes

GLMesh

GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh.

GLMeshold

GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh.

Module Contents

class picogl.renderer.glmesh.GLMesh(vertices: numpy.ndarray, faces: numpy.ndarray, colors: numpy.ndarray | None = None, normals: numpy.ndarray | None = None, uvs: numpy.ndarray | None = None, use_indices: bool = True)[source]

GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. It does not know anything about shaders or matrices.

vertices[source]
indices[source]
use_indices = True[source]
colors[source]
normals[source]
uvs[source]
vao: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None = None[source]
index_count: int = 0[source]
_expanded_vertices = None[source]
_expanded_colors = None[source]
_expanded_normals = None[source]
_expanded_uvs = None[source]
_expand_to_non_indexed() None[source]

Expand the mesh so that every triangle has its own copy of vertices/colors/normals/uvs. This converts indexed data (shared vertices) into a per-triangle vertex list suitable for glDrawArrays. The API remains the same; just keep the EBO empty and set index_count accordingly.

classmethod from_mesh_data(mesh: MeshData) GLMesh[source]

Construct a GLMesh from a MeshData container.

Parameters:

mesh (MeshData) – Must have .vbo (Nx3), .ebo (Mx1), optional .cbo (Nx3), .nbo (Nx3), uvs (Nx2)

Returns:

Ready-to-upload mesh (GPU buffers are allocated only when upload() is called).

Return type:

GLMesh

upload() None[source]

Allocate & fill GPU buffers.

bind()[source]
unbind()[source]
delete()[source]

Free GPU resources.

__enter__()[source]
__exit__(exc_type, exc, tb)[source]
draw() None[source]

Draw the mesh.

class picogl.renderer.glmesh.GLMeshold(vertices: numpy.ndarray, faces: numpy.ndarray, colors: numpy.ndarray | None = None, normals: numpy.ndarray | None = None, uvs: numpy.ndarray | None = None)[source]

GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. It does not know anything about shaders or matrices.

vertices[source]
indices[source]
colors[source]
normals[source]
uvs[source]
vao: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None = None[source]
index_count: int = 0[source]
classmethod from_mesh_data(mesh: MeshData) GLMesh[source]

Construct a GLMesh from a MeshData container.

Parameters:

mesh (MeshData) – Must have .vbo (Nx3), .ebo (Mx1), optional .cbo (Nx3), .nbo (Nx3), uvs (Nx2)

Returns:

Ready-to-upload mesh (GPU buffers are allocated only when upload() is called).

Return type:

GLMesh

upload() None[source]

Allocate & fill GPU buffers.

bind()[source]
unbind()[source]
delete()[source]

Free GPU resources.

__enter__()[source]
__exit__(exc_type, exc, tb)[source]
draw() None[source]

Draw the mesh.