1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use sfml::graphics::Texture as SfmlTexture; /// Texture pub struct Texture { texture: SfmlTexture, } impl Texture { /// Load a texture from a file pub fn load(f: &str) -> Texture { Texture { texture: SfmlTexture::new_from_file(f).expect("Couldn't load sprite"), } } /// Get a empty texture pub fn empty() -> Texture { Texture { texture: SfmlTexture::new(32, 32).unwrap(), } } /// Convert to an SFML (backend) texture pub fn to_sfml_texture(&self) -> &SfmlTexture { &self.texture } }