diff options
author | HampusM <hampus@hampusmat.com> | 2025-06-03 17:26:26 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-06-03 17:26:26 +0200 |
commit | 93ee9ee9a37ac410ea926997f08e1d5db052bb86 (patch) | |
tree | 88b31c30cfb14469398a763fcc977eaea7d52383 /engine/src/opengl | |
parent | 9023f12f74f5ec8836374383fd5c347612c5d42f (diff) |
refactor(engine): make texture mod not reexport from gl mod
Diffstat (limited to 'engine/src/opengl')
-rw-r--r-- | engine/src/opengl/texture.rs | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/engine/src/opengl/texture.rs b/engine/src/opengl/texture.rs index ffc978b..706b9c9 100644 --- a/engine/src/opengl/texture.rs +++ b/engine/src/opengl/texture.rs @@ -1,5 +1,4 @@ use crate::data_types::dimens::Dimens; -use crate::texture::Properties; #[derive(Debug)] pub struct Texture @@ -41,16 +40,9 @@ impl Texture } } - pub fn apply_properties(&mut self, properties: &Properties) - { - self.set_wrap(properties.wrap); - self.set_magnifying_filter(properties.magnifying_filter); - self.set_minifying_filter(properties.minifying_filter); - } - pub fn set_wrap(&mut self, wrapping: Wrapping) { - let wrapping_gl = wrapping.to_gl(); + let wrapping_gl = wrapping as gl::types::GLenum; #[allow(clippy::cast_possible_wrap)] unsafe { @@ -61,7 +53,7 @@ impl Texture pub fn set_magnifying_filter(&mut self, filtering: Filtering) { - let filtering_gl = filtering.to_gl(); + let filtering_gl = filtering as gl::types::GLenum; #[allow(clippy::cast_possible_wrap)] unsafe { @@ -75,7 +67,7 @@ impl Texture pub fn set_minifying_filter(&mut self, filtering: Filtering) { - let filtering_gl = filtering.to_gl(); + let filtering_gl = filtering as gl::types::GLenum; #[allow(clippy::cast_possible_wrap)] unsafe { @@ -132,43 +124,21 @@ impl Drop for Texture /// Texture wrapping. #[derive(Debug, Clone, Copy)] +#[repr(u32)] pub enum Wrapping { - Repeat, - MirroredRepeat, - ClampToEdge, - ClampToBorder, -} - -impl Wrapping -{ - fn to_gl(self) -> gl::types::GLenum - { - match self { - Self::Repeat => gl::REPEAT, - Self::MirroredRepeat => gl::MIRRORED_REPEAT, - Self::ClampToEdge => gl::CLAMP_TO_EDGE, - Self::ClampToBorder => gl::CLAMP_TO_BORDER, - } - } + Repeat = gl::REPEAT, + MirroredRepeat = gl::MIRRORED_REPEAT, + ClampToEdge = gl::CLAMP_TO_EDGE, + ClampToBorder = gl::CLAMP_TO_BORDER, } #[derive(Debug, Clone, Copy)] +#[repr(u32)] pub enum Filtering { - Nearest, - Linear, -} - -impl Filtering -{ - fn to_gl(self) -> gl::types::GLenum - { - match self { - Self::Linear => gl::LINEAR, - Self::Nearest => gl::NEAREST, - } - } + Nearest = gl::NEAREST, + Linear = gl::LINEAR, } /// Texture pixel data format. |