diff options
Diffstat (limited to 'engine/src/texture.rs')
-rw-r--r-- | engine/src/texture.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/engine/src/texture.rs b/engine/src/texture.rs index bde3cd2..f32bc0a 100644 --- a/engine/src/texture.rs +++ b/engine/src/texture.rs @@ -17,6 +17,8 @@ pub use reexports::*; pub struct Texture { inner: InnerTexture, + pixel_data_format: PixelDataFormat, + dimensions: Vec2<u32>, } impl Texture @@ -45,16 +47,18 @@ impl Texture let inner = InnerTexture::new(); + let dimensions = Vec2 { x: image.width(), y: image.height() }; + inner.bind(|texture_curr_bound| { InnerTexture::generate( &texture_curr_bound, - &Vec2 { x: image.width(), y: image.height() }, + &dimensions, image.as_bytes(), pixel_data_format, ); }); - let me = Self { inner }; + let me = Self { inner, pixel_data_format, dimensions }; me.set_wrap(Wrapping::Repeat); me.set_magnifying_filter(Filtering::Linear); @@ -90,6 +94,25 @@ impl Texture } } +impl Clone for Texture +{ + fn clone(&self) -> Self + { + let inner = self.inner.copy( + &self.dimensions, + self.pixel_data_format, + &Vec2::ZERO, + &Vec2::ZERO, + ); + + Self { + inner, + pixel_data_format: self.pixel_data_format, + dimensions: self.dimensions.clone(), + } + } +} + /// Texture error. #[derive(Debug, thiserror::Error)] pub enum Error |