[][src]Struct coffee::graphics::texture_array::Loader

pub struct Loader { /* fields omitted */ }

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]

Finish the Loader definition and obtain a Task that produces a value from the loaded TextureArray and its Indices.

Trait Implementations

impl Debug for Loader[src]

Auto Trait Implementations

impl Send for Loader

impl Sync for Loader

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

impl<T, U> TryInto 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<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>, 

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>,