diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-18 21:41:15 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-18 21:41:15 +0000 |
commit | 0cea9c894eb514c70ff7c8edd0ccfa59c1f07a1a (patch) | |
tree | 57f1f7b55b76402196e46638d8a223397170c713 /ui/sceneRenderer.cpp | |
parent | Rename rdiv to ratio and add a vec2 override (diff) | |
download | ilt-0cea9c894eb514c70ff7c8edd0ccfa59c1f07a1a.tar.bz2 ilt-0cea9c894eb514c70ff7c8edd0ccfa59c1f07a1a.tar.xz ilt-0cea9c894eb514c70ff7c8edd0ccfa59c1f07a1a.zip |
Save size of output in SceneRender and set viewport accordingly
Diffstat (limited to 'ui/sceneRenderer.cpp')
-rw-r--r-- | ui/sceneRenderer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ui/sceneRenderer.cpp b/ui/sceneRenderer.cpp index 6986fb6..6a68ac6 100644 --- a/ui/sceneRenderer.cpp +++ b/ui/sceneRenderer.cpp @@ -11,8 +11,8 @@ static constexpr std::array<glm::vec4, 4> displayVAOdata {{ {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, -1.0f, 1.0f, 0.0f}, }}; -SceneRenderer::SceneRenderer(glm::ivec2 size, GLuint o) : - camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(size), 0.1F, 10000.0F}, output {o}, +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} { glBindVertexArray(displayVAO); @@ -24,7 +24,7 @@ SceneRenderer::SceneRenderer(glm::ivec2 size, GLuint o) : glBindFramebuffer(GL_FRAMEBUFFER, gBuffer); const auto configuregdata - = [size](const GLuint data, const GLint format, const GLenum type, const GLenum attachment) { + = [this](const GLuint data, const GLint format, const GLenum type, const GLenum attachment) { glBindTexture(GL_TEXTURE_2D, data); glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, GL_RGBA, type, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -53,6 +53,8 @@ void SceneRenderer::render(std::function<void(const SceneShader &)> content) const { shader.setView(camera.GetViewProjection()); + glViewport(0, 0, size.x, size.y); + // Geometry pass glEnable(GL_BLEND); glEnable(GL_CULL_FACE); @@ -62,9 +64,9 @@ SceneRenderer::render(std::function<void(const SceneShader &)> content) const glBindFramebuffer(GL_FRAMEBUFFER, gBuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); content(shader); - glBindFramebuffer(GL_FRAMEBUFFER, output); // Lighting pass + glBindFramebuffer(GL_FRAMEBUFFER, output); glDisable(GL_BLEND); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); |