From ba2878c25a47b531539cefbb112ac7147f0cf55d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 28 Dec 2022 15:15:40 +0000 Subject: Setup GL context before doing any shadow render work --- gfx/gl/shadowMapper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gfx/gl/shadowMapper.cpp') diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 76d4390..2586982 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -36,6 +36,12 @@ ShadowMapper::ShadowMapper(const glm::ivec2 & s) : size {s} std::array ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const Camera & camera) const { + glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); + glViewport(0, 0, size.x, size.y); + glClear(GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + glCullFace(GL_FRONT); + auto viewExtents = camera.extentsAtDist(1) + camera.extentsAtDist(1000); const auto extents_minmax = [&viewExtents](auto && comp) { const auto mm = std::minmax_element(viewExtents.begin(), viewExtents.end(), comp); @@ -59,11 +65,6 @@ ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const C fixedPoint.setViewProjection(lightViewProjection); dynamicPoint.setViewProjection(lightViewProjection); - glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); - glViewport(0, 0, size.x, size.y); - glClear(GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - glCullFace(GL_FRONT); scene.shadows(*this); glCullFace(GL_BACK); -- cgit v1.2.3