lovr.graphics.newMesh

Creates a new Mesh. Meshes contain the data for an arbitrary set of vertices, and can be drawn. You must specify either the capacity for the Mesh or an initial set of vertex data. Optionally, a custom format table can be used to specify the set of vertex attributes the mesh will provide to the active shader. The draw mode and usage hint can also optionally be specified.

mesh = lovr.graphics.newMesh(size, mode, usage)

Arguments

NameTypeDefaultDescription
sizenumberThe maximum number of vertices the Mesh can store.
modeDrawMode'fan'How the Mesh will connect its vertices into triangles.
usageMeshUsage'dynamic'An optimization hint indicating how often the data in the Mesh will be updated.

Returns

NameTypeDescription
meshMeshThe new Mesh.

mesh = lovr.graphics.newMesh(vertices, mode, usage)

Arguments

NameTypeDefaultDescription
verticestableA table of vertices. Each vertex is a table containing the vertex data.
modeDrawMode'fan'How the Mesh will connect its vertices into triangles.
usageMeshUsage'dynamic'An optimization hint indicating how often the data in the Mesh will be updated.

Returns

NameTypeDescription
meshMeshThe new Mesh.

These variants accept a custom vertex format. For more info, see the Mesh page.

mesh = lovr.graphics.newMesh(format, size, mode, usage)

Arguments

NameTypeDefaultDescription
formattableA table describing the attribute format for the vertices.
sizenumberThe maximum number of vertices the Mesh can store.
modeDrawMode'fan'How the Mesh will connect its vertices into triangles.
usageMeshUsage'dynamic'An optimization hint indicating how often the data in the Mesh will be updated.

Returns

NameTypeDescription
meshMeshThe new Mesh.

mesh = lovr.graphics.newMesh(format, vertices, mode, usage)

Arguments

NameTypeDefaultDescription
formattableA table describing the attribute format for the vertices.
verticestableA table of vertices. Each vertex is a table containing the vertex data.
modeDrawMode'fan'How the Mesh will connect its vertices into triangles.
usageMeshUsage'dynamic'An optimization hint indicating how often the data in the Mesh will be updated.

Returns

NameTypeDescription
meshMeshThe new Mesh.

Notes

Once created, the size of the Mesh can't be changed.

See also