diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-29 00:18:02 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-29 00:18:02 +0000 |
commit | a18ea136a540d271687fd88831bc14394107dba5 (patch) | |
tree | 05eb6b5a4a9e77240e572c62b5a1d455008e966e /gfx/gl/shadowMapper.cpp | |
parent | Geometry shader for single pass shadow maps (diff) | |
download | ilt-a18ea136a540d271687fd88831bc14394107dba5.tar.bz2 ilt-a18ea136a540d271687fd88831bc14394107dba5.tar.xz ilt-a18ea136a540d271687fd88831bc14394107dba5.zip |
Merge common parts of shadow programs into a base class
Diffstat (limited to 'gfx/gl/shadowMapper.cpp')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 7770c9d..4141278 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -18,8 +18,7 @@ #include <vector> ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : - fixedPoint {shadowFixedPoint_vs, commonShadowPoint_gs}, - dynamicPointInst {shadowDynamicPointInst_vs, commonShadowPoint_gs}, size {s} + fixedPoint {shadowFixedPoint_vs}, dynamicPointInst {shadowDynamicPointInst_vs}, size {s} { glBindTexture(GL_TEXTURE_2D_ARRAY, depthMap); glTexImage3D( @@ -169,19 +168,19 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const return out; } -ShadowMapper::FixedPoint::FixedPoint(const Shader & vs, const Shader & gs) : - Program {vs, gs}, viewProjectionLoc {{ - {*this, "viewProjection[0]"}, - {*this, "viewProjection[1]"}, - {*this, "viewProjection[2]"}, - {*this, "viewProjection[3]"}, - }}, +ShadowMapper::ShadowProgram::ShadowProgram(const Shader & vs) : + Program {vs, commonShadowPoint_gs}, viewProjectionLoc {{ + {*this, "viewProjection[0]"}, + {*this, "viewProjection[1]"}, + {*this, "viewProjection[2]"}, + {*this, "viewProjection[3]"}, + }}, viewProjectionsLoc {*this, "viewProjections"}, viewPointLoc {*this, "viewPoint"} { } void -ShadowMapper::FixedPoint::setViewPoint(const GlobalPosition3D viewPoint, size_t n) const +ShadowMapper::ShadowProgram::setViewPoint(const GlobalPosition3D viewPoint, size_t n) const { use(); glUniform(viewPointLoc, viewPoint); @@ -189,43 +188,23 @@ ShadowMapper::FixedPoint::setViewPoint(const GlobalPosition3D viewPoint, size_t } void -ShadowMapper::FixedPoint::setViewProjection(const glm::mat4 & viewProjection, size_t n) const +ShadowMapper::ShadowProgram::setViewProjection(const glm::mat4 & viewProjection, size_t n) const { use(); glUniform(viewProjectionLoc[n], viewProjection); } void -ShadowMapper::FixedPoint::use() const +ShadowMapper::ShadowProgram::use() const { glUseProgram(*this); } -ShadowMapper::DynamicPoint::DynamicPoint() : - Program {shadowDynamicPoint_vs, commonShadowPoint_gs}, viewProjectionLoc {{ - {*this, "viewProjection[0]"}, - {*this, "viewProjection[1]"}, - {*this, "viewProjection[2]"}, - {*this, "viewProjection[3]"}, - }}, - viewProjectionsLoc {*this, "viewProjections"}, viewPointLoc {*this, "viewPoint"}, modelLoc {*this, "model"}, - modelPosLoc {*this, "modelPos"} -{ -} - -void -ShadowMapper::DynamicPoint::setViewPoint(const GlobalPosition3D viewPoint, size_t n) const -{ - glUseProgram(*this); - glUniform(viewPointLoc, viewPoint); - glUniform(viewProjectionsLoc, static_cast<GLint>(n)); -} +ShadowMapper::FixedPoint::FixedPoint(const Shader & vs) : ShadowProgram {vs} { } -void -ShadowMapper::DynamicPoint::setViewProjection(const glm::mat4 & viewProjection, size_t n) const +ShadowMapper::DynamicPoint::DynamicPoint() : + ShadowProgram {shadowDynamicPoint_vs}, modelLoc {*this, "model"}, modelPosLoc {*this, "modelPos"} { - glUseProgram(*this); - glUniform(viewProjectionLoc[n], viewProjection); } void |