summaryrefslogtreecommitdiff
path: root/gfx/gl/bufferedLocation.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
commit9ab2aad4aa00afe3373b3a779377fa049459fb4d (patch)
tree18bf013e3be660b0769cd1a601e670eb79355324 /gfx/gl/bufferedLocation.h
parentRename strings.h to something that won't conflict with a system header (diff)
parentTemplated BufferedLocation and single buffer storage for RVC locations (diff)
downloadilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.bz2
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.xz
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.zip
Merge branch 'containers'
Diffstat (limited to 'gfx/gl/bufferedLocation.h')
-rw-r--r--gfx/gl/bufferedLocation.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h
index 6d148cd..8096489 100644
--- a/gfx/gl/bufferedLocation.h
+++ b/gfx/gl/bufferedLocation.h
@@ -1,14 +1,16 @@
#pragma once
-#include "instanceVertices.h"
#include "location.h"
+#include <functional>
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
+#include <tuple>
class BufferedLocation {
public:
- BufferedLocation(InstanceVertices<glm::mat4> &, glm::vec3 = {}, glm::vec3 = {});
- BufferedLocation(InstanceVertices<glm::mat4> &, const Location &);
+ BufferedLocation(glm::vec3 = {}, glm::vec3 = {});
+ BufferedLocation(const Location &);
+ virtual ~BufferedLocation() = default;
BufferedLocation & operator=(const Location &);
@@ -23,8 +25,28 @@ public:
glm::mat4 getTransform() const;
private:
- void updateBuffer();
+ virtual void updateBuffer() = 0;
Location loc;
- InstanceVertices<glm::mat4>::InstanceProxy buffer;
+};
+
+template<typename... Target> class BufferedLocationT : public BufferedLocation {
+public:
+ template<typename... LocationArgs>
+ BufferedLocationT(Target &&... target, LocationArgs &&... t) :
+ BufferedLocation {std::forward<LocationArgs>(t)...}, target {std::forward<Target>(target)...}
+ {
+ updateBuffer();
+ }
+
+ using BufferedLocation::operator=;
+
+private:
+ void
+ updateBuffer() override
+ {
+ std::apply(std::invoke<const Target &...>, target) = getTransform();
+ }
+
+ std::tuple<Target...> target;
};