picogl.renderer.glmesh ====================== .. py:module:: picogl.renderer.glmesh Classes ------- .. autoapisummary:: picogl.renderer.glmesh.GLMesh picogl.renderer.glmesh.GLMeshold Module Contents --------------- .. py:class:: GLMesh(vertices: numpy.ndarray, faces: numpy.ndarray, colors: Optional[numpy.ndarray] = None, normals: Optional[numpy.ndarray] = None, uvs: Optional[numpy.ndarray] = None, use_indices: bool = True) GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. It does not know anything about shaders or matrices. .. py:attribute:: vertices .. py:attribute:: indices .. py:attribute:: use_indices :value: True .. py:attribute:: colors .. py:attribute:: normals .. py:attribute:: uvs .. py:attribute:: vao :type: Optional[picogl.backend.modern.core.vertex.array.object.VertexArrayObject] :value: None .. py:attribute:: index_count :type: int :value: 0 .. py:attribute:: _expanded_vertices :value: None .. py:attribute:: _expanded_colors :value: None .. py:attribute:: _expanded_normals :value: None .. py:attribute:: _expanded_uvs :value: None .. py:method:: _expand_to_non_indexed() -> None 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. .. py:method:: from_mesh_data(mesh: MeshData) -> GLMesh :classmethod: Construct a GLMesh from a MeshData container. :param mesh: Must have .vbo (Nx3), .ebo (Mx1), optional .cbo (Nx3), .nbo (Nx3), uvs (Nx2) :type mesh: MeshData :returns: Ready-to-upload mesh (GPU buffers are allocated only when `upload()` is called). :rtype: GLMesh .. py:method:: upload() -> None Allocate & fill GPU buffers. .. py:method:: bind() .. py:method:: unbind() .. py:method:: delete() Free GPU resources. .. py:method:: __enter__() .. py:method:: __exit__(exc_type, exc, tb) .. py:method:: draw() -> None Draw the mesh. .. py:class:: GLMeshold(vertices: numpy.ndarray, faces: numpy.ndarray, colors: Optional[numpy.ndarray] = None, normals: Optional[numpy.ndarray] = None, uvs: Optional[numpy.ndarray] = None) GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. It does not know anything about shaders or matrices. .. py:attribute:: vertices .. py:attribute:: indices .. py:attribute:: colors .. py:attribute:: normals .. py:attribute:: uvs .. py:attribute:: vao :type: Optional[picogl.backend.modern.core.vertex.array.object.VertexArrayObject] :value: None .. py:attribute:: index_count :type: int :value: 0 .. py:method:: from_mesh_data(mesh: MeshData) -> GLMesh :classmethod: Construct a GLMesh from a MeshData container. :param mesh: Must have .vbo (Nx3), .ebo (Mx1), optional .cbo (Nx3), .nbo (Nx3), uvs (Nx2) :type mesh: MeshData :returns: Ready-to-upload mesh (GPU buffers are allocated only when `upload()` is called). :rtype: GLMesh .. py:method:: upload() -> None Allocate & fill GPU buffers. .. py:method:: bind() .. py:method:: unbind() .. py:method:: delete() Free GPU resources. .. py:method:: __enter__() .. py:method:: __exit__(exc_type, exc, tb) .. py:method:: draw() -> None Draw the mesh.