diff options
| author | HampusM <hampus@hampusmat.com> | 2024-04-14 14:33:44 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2024-04-15 22:07:42 +0200 | 
| commit | 97bb50d42d7c1f475bf63861449a2162f665be26 (patch) | |
| tree | b25091d4ab06b60863b4ea1bf08f1ef36ad083a6 /engine/src/texture.rs | |
| parent | 73c5bb19e7274b3e4048f70a19a7b9a2d361bfa1 (diff) | |
refactor(engine): use OpenGL DSA functions
Diffstat (limited to 'engine/src/texture.rs')
| -rw-r--r-- | engine/src/texture.rs | 25 | 
1 files changed, 14 insertions, 11 deletions
diff --git a/engine/src/texture.rs b/engine/src/texture.rs index 5cea9ff..88c57bd 100644 --- a/engine/src/texture.rs +++ b/engine/src/texture.rs @@ -7,8 +7,8 @@ use image::io::Reader as ImageReader;  use image::{DynamicImage, ImageError, Rgb, RgbImage};  use crate::color::Color; +use crate::data_types::dimens::Dimens;  use crate::opengl::texture::PixelDataFormat; -use crate::vector::Vec2;  static NEXT_ID: AtomicU32 = AtomicU32::new(0); @@ -25,7 +25,7 @@ pub struct Texture      id: Id,      image: DynamicImage,      pixel_data_format: PixelDataFormat, -    dimensions: Vec2<u32>, +    dimensions: Dimens<u32>,      properties: Properties,  } @@ -46,14 +46,17 @@ impl Texture              .map_err(Error::DecodeImageFailed)?;          let pixel_data_format = match &image { -            DynamicImage::ImageRgb8(_) => PixelDataFormat::Rgb, -            DynamicImage::ImageRgba8(_) => PixelDataFormat::Rgba, +            DynamicImage::ImageRgb8(_) => PixelDataFormat::Rgb8, +            DynamicImage::ImageRgba8(_) => PixelDataFormat::Rgba8,              _ => {                  return Err(Error::UnsupportedImageDataKind);              }          }; -        let dimensions = Vec2 { x: image.width(), y: image.height() }; +        let dimensions = Dimens { +            width: image.width(), +            height: image.height(), +        };          let id = NEXT_ID.fetch_add(1, Ordering::Relaxed); @@ -67,11 +70,11 @@ impl Texture      }      #[must_use] -    pub fn new_from_color(dimensions: &Vec2<u32>, color: &Color<u8>) -> Self +    pub fn new_from_color(dimensions: &Dimens<u32>, color: &Color<u8>) -> Self      {          let image = RgbImage::from_pixel( -            dimensions.x, -            dimensions.y, +            dimensions.width, +            dimensions.height,              Rgb([color.red, color.green, color.blue]),          ); @@ -80,8 +83,8 @@ impl Texture          Self {              id: Id::new(id),              image: image.into(), -            pixel_data_format: PixelDataFormat::Rgb, -            dimensions: dimensions.clone(), +            pixel_data_format: PixelDataFormat::Rgb8, +            dimensions: *dimensions,              properties: Properties::default(),          }      } @@ -104,7 +107,7 @@ impl Texture      }      #[must_use] -    pub fn dimensions(&self) -> &Vec2<u32> +    pub fn dimensions(&self) -> &Dimens<u32>      {          &self.dimensions      }  | 
