Pass:mesh

Draws a mesh.


Pass:mesh(vertices, transform, start, count, instances, base)

Arguments

NameTypeDefaultDescription
verticesBuffernil The buffer containing the vertices to draw.
transformMat4 The transform to apply to the mesh. Can also be provided as a position, 1-component scale, and rotation using a combination of Vectors and numbers.
startnumber1 The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).
countnumbernil The number of vertices to render (or the number of indices, when using an index buffer). When nil, as many vertices or indices as possible will be drawn (based on the length of the Buffers and start).
instancesnumber1 The number of copies of the mesh to render.
basenumber0 A base offset to apply to vertex indices.

Returns

Nothing


Pass:mesh(vertices, indices, transform, start, count, instances, base)

Arguments

NameTypeDefaultDescription
verticesBuffernil The buffer containing the vertices to draw.
indicesBuffer The buffer containing the vertex indices to draw.
transformMat4 The transform to apply to the mesh. Can also be provided as a position, 1-component scale, and rotation using a combination of Vectors and numbers.
startnumber1 The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer).
countnumbernil The number of vertices to render (or the number of indices, when using an index buffer). When nil, as many vertices or indices as possible will be drawn (based on the length of the Buffers and start).
instancesnumber1 The number of copies of the mesh to render.
basenumber0 A base offset to apply to vertex indices.

Returns

Nothing


Pass:mesh(vertices, indices, draws, drawcount, offset, stride)

Arguments

NameTypeDefaultDescription
verticesBuffernil The buffer containing the vertices to draw.
indicesBuffer The buffer containing the vertex indices to draw.
drawsBuffer The buffer containing indirect draw commands.
drawcountnumber The number of indirect draws to draw.
offsetnumber A byte offset into the draw buffer.
stridenumber The number of bytes between consecutive elements in the draw buffer.

Returns

Nothing


Pass:mesh(vertexcount, transform)

Arguments

NameTypeDescription
vertexcountnumber The number of vertices or indices to draw.
transformMat4 The transform to apply to the mesh. Can also be provided as a position, 1-component scale, and rotation using a combination of Vectors and numbers.

Returns

Nothing


Pass:mesh(vertexcount, indices, transform)

Arguments

NameTypeDescription
vertexcountnumber The number of vertices or indices to draw.
indicesBuffer The buffer containing the vertex indices to draw.
transformMat4 The transform to apply to the mesh. Can also be provided as a position, 1-component scale, and rotation using a combination of Vectors and numbers.

Returns

Nothing

Notes

The index buffer defines the order the vertices are drawn in. It can be used to reorder, reuse, or omit vertices from the mesh.

The active MeshMode controls whether the vertices are drawn as points, lines, or triangles.

The active Material is applied to the mesh.

Example

function lovr.draw(pass)
  local vertices = {
    vec3(  0,  .4, 0), vec4(1, 0, 0, 1),
    vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),
    vec3( .5, -.4, 0), vec4(0, 0, 1, 1)
  }

  local format = {
    { type = 'vec3', location = 'VertexPosition' },
    { type = 'vec4', location = 'VertexColor' }
  }

  local triangle = lovr.graphics.getBuffer(vertices, format)

  pass:mesh(triangle, 0, 1.7, -1)
end

See also