picogl.renderer.draw_spec

CPU-side draw layout and draw specifications for MeshData.

These types describe what portion of a mesh to draw. They contain no OpenGL objects. A VAO/VBG consumes a MeshDrawSpec to issue glDraw*.

Attributes

_UINT32_BYTES

Classes

MeshDrawInfo

Persistent topology for a mesh (how items map onto vertices/indices).

MeshDrawSpec

One GL-free draw: mode, element/vertex count, and EBO byte offset.

Functions

infer_draw_info(*, has_indices[, index_count]) → MeshDrawInfo

Infer a conservative layout when the mesh has no explicit draw_info.

compute_draw_spec(info, *[, index_count, ...]) → MeshDrawSpec

Map a logical item range onto a MeshDrawSpec.

execute_draw_spec(vao, spec) → None

Issue VertexArrayObject.draw from a resolved MeshDrawSpec.

Module Contents

picogl.renderer.draw_spec._UINT32_BYTES[source]
class picogl.renderer.draw_spec.MeshDrawInfo[source]

Persistent topology for a mesh (how items map onto vertices/indices).

Parameters:
  • mode – Primitive mode (POINTS, LINES, TRIANGLES, …).

  • indexed – Whether drawing uses an element buffer.

  • elements_per_item – Indices per logical item (atom, bond, …), or None when the mesh is not instanced.

  • vertices_per_item – Vertices per logical item, used when expanding per-item attributes such as colors.

mode: picogl.backend.gl.enums.GLDrawMode[source]
indexed: bool = False[source]
elements_per_item: int | None = None[source]
vertices_per_item: int | None = None[source]
class picogl.renderer.draw_spec.MeshDrawSpec[source]

One GL-free draw: mode, element/vertex count, and EBO byte offset.

Parameters:
  • mode – Primitive mode for glDrawArrays / glDrawElements.

  • count – Vertex count (non-indexed) or index count (indexed).

  • first – First vertex for non-indexed draws.

  • pointer – Byte offset into the element buffer for indexed draws.

mode: picogl.backend.gl.enums.GLDrawMode[source]
count: int[source]
first: int = 0[source]
pointer: int = 0[source]
to_draw_spec() → picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec[source]

Convert to the GPU DrawSpec.

picogl.renderer.draw_spec.infer_draw_info(*, has_indices: bool, index_count: int = 0) → MeshDrawInfo[source]

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 MeshDrawInfo explicitly (LINES).

picogl.renderer.draw_spec.compute_draw_spec(info: MeshDrawInfo, *, index_count: int = 0, vertex_count: int = 0, first_item: int = 0, item_count: int | None = None) → MeshDrawSpec[source]

Map a logical item range onto a MeshDrawSpec.

Parameters:
  • info – Mesh topology.

  • index_count – Length of the element buffer (0 if none).

  • vertex_count – Number of vertices.

  • first_item – First logical item (atom, bond, …).

  • item_count – Number of items; None draws the remainder.

Returns:

Draw specification with counts clamped to the buffer.

picogl.renderer.draw_spec.execute_draw_spec(vao: Any, spec: MeshDrawSpec) → None[source]

Issue VertexArrayObject.draw from a resolved MeshDrawSpec.

Parameters:
  • vao – GPU vertex array that implements draw(...).

  • spec – Count/mode/offset for one glDraw* call.