[−][src]Struct coffee::graphics::texture_array::Loader
A TextureArray
builder that produces a Task
.
You should use add
to get an index Key
per texture so you can
retrieve each Index
from the provided Indices
on finish
.
For example, let's say that we want to use a TextureArray
for our
entities. We could write in our entity
module:
use coffee::load::Task; use coffee::graphics::texture_array::{TextureArray, Index, Loader}; pub struct Assets { player: Index, enemy: Index, building: Index, items: Index, texture: TextureArray, } impl Assets { pub fn load() -> Task<Assets> { let mut loader = Loader::new(2048, 2048); let player = loader.add("player.png"); let enemy = loader.add("enemy.png"); let building = loader.add("building.png"); let items = loader.add("items.png"); loader.finish(move |texture, indices| Ok(Assets { player: indices.get(player)?, enemy: indices.get(enemy)?, building: indices.get(building)?, items: indices.get(items)?, texture, })) } }
Methods
impl Loader
[src]
pub fn new(width: u16, height: u16) -> Loader
[src]
Create a new Loader
that produces a TextureArray
of the given
size.
pub fn add<P: Into<PathBuf>>(&mut self, path: P) -> Key
[src]
Queue an image to be added to the produced TextureArray
and obtain
a Key
to its Index
.
pub fn finish<F, T>(self, on_completion: F) -> Task<T> where
F: 'static + Fn(TextureArray, Indices) -> Result<T>,
[src]
F: 'static + Fn(TextureArray, Indices) -> Result<T>,
Finish the Loader
definition and obtain a Task
that produces
a value from the loaded TextureArray
and its Indices
.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Erased for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,