diff options
author | HampusM <hampus@hampusmat.com> | 2025-06-03 18:06:29 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-06-03 18:06:54 +0200 |
commit | d56f5bce6a38ef71b3f15a3efa845637885a410f (patch) | |
tree | fbc5f96b877ef9765f27b7b2eb268e9b02158163 /engine/src/opengl | |
parent | 93ee9ee9a37ac410ea926997f08e1d5db052bb86 (diff) |
refactor(engine): bind texture to gl texture unit with DSA
Diffstat (limited to 'engine/src/opengl')
-rw-r--r-- | engine/src/opengl/texture.rs | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/engine/src/opengl/texture.rs b/engine/src/opengl/texture.rs index 706b9c9..80a5f37 100644 --- a/engine/src/opengl/texture.rs +++ b/engine/src/opengl/texture.rs @@ -19,10 +19,10 @@ impl Texture Self { texture } } - pub fn bind(&self) + pub fn bind_to_texture_unit(&self, texture_unit: u32) { unsafe { - gl::BindTexture(gl::TEXTURE_2D, self.texture); + gl::BindTextureUnit(texture_unit, self.texture); } } @@ -167,35 +167,3 @@ impl PixelDataFormat } } } - -pub fn set_active_texture_unit(texture_unit: TextureUnit) -{ - unsafe { - gl::ActiveTexture(texture_unit.into_gl()); - } -} - -macro_rules! texture_unit_enum { - (cnt=$cnt: literal) => { - seq_macro::seq!(N in 0..$cnt { - #[derive(Debug, Clone, Copy)] - pub enum TextureUnit { - #( - No~N, - )* - } - - impl TextureUnit { - fn into_gl(self) -> gl::types::GLenum { - match self { - #( - Self::No~N => gl::TEXTURE~N, - )* - } - } - } - }); - }; -} - -texture_unit_enum!(cnt = 3); |