From b7b5db10f9b99815d8a32fafde27c0c51f7e26d3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 2 Jan 2023 17:26:23 +0000 Subject: Single helper for rendering the fullscreen quad --- gfx/gl/sceneRenderer.cpp | 16 ++++++++++------ gfx/gl/sceneRenderer.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'gfx') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index ee6d927..8b299ad 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -96,9 +96,7 @@ SceneRenderer::render(const SceneProvider & scene) const glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, gIllumination); lighting.use(); - glBindVertexArray(displayVAO); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); + renderQuad(); } void @@ -119,12 +117,18 @@ SceneRenderer::setDirectionalLight( glViewport(0, 0, size.x, size.y); dirLight.use(); dirLight.setDirectionalLight(colour, direction, lvp.projections, lvp.regions); - glBindVertexArray(displayVAO); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); + renderQuad(); } } +void +SceneRenderer::renderQuad() const +{ + glBindVertexArray(displayVAO); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); +} + SceneRenderer::DirectionalLightProgram::DirectionalLightProgram() : Program {lightingShader_vs, directionalLight_fs}, directionLoc {*this, "lightDirection"}, colourLoc {*this, "lightColour"}, lightViewProjectionLoc {*this, "lightViewProjection"}, diff --git a/gfx/gl/sceneRenderer.h b/gfx/gl/sceneRenderer.h index 28acc3b..5f6a36e 100644 --- a/gfx/gl/sceneRenderer.h +++ b/gfx/gl/sceneRenderer.h @@ -20,6 +20,8 @@ public: Camera camera; private: + void renderQuad() const; + glm::ivec2 size; GLuint output; glFrameBuffer gBuffer; -- cgit v1.2.3