diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-28 15:15:40 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-28 15:15:40 +0000 |
commit | ba2878c25a47b531539cefbb112ac7147f0cf55d (patch) | |
tree | 3e34ff0a8de2a4ecf3ea104a023f91b3769cb4e1 /gfx/gl | |
parent | Initial support for multiple shadow maps in the same texture (diff) | |
download | ilt-ba2878c25a47b531539cefbb112ac7147f0cf55d.tar.bz2 ilt-ba2878c25a47b531539cefbb112ac7147f0cf55d.tar.xz ilt-ba2878c25a47b531539cefbb112ac7147f0cf55d.zip |
Setup GL context before doing any shadow render work
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
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<glm::mat4x4, 1> 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); |