diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-13 15:44:09 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-14 23:46:14 +0000 |
commit | b27c66cb2aaa897e4c18b3be3a0b121b6695e7e1 (patch) | |
tree | dec28585a610de4618d392fe72fd4e4968c2f636 /ui/sceneRenderer.cpp | |
parent | Pass the output framebuffer id to scene renderer (diff) | |
download | ilt-b27c66cb2aaa897e4c18b3be3a0b121b6695e7e1.tar.bz2 ilt-b27c66cb2aaa897e4c18b3be3a0b121b6695e7e1.tar.xz ilt-b27c66cb2aaa897e4c18b3be3a0b121b6695e7e1.zip |
Refactor shading output components
SceneShader and Camera are part of SceneRenderer
Diffstat (limited to 'ui/sceneRenderer.cpp')
-rw-r--r-- | ui/sceneRenderer.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ui/sceneRenderer.cpp b/ui/sceneRenderer.cpp index 9432710..852f64c 100644 --- a/ui/sceneRenderer.cpp +++ b/ui/sceneRenderer.cpp @@ -1,4 +1,5 @@ #include "sceneRenderer.h" +#include "maths.h" #include <gfx/gl/shaders/fs-lightingShader.h> #include <gfx/gl/shaders/vs-lightingShader.h> #include <glm/gtc/type_ptr.hpp> @@ -10,7 +11,9 @@ 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) : output {o}, lighting {lightingShader_vs, lightingShader_fs} +SceneRenderer::SceneRenderer(glm::ivec2 size, GLuint o) : + camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, rdiv(size.x, size.y), 0.1F, 10000.0F}, output {o}, + lighting {lightingShader_vs, lightingShader_fs} { glBindVertexArray(displayVAO); glBindBuffer(GL_ARRAY_BUFFER, displayVBO); @@ -47,8 +50,9 @@ SceneRenderer::SceneRenderer(glm::ivec2 size, GLuint o) : output {o}, lighting { } void -SceneRenderer::render(std::function<void()> content) const +SceneRenderer::render(std::function<void(const SceneShader &)> content) const { + shader.setView(camera.GetViewProjection()); // Geometry pass glEnable(GL_BLEND); glEnable(GL_CULL_FACE); @@ -57,7 +61,7 @@ SceneRenderer::render(std::function<void()> content) const glEnable(GL_DEPTH_TEST); glBindFramebuffer(GL_FRAMEBUFFER, gBuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - content(); + content(shader); glBindFramebuffer(GL_FRAMEBUFFER, output); // Lighting pass |