Pass:mesh
EditDraws a mesh.
Draw a range of vertices from a Buffer, using numbers for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
x | number | 0 | The x coordinate of the position to draw the mesh at. |
y | number | 0 | The y coordinate of the position to draw the mesh at. |
z | number | 0 | The z coordinate of the position to draw the mesh at. |
scale | number | 1 | The scale of the mesh. |
angle | number | 0 | The number of radians the mesh is rotated around its rotational axis. |
ax | number | 0 | The x component of the axis of rotation. |
ay | number | 1 | The y component of the axis of rotation. |
az | number | 0 | The z component of the axis of rotation. |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
Returns
Nothing
Draw a range of vertices from a Buffer, using vector types for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
position | Vec3 | The position to draw the mesh at. | |
scales | Vec3 | The scale of the mesh. | |
orientation | Quat | The orientation of the mesh. | |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
Returns
Nothing
Draw a range of vertices from a Buffer, using a matrix for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
transform | Mat4 | The transform to apply to the mesh. | |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
Returns
Nothing
Draw a mesh using a vertex buffer and an index buffer, using numbers for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
indices | Buffer | The buffer containing the vertex indices to draw. | |
x | number | 0 | The x coordinate of the position to draw the mesh at. |
y | number | 0 | The y coordinate of the position to draw the mesh at. |
z | number | 0 | The z coordinate of the position to draw the mesh at. |
scale | number | 1 | The scale of the mesh. |
angle | number | 0 | The number of radians the mesh is rotated around its rotational axis. |
ax | number | 0 | The x component of the axis of rotation. |
ay | number | 1 | The y component of the axis of rotation. |
az | number | 0 | The z component of the axis of rotation. |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
base | number | 0 | A base offset to apply to vertex indices. |
Returns
Nothing
Draw a mesh using a vertex buffer and an index buffer, using vector types for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
indices | Buffer | The buffer containing the vertex indices to draw. | |
position | Vec3 | The position to draw the mesh at. | |
scales | Vec3 | The scale of the mesh. | |
orientation | Quat | The orientation of the mesh. | |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
base | number | 0 | A base offset to apply to vertex indices. |
Returns
Nothing
Draw a mesh using a vertex buffer and an index buffer, using a matrix for the transform.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
indices | Buffer | The buffer containing the vertex indices to draw. | |
transform | Mat4 | The transform to apply to the mesh. | |
start | number | 1 | The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). |
count | number | nil |
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 ).
|
instances | number | 1 | The number of copies of the mesh to render. |
base | number | 0 | A base offset to apply to vertex indices. |
Returns
Nothing
Perform indirect draws. drawcount
meshes from the vertex and index buffer will be drawn, using parameters starting from offset
bytes in the draws
buffer.
Arguments
Name | Type | Default | Description |
vertices | Buffer | nil | The buffer containing the vertices to draw. |
indices | Buffer | The buffer containing the vertex indices to draw. | |
draws | Buffer | The buffer containing indirect draw commands. | |
drawcount | number | The number of indirect draws to draw. | |
offset | number | A byte offset into the draw buffer. | |
stride | number | The number of bytes between consecutive elements in the draw buffer. |
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.
When drawing without a vertex buffer, the VertexIndex
variable can be used in shaders to compute the position of each vertex, possibly by reading data from other Buffer
or Texture
resources.
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