From a2d89841998986ef76b99375064565fb4b5223e1 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Sat, 3 Jun 2023 16:30:23 +0200 Subject: [PATCH] shader matrix support --- include/render/shaders/ShaderProgram.h | 2 ++ src/render/shaders/ShaderProgram.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/render/shaders/ShaderProgram.h b/include/render/shaders/ShaderProgram.h index 31f36d5..3d0af59 100755 --- a/include/render/shaders/ShaderProgram.h +++ b/include/render/shaders/ShaderProgram.h @@ -3,6 +3,7 @@ #include #include "Defines.h" #include "render/GL.h" +#include "misc/Maths.h" namespace td { namespace shader { @@ -27,6 +28,7 @@ protected: void LoadVector(unsigned int location, const Vec2f& vector) const; void LoadVector(unsigned int location, const Vec3f& vector) const; void LoadBoolean(unsigned int location, bool value) const; + void LoadMat4(unsigned int location, const maths::Mat4f& mat) const; void CleanUp() const; private: diff --git a/src/render/shaders/ShaderProgram.cpp b/src/render/shaders/ShaderProgram.cpp index 1b7bd83..c74ccd0 100755 --- a/src/render/shaders/ShaderProgram.cpp +++ b/src/render/shaders/ShaderProgram.cpp @@ -67,6 +67,10 @@ void ShaderProgram::LoadBoolean(unsigned int location, bool value) const { glUniform1i(static_cast(location), value); } +void ShaderProgram::LoadMat4(unsigned int location, const maths::Mat4f& mat) const { + glUniformMatrix4fv(static_cast(location), 1, false, reinterpret_cast(&mat)); +} + void ShaderProgram::CleanUp() const { Stop(); glDetachShader(m_ProgramID, m_VertexShaderID);