picogl.renderer
Submodules
Classes
Base Renderer Class |
|
Stores dynamic OpenGL-related state (VAO, shader, texture handles, etc.). |
|
GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. |
|
Holds OpenGL-related state objects for rendering. |
Package Contents
- class picogl.renderer.RendererBase(parent: object = None)[source]
Bases:
picogl.renderer.abstract.AbstractRendererBase Renderer Class
- line_width = 2.0
- show_model = False
- parent = None
- _initialized = False
- property dispatch_list
- render(mvp_matrix: numpy.ndarray | None = None) None[source]
render dispatcher
- Returns:
None
- class picogl.renderer.GLContext[source]
Stores dynamic OpenGL-related state (VAO, shader, texture handles, etc.). Does NOT store raw vertex data.
- vertex_array: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None = None
- shader: picogl.backend.modern.core.shader.program.ShaderProgram | None = None
- mvp_matrix: numpy.ndarray
- model_matrix: numpy.ndarray
- view: numpy.ndarray
- eye_np: numpy.ndarray
- class picogl.renderer.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
- indices
- use_indices = True
- colors
- normals
- uvs
- _expanded_vertices = None
- _expanded_colors = None
- _expanded_normals = None
- _expanded_uvs = None
- _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.
- class picogl.renderer.MeshData(vbo: numpy.ndarray = None, nbo: numpy.ndarray = None, uvs: numpy.ndarray = None, cbo: numpy.ndarray = None, ebo: numpy.ndarray = None)[source]
Holds OpenGL-related state objects for rendering.
- vbo = None
- nbo = None
- uvs = None
- cbo = None
- ebo = None
- vertex_count
- classmethod _to_float32_flat(arr, name: str, required: bool = False) numpy.ndarray[source]
- classmethod _to_float32_flat_or_none(arr, name: str) numpy.ndarray[source]
- classmethod _to_int32_flat(arr, name: str, required: bool = False) numpy.ndarray[source]
- classmethod _default_colors_for_vertices(vertex_count: int) numpy.ndarray[source]
- classmethod _default_normals_for_vertices(vertex_count: int) numpy.ndarray[source]
- classmethod from_raw(vertices: numpy.ndarray | list[float], normals: numpy.ndarray | list[float] | None = None, uvs: numpy.ndarray | list[float] | None = None, colors: numpy.ndarray | list[float] | None = None, indices: numpy.ndarray | list[float] | None = None, color_per_vertex: numpy.ndarray | list[float] | None = None)[source]
Build a MeshData from raw/python inputs.
- Parameters:
vertices – np.ndarray required, list/array of x,y,z triplets
normals – np.ndarray optional, list/array of x,y,z triplets
uvs – np.ndarray optional, list/array of u,v pairs
indices – np.ndarray optional int indices
colors – np.ndarray optional per-vertex colors (flat float32 array)
color_per_vertex – np.ndarray if provided and colors is None, generate per-vertex colors
- draw(color: tuple = None, line_width: float = 1.0, mode: int = GL.GL_TRIANGLES, fill: bool = False, alpha: float = 1.0)[source]
Draw the mesh with optional colour override and transparency.
- Parameters:
color – Optional colour override. If None and vertex colors exist, uses vertex colors.
line_width – Line width for wireframe mode
mode – OpenGL drawing mode
fill – Whether to fill or use wireframe
alpha – Transparency value from 0.0 (opaque) to 1.0 (fully transparent)