Struct tetra::graphics::mesh::GeometryBuilder[][src]

pub struct GeometryBuilder { /* fields omitted */ }
Expand description

A builder for creating primitive shape geometry, and associated buffers/meshes.

Performance

GeometryBuilder stores the generated vertex and index data in a pair of Vecs. This means that creating a new builder (as well as cloning an existing one) will allocate memory. Consider reusing a GeometryBuilder if you need to reuse the generated data, or if you need to create new data every frame.

Creating buffers/meshes from the generated geometry is a fairly expensive operation. Try to avoid creating lots of seperate buffers/meshes, and pack multiple shapes into the same buffers/mesh if they don’t move relative to each other.

Examples

The shapes example demonstrates how to draw primitive shapes, both through the simplified API on Mesh, and the more powerful GeometryBuilder API.

Implementations

Creates a new empty geometry builder.

Adds a rectangle.

Errors

Adds a rounded rectangle.

Errors

Adds a circle.

Errors

Adds an ellipse.

Errors

Adds a polygon.

Errors

Adds a polyline.

Errors

Sets the color that will be used for subsequent shapes.

You can also use DrawParams::color to tint an entire mesh - this method only needs to be used if you want to display multiple colors in a single piece of geometry.

Clears the geometry builder’s data.

Returns a view of the generated vertex data.

Returns a view of the generated index data.

Consumes the builder, returning the generated geometry.

Builds a vertex and index buffer from the generated geometry.

This involves uploading the geometry to the GPU, and is a fairly expensive operation.

Errors

Builds a mesh from the generated geometry.

This involves uploading the geometry to the GPU, and is a fairly expensive operation.

Errors

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.