summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-08-26 13:55:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-08-26 13:59:57 +0100
commit10e0fee323e6277ba73ee1fc148417882bc381c3 (patch)
tree86d83581b6b39d3a5f2f11a420d35440106d41e5 /gfx/gl
parentAdd a foliage vertex array for just the location data (diff)
downloadilt-10e0fee323e6277ba73ee1fc148417882bc381c3.tar.bz2
ilt-10e0fee323e6277ba73ee1fc148417882bc381c3.tar.xz
ilt-10e0fee323e6277ba73ee1fc148417882bc381c3.zip
Add helper to test if a uniform was found
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/program.h6
-rw-r--r--gfx/gl/sceneShader.cpp2
-rw-r--r--gfx/gl/shadowMapper.cpp4
-rw-r--r--gfx/gl/shadowStenciller.h2
4 files changed, 11 insertions, 3 deletions
diff --git a/gfx/gl/program.h b/gfx/gl/program.h
index c89a128..20be1aa 100644
--- a/gfx/gl/program.h
+++ b/gfx/gl/program.h
@@ -33,6 +33,12 @@ public:
return location;
}
+ explicit
+ operator bool() const
+ {
+ return location >= 0;
+ }
+
protected:
GLint location;
};
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp
index 4cbccb3..571538a 100644
--- a/gfx/gl/sceneShader.cpp
+++ b/gfx/gl/sceneShader.cpp
@@ -65,7 +65,7 @@ SceneShader::SceneProgram::setViewProjection(const GlobalPosition3D & viewPoint,
void
SceneShader::SceneProgram::setViewPort(const ViewPort & viewPort) const
{
- if (viewPortLoc >= 0) {
+ if (viewPortLoc) {
glUseProgram(*this);
glUniform(viewPortLoc, viewPort);
}
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 55167e5..177bd22 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -139,7 +139,9 @@ ShadowMapper::ShadowProgram::setView(const std::span<const glm::mat4x4> viewProj
use();
glUniform(viewPointLoc, viewPoint);
glUniform(viewProjectionLoc, viewProjection);
- glUniform(sizesLoc, sizes);
+ if (sizesLoc) {
+ glUniform(sizesLoc, sizes);
+ }
glUniform(viewProjectionsLoc, static_cast<GLint>(viewProjection.size()));
}
diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h
index 009285c..925f82a 100644
--- a/gfx/gl/shadowStenciller.h
+++ b/gfx/gl/shadowStenciller.h
@@ -17,7 +17,7 @@ public:
private:
glFrameBuffer fbo;
Program shadowCaster;
- Program::UniformLocation viewProjectionLoc {shadowCaster, "viewProjection"};
+ Program::RequiredUniformLocation viewProjectionLoc {shadowCaster, "viewProjection"};
glm::mat4 lightDirMat {};
};