From 50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 3 Mar 2021 00:17:04 +0000 Subject: Only calculate and bind the model transform if the shader program uses it --- gfx/gl/shader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gfx/gl/shader.cpp') diff --git a/gfx/gl/shader.cpp b/gfx/gl/shader.cpp index 04d5ac6..3021257 100644 --- a/gfx/gl/shader.cpp +++ b/gfx/gl/shader.cpp @@ -74,8 +74,10 @@ Shader::setModel(const Location & loc, Program pid) const { auto & prog = programs[(int)pid]; glUseProgram(prog.m_program); - const auto model {glm::translate(loc.pos) * rotate_ypr(loc.rot)}; - glUniformMatrix4fv(prog.model_uniform, 1, GL_FALSE, &model[0][0]); + if (prog.model_uniform >= 0) { + const auto model {glm::translate(loc.pos) * rotate_ypr(loc.rot)}; + glUniformMatrix4fv(prog.model_uniform, 1, GL_FALSE, &model[0][0]); + } } void -- cgit v1.2.3