Skip to content

mesh

mesh

Meshes: a list of vertices you control, drawn as triangles, a triangle fan, or a triangle strip, with an optional texture. Build a vertex with meshVertex, make the mesh with newMesh, and draw it.

MeshDraw

type MeshDraw = enum

How a mesh's vertices form triangles: independent triples, a fan around

the first vertex, or a strip.

Values

  • mdTriangles
  • mdFan
  • mdStrip

Mesh

type Mesh = ref object

A list of vertices you control, drawn as triangles with an optional

texture. Without one the vertex colors show directly, which is how you make gradients.

Fields

  • verts seq[Vertex]
  • texture Texture
  • mode MeshDraw

meshVertex

proc meshVertex(x, y: float; u = 0.0; v = 0.0; color: Color = (255'u8, 255'u8, 255'u8, 255'u8)): Vertex

A mesh vertex from a position, texture coordinates from 0 to 1, and a

color.

Parameters

  • x (float)
  • y (float)
  • u (auto)
  • v (auto)
  • color (Color)

Returns

Vertex

newMesh

proc newMesh(verts: seq[Vertex]; mode = mdTriangles; texture: Texture = nil): Mesh

A mesh from vertices built with meshVertex. Pass a texture to map it

across the vertices' texture coordinates.

Parameters

  • verts (seq[Vertex])
  • mode (auto)
  • texture (Texture)

Returns

Mesh

draw

proc draw(mesh: Mesh; nim2d: Nim2d; x = 0.0; y = 0.0)

Draw the mesh, optionally offset by (x, y), through the current transform.

Parameters

  • mesh (Mesh)
  • nim2d (Nim2d)
  • x (auto)
  • y (auto)
Generated with mkdocstrings-nim