summaryrefslogtreecommitdiff
path: root/engine/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/opengl')
-rw-r--r--engine/src/opengl/shader.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/engine/src/opengl/shader.rs b/engine/src/opengl/shader.rs
index 603c790..3dc308e 100644
--- a/engine/src/opengl/shader.rs
+++ b/engine/src/opengl/shader.rs
@@ -2,6 +2,7 @@ use std::ffi::CStr;
use std::ptr::null_mut;
use crate::matrix::Matrix;
+use crate::opengl::currently_bound::CurrentlyBound;
#[derive(Debug)]
pub struct Shader
@@ -151,14 +152,24 @@ impl Program
Ok(())
}
- pub fn activate(&self)
+ pub fn activate(&self, cb: impl FnOnce(CurrentlyBound<'_, Self>))
{
unsafe {
gl::UseProgram(self.program);
}
+
+ // SAFETY: The shader program object is bound above
+ let currently_bound = unsafe { CurrentlyBound::new() };
+
+ cb(currently_bound);
}
- pub fn set_uniform_matrix_4fv(&self, name: &CStr, matrix: &Matrix<f32, 4, 4>)
+ pub fn set_uniform_matrix_4fv(
+ &self,
+ _: &CurrentlyBound<Self>,
+ name: &CStr,
+ matrix: &Matrix<f32, 4, 4>,
+ )
{
let uniform_location =
unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) };