summaryrefslogtreecommitdiff
path: root/engine/src/opengl
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-22 19:29:11 +0200
committerHampusM <hampus@hampusmat.com>2023-10-22 19:29:11 +0200
commit54c0fd70f82eb1a6814872c78bc22380f438c9d1 (patch)
tree7b0b67b52daa7ce18432c7b83caa862234a3255c /engine/src/opengl
parent30394c16ccdcdb145352e245a7a8893cef28e82d (diff)
feat(engine): add translating & scaling objects
Diffstat (limited to 'engine/src/opengl')
-rw-r--r--engine/src/opengl/shader.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/engine/src/opengl/shader.rs b/engine/src/opengl/shader.rs
index 0bbca77..603c790 100644
--- a/engine/src/opengl/shader.rs
+++ b/engine/src/opengl/shader.rs
@@ -1,6 +1,8 @@
use std::ffi::CStr;
use std::ptr::null_mut;
+use crate::matrix::Matrix;
+
#[derive(Debug)]
pub struct Shader
{
@@ -156,6 +158,16 @@ impl Program
}
}
+ pub fn set_uniform_matrix_4fv(&self, name: &CStr, matrix: &Matrix<f32, 4, 4>)
+ {
+ let uniform_location =
+ unsafe { gl::GetUniformLocation(self.program, name.as_ptr().cast()) };
+
+ unsafe {
+ gl::UniformMatrix4fv(uniform_location, 1, gl::FALSE, matrix.as_ptr());
+ }
+ }
+
fn get_info_log(&self) -> String
{
let mut buf = vec![gl::types::GLchar::default(); 512];