summaryrefslogtreecommitdiff
path: root/gfx/gl/sceneShader.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-11-23 17:53:32 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-11-23 18:38:46 +0000
commit5b415937c6c7097373bfd754b5699a9946c2cd16 (patch)
tree8f9978bdd0670b3f70c2775ad91bfaff46f873bf /gfx/gl/sceneShader.cpp
parentRename setView to setViewProjection to avoid ambiguity (diff)
downloadilt-5b415937c6c7097373bfd754b5699a9946c2cd16.tar.bz2
ilt-5b415937c6c7097373bfd754b5699a9946c2cd16.tar.xz
ilt-5b415937c6c7097373bfd754b5699a9946c2cd16.zip
Support setting a viewPort uniform for those shaders which need it
Diffstat (limited to 'gfx/gl/sceneShader.cpp')
-rw-r--r--gfx/gl/sceneShader.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp
index b20b1db..0b0c530 100644
--- a/gfx/gl/sceneShader.cpp
+++ b/gfx/gl/sceneShader.cpp
@@ -25,12 +25,29 @@ SceneShader::setViewProjection(const glm::mat4 & viewProjection) const
}
void
+SceneShader::setViewPort(const glm::ivec4 & viewPort) const
+{
+ for (const auto & prog : std::array<const SceneProgram *, 4> {&basic, &water, &landmass, &absolute}) {
+ prog->setViewPort(viewPort);
+ }
+}
+
+void
SceneShader::SceneProgram::setViewProjection(const glm::mat4 & viewProjection) const
{
glUseProgram(*this);
glUniformMatrix4fv(viewProjectionLoc, 1, GL_FALSE, glm::value_ptr(viewProjection));
}
+void
+SceneShader::SceneProgram::setViewPort(const glm::ivec4 & viewPort) const
+{
+ if (viewPortLoc >= 0) {
+ glUseProgram(*this);
+ glUniform4iv(viewPortLoc, 1, glm::value_ptr(viewPort));
+ }
+}
+
SceneShader::BasicProgram::BasicProgram() : SceneProgram {basicShader_vs, basicShader_fs}, modelLoc {*this, "model"} { }
void