diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-03 00:17:04 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-03 00:17:04 +0000 |
commit | 50f364dc69f1f42beb6ec2b0cf1d4fbca0c97b79 (patch) | |
tree | 0b1dcb349349225c0324e1245ebd6474d9741239 /gfx/gl | |
parent | Replace Transform with Location (diff) | |
download | ilt-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')
-rw-r--r-- | gfx/gl/shader.cpp | 6 |
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
|