summaryrefslogtreecommitdiff
path: root/gfx/gl/shader.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:17:04 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:17:04 +0000
commit50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79 (patch)
tree0b1dcb349349225c0324e1245ebd6474d9741239 /gfx/gl/shader.cpp
parentReplace Transform with Location (diff)
downloadilt-50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79.tar.bz2
ilt-50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79.tar.xz
ilt-50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79.zip
Only calculate and bind the model transform if the shader program uses it
Diffstat (limited to 'gfx/gl/shader.cpp')
-rw-r--r--gfx/gl/shader.cpp6
1 files changed, 4 insertions, 2 deletions
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