summaryrefslogtreecommitdiff
path: root/gfx/renderable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/renderable.cpp')
-rw-r--r--gfx/renderable.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/gfx/renderable.cpp b/gfx/renderable.cpp
index 8caab93..4597597 100644
--- a/gfx/renderable.cpp
+++ b/gfx/renderable.cpp
@@ -1,4 +1,39 @@
#include "renderable.h"
+#include "gl_traits.h"
+#include "location.h"
+#include "maths.h"
+
+std::weak_ptr<Renderable::CommonLocationData> Renderable::commonLocationData;
+
+Renderable::CommonLocation::CommonLocation(Location const & location) :
+ position {location.pos, 0}, rotation {location.rot, 0}, rotationMatrix {location.getRotationTransform()}
+{
+}
+
+Renderable::CommonLocation &
+Renderable::CommonLocation ::operator=(Location const & location)
+{
+ position = location.pos || 0;
+ rotation = location.rot || 0.F;
+ rotationMatrix = location.getRotationTransform();
+ return *this;
+}
+
+Renderable::Renderable()
+{
+ if (!(locationData = commonLocationData.lock())) {
+ commonLocationData = locationData = std::make_shared<CommonLocationData>();
+ }
+}
+
+GLuint
+gl_traits<InstanceVertices<Renderable::CommonLocation>::InstanceProxy>::vertexArrayAttribFormat(
+ GLuint vao, GLuint index, GLuint offset)
+{
+ return gl_traits<
+ decltype(InstanceVertices<Renderable::CommonLocation>::InstanceProxy::index)>::vertexArrayAttribFormat(vao,
+ index, offset + offsetof(InstanceVertices<Renderable::CommonLocation>::InstanceProxy, index));
+};
void
Renderable::preFrame(const Frustum &, const Frustum &)