Struct ggez::graphics::MeshBatch [−][src]
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]
P: Into<DrawParam>,
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]
P: Into<DrawParam>,
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]
&mut self,
first_handle: MeshIdx,
params: &[P]
) -> GameResult where
P: Into<DrawParam> + Copy,
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]
&mut self,
ctx: &mut Context,
first_handle: MeshIdx,
count: usize
) -> GameResult
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
Auto Trait Implementations
impl !RefUnwindSafe for MeshBatch
[src]
impl Send for MeshBatch
[src]
impl Sync for MeshBatch
[src]
impl Unpin for MeshBatch
[src]
impl !UnwindSafe for MeshBatch
[src]
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> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,