summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/bufferedLocation.cpp7
-rw-r--r--gfx/gl/bufferedLocation.h18
2 files changed, 13 insertions, 12 deletions
diff --git a/gfx/gl/bufferedLocation.cpp b/gfx/gl/bufferedLocation.cpp
index 6ba8812..412e3ab 100644
--- a/gfx/gl/bufferedLocation.cpp
+++ b/gfx/gl/bufferedLocation.cpp
@@ -1,6 +1,5 @@
#include "bufferedLocation.h"
#include "location.h"
-#include "maths.h"
#include <glm/gtx/transform.hpp>
BufferedLocation::BufferedLocation(Position3D p, Rotation3D r) : BufferedLocation {Location {p, r}} { }
@@ -69,3 +68,9 @@ BufferedLocation::getRotationTransform() const
{
return loc.getRotationTransform();
}
+
+void
+BufferedLocationUpdater::updateBuffer() const
+{
+ onUpdate(this);
+}
diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h
index 8302b3c..a5cd23e 100644
--- a/gfx/gl/bufferedLocation.h
+++ b/gfx/gl/bufferedLocation.h
@@ -4,7 +4,7 @@
#include <functional>
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
-#include <tuple>
+#include <utility>
class BufferedLocation {
public:
@@ -26,16 +26,16 @@ public:
[[nodiscard]] glm::mat4 getRotationTransform() const;
private:
- virtual void updateBuffer() = 0;
+ virtual void updateBuffer() const = 0;
Location loc;
};
-template<typename... Target> class BufferedLocationT : public BufferedLocation {
+class BufferedLocationUpdater : public BufferedLocation {
public:
template<typename... LocationArgs>
- BufferedLocationT(Target &&... target, LocationArgs &&... t) :
- BufferedLocation {std::forward<LocationArgs>(t)...}, target {std::forward<Target>(target)...}
+ BufferedLocationUpdater(std::function<void(const BufferedLocation *)> onUpdate, LocationArgs &&... t) :
+ BufferedLocation {std::forward<LocationArgs>(t)...}, onUpdate {std::move(onUpdate)}
{
updateBuffer();
}
@@ -43,11 +43,7 @@ public:
using BufferedLocation::operator=;
private:
- void
- updateBuffer() override
- {
- std::apply(std::invoke<const Target &...>, target) = getTransform();
- }
+ void updateBuffer() const override;
- std::tuple<Target...> target;
+ std::function<void(const BufferedLocation *)> onUpdate;
};