diff options
Diffstat (limited to 'engine/src/opengl')
-rw-r--r-- | engine/src/opengl/shader.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/engine/src/opengl/shader.rs b/engine/src/opengl/shader.rs index 3dc308e..4bf56aa 100644 --- a/engine/src/opengl/shader.rs +++ b/engine/src/opengl/shader.rs @@ -3,6 +3,7 @@ use std::ptr::null_mut; use crate::matrix::Matrix; use crate::opengl::currently_bound::CurrentlyBound; +use crate::vector::Vec3; #[derive(Debug)] pub struct Shader @@ -179,6 +180,41 @@ impl Program } } + pub fn set_uniform_vec_3fv( + &self, + _: &CurrentlyBound<Self>, + name: &CStr, + vec: &Vec3<f32>, + ) + { + let uniform_location = + unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) }; + + unsafe { + gl::Uniform3fv(uniform_location, 1, vec.as_ptr()); + } + } + + pub fn set_uniform_1fv(&self, _: &CurrentlyBound<Self>, name: &CStr, num: f32) + { + let uniform_location = + unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) }; + + unsafe { + gl::Uniform1fv(uniform_location, 1, &num); + } + } + + pub fn set_uniform_1uiv(&self, _: &CurrentlyBound<Self>, name: &CStr, num: u32) + { + let uniform_location = + unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) }; + + unsafe { + gl::Uniform1uiv(uniform_location, 1, &num); + } + } + fn get_info_log(&self) -> String { let mut buf = vec![gl::types::GLchar::default(); 512]; |