rugra/
texture.rs

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