Struct ggez::graphics::MeshBatch[][src]

pub struct MeshBatch { /* fields omitted */ }

Mesh that will be rendered with hardware instancing. Use this when you have a lot of similar geometry which does not move around often.

Implementations

impl MeshBatch[src]

pub fn new(mesh: Mesh) -> GameResult<MeshBatch>[src]

Creates a new mesh batch.

Takes ownership of the Mesh.

pub fn clear(&mut self)[src]

Removes all instances from the batch.

Calling this invalidates the entire buffer, however this will not automatically deallocate graphics card memory or flush the buffer.

pub fn get_instance_params(&self) -> &[DrawParam][src]

Returns a reference to mesh instances

pub fn get_instance_params_mut(&mut self) -> &mut [DrawParam][src]

Returns a mutable reference to mesh instances.

Please note that manually altering items in this slice will not automatically invalidate the buffer, you will have to manually call flush() or flush_range() later.

pub fn add<P>(&mut self, param: P) -> MeshIdx where
    P: Into<DrawParam>, 
[src]

Adds a new instance to the mesh batch

Returns a handle with which to modify the instance using set()

Calling this invalidates the entire buffer and will result in flusing it on the next graphics::draw() call.

pub fn set<P>(&mut self, handle: MeshIdx, param: P) -> GameResult where
    P: Into<DrawParam>, 
[src]

Alters an instance in the batch to use the given draw params.

Calling this invalidates the entire buffer and will result in flusing it on the next graphics::draw() call.

This might cause performance issues with large batches, to avoid this consider using flush_range to explicitly invalidate required data slice.

pub fn set_range<P>(
    &mut self,
    first_handle: MeshIdx,
    params: &[P]
) -> GameResult where
    P: Into<DrawParam> + Copy
[src]

Alters a range of instances in the batch to use the given draw params

Calling this invalidates the entire buffer and will result in flusing it on the next graphics::draw() call.

This might cause performance issues with large batches, to avoid this consider using flush_range to explicitly invalidate required data slice.

pub fn flush_range(
    &mut self,
    ctx: &mut Context,
    first_handle: MeshIdx,
    count: usize
) -> GameResult
[src]

Immediately sends specified slice of data in the batch to the graphics card.

Calling this counts as a full buffer flush, but only flushes the data within the provided range, anything outside of this range will not be touched.

Use it for updating small portions of large batches.

pub fn flush(&mut self, ctx: &mut Context) -> GameResult[src]

Immediately sends all data in the batch to the graphics card.

In general, graphics::draw() on the MeshBatch will do this automatically when buffer contents are updated.

pub fn draw(&mut self, ctx: &mut Context, param: DrawParam) -> GameResult[src]

Draws the drawable onto the rendering target.

pub fn dimensions(&self, ctx: &mut Context) -> Option<Rect>[src]

Returns a bounding box in the form of a Rect.

pub fn set_blend_mode(&mut self, mode: Option<BlendMode>)[src]

Sets the blend mode to be used when drawing this drawable.

pub fn blend_mode(&self) -> Option<BlendMode>[src]

Gets the blend mode to be used when drawing this drawable.

Trait Implementations

impl Debug for MeshBatch[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,