From 54c0fd70f82eb1a6814872c78bc22380f438c9d1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 22 Oct 2023 19:29:11 +0200 Subject: feat(engine): add translating & scaling objects --- engine/src/opengl/shader.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engine/src/opengl') 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) + { + 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]; -- cgit v1.2.3-18-g5258