Skip to content

Commit

Permalink
feat: add bind_texture_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Dec 24, 2023
1 parent c4a5f71 commit 4d3cd10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ pub trait HasContext {

unsafe fn bind_texture(&self, target: u32, texture: Option<Self::Texture>);

unsafe fn bind_texture_unit(&self, unit: u32, texture: Option<Self::Texture>);

unsafe fn bind_sampler(&self, unit: u32, sampler: Option<Self::Sampler>);

unsafe fn active_texture(&self, unit: u32);
Expand Down
5 changes: 5 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,11 @@ impl HasContext for Context {
gl.BindTexture(target, texture.map(|t| t.0.get()).unwrap_or(0));
}

unsafe fn bind_texture_unit(&self, unit: u32, texture: Option<Self::Texture>) {
let gl = &self.raw;
gl.BindTextureUnit(unit, texture.map(|t| t.0.get()).unwrap_or(0));
}

unsafe fn bind_sampler(&self, unit: u32, sampler: Option<Self::Sampler>) {
let gl = &self.raw;
gl.BindSampler(unit, sampler.map(|s| s.0.get()).unwrap_or(0));
Expand Down
4 changes: 4 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3775,6 +3775,10 @@ impl HasContext for Context {
}
}

unsafe fn bind_texture_unit(&self, unit: u32, texture: Option<Self::Texture>) {
unimplemented!()
}

unsafe fn bind_sampler(&self, unit: u32, sampler: Option<Self::Sampler>) {
let samplers = self.samplers.borrow();
let raw_sampler = sampler.map(|s| samplers.get_unchecked(s));
Expand Down

0 comments on commit 4d3cd10

Please sign in to comment.