picogl.renderer.glmesh
A module for GPU-resident indexed and non-indexed geometry.
This module defines the GLMesh class, which represents a 3D mesh stored on the GPU. It provides mechanisms for defining a mesh’s vertices, faces, colors, normals, UVs, and vertex layout, along with functionality for uploading these attributes to GPU buffers and expanding indexed meshes into per-triangle vertex lists if needed.
Classes
GPU-resident geometry: owns VAO/VBO and optional EBO/CBO/NBO buffers. |
Functions
|
expand_triangle_vertices_and_colors |
|
empty_triangle_vertices |
Module Contents
- picogl.renderer.glmesh.expand_triangle_vertices_and_colors(a: int, b: int, c: int, colors: numpy.ndarray, expanded_colors: numpy.ndarray, expanded_vertices: numpy.ndarray, triangle_index: int, vertices: numpy.ndarray) None[source]
expand_triangle_vertices_and_colors
- picogl.renderer.glmesh.empty_triangle_vertices(triangle_count: int, components: int = 3) numpy.ndarray[source]
empty_triangle_vertices
- class picogl.renderer.glmesh.GLMesh(vertices: numpy.ndarray, faces: numpy.ndarray | None = None, colors: numpy.ndarray | None = None, normals: numpy.ndarray | None = None, uvs: numpy.ndarray | None = None, use_indices: bool = True, *, shader_type: Literal[picogl.shaders.type.ShaderType.ISOSURFACE, picogl.shaders.type.ShaderType.RIBBONS, picogl.shaders.type.ShaderType.TEXTURES] = ShaderType.ISOSURFACE, registry_label: str | None = None)[source]
Bases:
picogl.gpu.buffers.mesh_owner.MeshDataOwnerGPU-resident geometry: owns VAO/VBO and optional EBO/CBO/NBO buffers. It does not know anything about shaders or matrices.
- mesh: picogl.renderer.meshdata.MeshData | None = None[source]
- _get_buffer_data(vbo_type: picogl.gpu.buffers.vertex.vbo.vbo_class.VBOType) numpy.ndarray | None[source]
get_buffer_data(vbo_type) -> np.ndarray
- _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: picogl.renderer.meshdata.MeshData, *, vertex_layout: picogl.shaders.type.ShaderType.ISOSURFACE | picogl.shaders.type.ShaderType.RIBBONS | picogl.shaders.type.ShaderType.TEXTURES = ShaderType.ISOSURFACE, registry_label: str | None = None) GLMesh[source]
Construct a GLMesh from a MeshData container.
- Parameters:
mesh (MeshData) – Must have vertices (Nx3). Indices are optional; geometry without indices is rendered directly with
glDrawArrays.vertex_layout –
surface→ attr order pos, color, normal (surface_with_lighting/ mesh).ribbon→ pos, normal, color (ribbons).
- Returns:
Ready-to-upload mesh (GPU buffers are allocated only when upload() is called).
- Return type:
- update_colors(colors: numpy.ndarray)[source]
- draw(mode: picogl.backend.gl.enums.GLDrawMode | None = None) None[source]
Draw via attached
MeshDatawhen its CPU arrays are intact.Callers that copy arrays into this object then drop the MeshData CPU buffers (
MeshData.delete) fall back toexecute_draw_spec()using the uploaded VAO andindex_count.modeoverrides the meshMeshDrawSpecwhen given (gizmo line draws).