summaryrefslogtreecommitdiff
path: root/engine/src/opengl/shader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/opengl/shader.rs')
-rw-r--r--engine/src/opengl/shader.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/engine/src/opengl/shader.rs b/engine/src/opengl/shader.rs
index 9bed09b..224a9bc 100644
--- a/engine/src/opengl/shader.rs
+++ b/engine/src/opengl/shader.rs
@@ -153,7 +153,7 @@ impl Program
Ok(())
}
- pub fn activate(&self, cb: impl FnOnce(CurrentlyBound<'_, Self>))
+ pub fn activate<Ret>(&self, cb: impl FnOnce(CurrentlyBound<'_, Self>) -> Ret) -> Ret
{
unsafe {
gl::UseProgram(self.program);
@@ -162,7 +162,7 @@ impl Program
// SAFETY: The shader program object is bound above
let currently_bound = unsafe { CurrentlyBound::new() };
- cb(currently_bound);
+ cb(currently_bound)
}
pub fn set_uniform_matrix_4fv(
@@ -205,6 +205,16 @@ impl Program
}
}
+ pub fn set_uniform_1i(&self, _: &CurrentlyBound<Self>, name: &CStr, num: i32)
+ {
+ let uniform_location =
+ unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) };
+
+ unsafe {
+ gl::Uniform1i(uniform_location, num);
+ }
+ }
+
fn get_info_log(&self) -> String
{
let mut buf = vec![gl::types::GLchar::default(); 512];