summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/shadowMapper.cpp49
-rw-r--r--gfx/gl/shadowMapper.h17
2 files changed, 23 insertions, 43 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
diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h
index 421e6a5..4f81e58 100644
--- a/gfx/gl/shadowMapper.h
+++ b/gfx/gl/shadowMapper.h
@@ -24,9 +24,10 @@ public:
[[nodiscard]] Definitions update(const SceneProvider &, const Direction3D & direction, const Camera &) const;
- class FixedPoint : public Program {
+ class ShadowProgram : public Program {
public:
- FixedPoint(const Shader & vs, const Shader & gs);
+ explicit ShadowProgram(const Shader & vs);
+
void setViewPoint(const GlobalPosition3D, size_t n) const;
void setViewProjection(const glm::mat4 &, size_t n) const;
void use() const;
@@ -37,18 +38,18 @@ public:
RequiredUniformLocation viewPointLoc;
};
- class DynamicPoint : public Program {
+ class FixedPoint : public ShadowProgram {
+ public:
+ explicit FixedPoint(const Shader & vs);
+ };
+
+ class DynamicPoint : public ShadowProgram {
public:
DynamicPoint();
- void setViewPoint(const GlobalPosition3D, size_t n) const;
- void setViewProjection(const glm::mat4 &, size_t n) const;
void use(const Location &) const;
void setModel(const Location &) const;
private:
- std::array<RequiredUniformLocation, 4> viewProjectionLoc;
- RequiredUniformLocation viewProjectionsLoc;
- RequiredUniformLocation viewPointLoc;
RequiredUniformLocation modelLoc;
RequiredUniformLocation modelPosLoc;
};