picogl.renderer.draw_spec ========================= .. py:module:: picogl.renderer.draw_spec .. autoapi-nested-parse:: CPU-side draw layout and draw specifications for :class:`MeshData`. These types describe *what portion of a mesh to draw*. They contain no OpenGL objects. A VAO/VBG consumes a :class:`MeshDrawSpec` to issue ``glDraw*``. Attributes ---------- .. autoapisummary:: picogl.renderer.draw_spec._UINT32_BYTES Classes ------- .. autoapisummary:: picogl.renderer.draw_spec.MeshDrawInfo picogl.renderer.draw_spec.MeshDrawSpec Functions --------- .. autoapisummary:: picogl.renderer.draw_spec.infer_draw_info picogl.renderer.draw_spec.compute_draw_spec picogl.renderer.draw_spec.execute_draw_spec Module Contents --------------- .. py:data:: _UINT32_BYTES .. py:class:: MeshDrawInfo Persistent topology for a mesh (how items map onto vertices/indices). :param mode: Primitive mode (``POINTS``, ``LINES``, ``TRIANGLES``, …). :param indexed: Whether drawing uses an element buffer. :param elements_per_item: Indices per logical item (atom, bond, …), or ``None`` when the mesh is not instanced. :param vertices_per_item: Vertices per logical item, used when expanding per-item attributes such as colors. .. py:attribute:: mode :type: picogl.backend.gl.enums.GLDrawMode .. py:attribute:: indexed :type: bool :value: False .. py:attribute:: elements_per_item :type: int | None :value: None .. py:attribute:: vertices_per_item :type: int | None :value: None .. py:class:: MeshDrawSpec One GL-free draw: mode, element/vertex count, and EBO byte offset. :param mode: Primitive mode for ``glDrawArrays`` / ``glDrawElements``. :param count: Vertex count (non-indexed) or index count (indexed). :param first: First vertex for non-indexed draws. :param pointer: Byte offset into the element buffer for indexed draws. .. py:attribute:: mode :type: picogl.backend.gl.enums.GLDrawMode .. py:attribute:: count :type: int .. py:attribute:: first :type: int :value: 0 .. py:attribute:: pointer :type: int :value: 0 .. py:method:: to_draw_spec() -> picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec Convert to the GPU :class:`~picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec`. .. py:function:: infer_draw_info(*, has_indices: bool, index_count: int = 0) -> MeshDrawInfo Infer a conservative layout when the mesh has no explicit ``draw_info``. Indexed meshes default to triangles; otherwise points. Line-stick bond meshes must set :class:`MeshDrawInfo` explicitly (``LINES``). .. py:function:: compute_draw_spec(info: MeshDrawInfo, *, index_count: int = 0, vertex_count: int = 0, first_item: int = 0, item_count: int | None = None) -> MeshDrawSpec Map a logical item range onto a :class:`MeshDrawSpec`. :param info: Mesh topology. :param index_count: Length of the element buffer (0 if none). :param vertex_count: Number of vertices. :param first_item: First logical item (atom, bond, …). :param item_count: Number of items; ``None`` draws the remainder. :return: Draw specification with counts clamped to the buffer. .. py:function:: execute_draw_spec(vao: Any, spec: MeshDrawSpec) -> None Issue ``VertexArrayObject.draw`` from a resolved :class:`MeshDrawSpec`. :param vao: GPU vertex array that implements ``draw(...)``. :param spec: Count/mode/offset for one ``glDraw*`` call.