summaryrefslogtreecommitdiffhomepage
path: root/draw/anim.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-07 10:29:56 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-07 10:29:56 +0100
commit672f67c61f275dea196d4c3fbc5ffe7405dc43d3 (patch)
tree22559814268d289245d26f363708678b02c396c9 /draw/anim.hpp
parent411164f34aeea4987dae101cf92beb5dfa8c0cd9 (diff)
wip
Diffstat (limited to 'draw/anim.hpp')
-rw-r--r--draw/anim.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/draw/anim.hpp b/draw/anim.hpp
new file mode 100644
index 00000000..60a4e839
--- /dev/null
+++ b/draw/anim.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "local-coords.hpp"
+#include <array>
+#include <Corrade/Containers/ArrayViewStl.h>
+#include <Magnum/Magnum.h>
+#include <Magnum/Math/Vector2.h>
+#include <Magnum/Math/Vector3.h>
+#include <Magnum/GL/Mesh.h>
+#include <Magnum/GL/Buffer.h>
+
+namespace floormat::Serialize { struct anim_atlas; struct anim_frame; }
+
+namespace floormat {
+
+struct anim_atlas;
+using anim_frame = Serialize::anim_frame;
+
+struct anim_mesh final
+{
+ anim_mesh();
+ void draw(local_coords pos, const anim_atlas& atlas, const anim_frame& frame);
+
+private:
+ struct vertex_data final { Vector2 texcoords; };
+ using quad_data = std::array<vertex_data, 4>;
+
+ static std::array<UnsignedShort, 6> make_index_array();
+
+
+ GL::Mesh _mesh;
+ GL::Buffer _vertex_buffer{quad_data{}, Magnum::GL::BufferUsage::DynamicDraw},
+ _index_buffer{make_index_array()}, _positions_buffer{quad_data{}};
+};
+
+} // namespace floormat