Struct tetra::graphics::mesh::GeometryBuilder [−][src]
A builder for creating primitive shape geometry, and associated buffers/meshes.
Performance
GeometryBuilder
stores the generated vertex and index data in a pair of Vec
s. 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.
Examples
The shapes
example demonstrates
how to draw primitive shapes, both through the simplified API on Mesh
, and the more powerful
GeometryBuilder
API.
Implementations
impl GeometryBuilder
[src]
pub fn new() -> GeometryBuilder
[src]
Creates a new empty geometry builder.
pub fn rectangle(
&mut self,
style: ShapeStyle,
rectangle: Rectangle
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
style: ShapeStyle,
rectangle: Rectangle
) -> Result<&mut GeometryBuilder>
Adds a rectangle.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn rounded_rectangle(
&mut self,
style: ShapeStyle,
rectangle: Rectangle,
radii: BorderRadii
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
style: ShapeStyle,
rectangle: Rectangle,
radii: BorderRadii
) -> Result<&mut GeometryBuilder>
Adds a rounded rectangle.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn circle(
&mut self,
style: ShapeStyle,
center: Vec2<f32>,
radius: f32
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
style: ShapeStyle,
center: Vec2<f32>,
radius: f32
) -> Result<&mut GeometryBuilder>
Adds a circle.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn ellipse(
&mut self,
style: ShapeStyle,
center: Vec2<f32>,
radii: Vec2<f32>
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
style: ShapeStyle,
center: Vec2<f32>,
radii: Vec2<f32>
) -> Result<&mut GeometryBuilder>
Adds an ellipse.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn polygon(
&mut self,
style: ShapeStyle,
points: &[Vec2<f32>]
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
style: ShapeStyle,
points: &[Vec2<f32>]
) -> Result<&mut GeometryBuilder>
Adds a polygon.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn polyline(
&mut self,
stroke_width: f32,
points: &[Vec2<f32>]
) -> Result<&mut GeometryBuilder>
[src]
&mut self,
stroke_width: f32,
points: &[Vec2<f32>]
) -> Result<&mut GeometryBuilder>
Adds a polyline.
Errors
TetraError::TessellationError
will be returned if the shape could not be turned into vertex data.
pub fn set_color(&mut self, color: Color) -> &mut GeometryBuilder
[src]
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.
pub fn clear(&mut self) -> &mut GeometryBuilder
[src]
Clears the geometry builder’s data.
pub fn vertices(&self) -> &[Vertex]
[src]
Returns a view of the generated vertex data.
pub fn indices(&self) -> &[u32]
[src]
Returns a view of the generated index data.
pub fn into_data(self) -> (Vec<Vertex>, Vec<u32>)
[src]
Consumes the builder, returning the generated geometry.
pub fn build_buffers(
&self,
ctx: &mut Context
) -> Result<(VertexBuffer, IndexBuffer)>
[src]
&self,
ctx: &mut Context
) -> Result<(VertexBuffer, IndexBuffer)>
Builds a vertex and index buffer from the generated geometry.
Errors
TetraError::PlatformError
will be returned if the underlying graphics API encounters an error.
pub fn build_mesh(&self, ctx: &mut Context) -> Result<Mesh>
[src]
Builds a mesh from the generated geometry.
Errors
TetraError::PlatformError
will be returned if the underlying graphics API encounters an error.
Trait Implementations
impl Clone for GeometryBuilder
[src]
fn clone(&self) -> GeometryBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for GeometryBuilder
[src]
impl Default for GeometryBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for GeometryBuilder
impl Send for GeometryBuilder
impl Sync for GeometryBuilder
impl Unpin for GeometryBuilder
impl UnwindSafe for GeometryBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,