diff options
-rw-r--r-- | gfx/gl/sceneShader.cpp | 17 | ||||
-rw-r--r-- | gfx/gl/sceneShader.h | 6 | ||||
-rw-r--r-- | ui/sceneRenderer.cpp | 1 |
3 files changed, 23 insertions, 1 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 diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h index 8094e0a..99431f1 100644 --- a/gfx/gl/sceneShader.h +++ b/gfx/gl/sceneShader.h @@ -8,14 +8,17 @@ class SceneShader { class SceneProgram : public Program { public: template<typename... S> - inline SceneProgram(const S &... srcs) : Program {srcs...}, viewProjectionLoc {*this, "viewProjection"} + inline SceneProgram(const S &... srcs) : + Program {srcs...}, viewProjectionLoc {*this, "viewProjection"}, viewPortLoc {*this, "viewPort"} { } void setViewProjection(const glm::mat4 &) const; + void setViewPort(const glm::ivec4 &) const; private: RequiredUniformLocation viewProjectionLoc; + UniformLocation viewPortLoc; }; class BasicProgram : public SceneProgram { @@ -52,4 +55,5 @@ public: AbsolutePosProgram landmass, absolute; void setViewProjection(const glm::mat4 & viewProjection) const; + void setViewPort(const glm::ivec4 & viewPort) const; }; diff --git a/ui/sceneRenderer.cpp b/ui/sceneRenderer.cpp index ffcc8e3..dc8e440 100644 --- a/ui/sceneRenderer.cpp +++ b/ui/sceneRenderer.cpp @@ -16,6 +16,7 @@ SceneRenderer::SceneRenderer(glm::ivec2 s, GLuint o) : camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(s), 0.1F, 10000.0F}, size {s}, output {o}, lighting {lightingShader_vs, lightingShader_fs} { + shader.setViewPort({0, 0, size.x, size.y}); glBindVertexArray(displayVAO); glBindBuffer(GL_ARRAY_BUFFER, displayVBO); glBufferData(GL_ARRAY_BUFFER, sizeof(displayVAOdata), nullptr, GL_STATIC_DRAW); |