diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-07 10:29:56 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-07 10:29:56 +0100 |
commit | 672f67c61f275dea196d4c3fbc5ffe7405dc43d3 (patch) | |
tree | 22559814268d289245d26f363708678b02c396c9 /draw/anim.cpp | |
parent | 411164f34aeea4987dae101cf92beb5dfa8c0cd9 (diff) |
wip
Diffstat (limited to 'draw/anim.cpp')
-rw-r--r-- | draw/anim.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/draw/anim.cpp b/draw/anim.cpp new file mode 100644 index 00000000..0b69e4dd --- /dev/null +++ b/draw/anim.cpp @@ -0,0 +1,25 @@ +#include "anim.hpp" +#include "anim-atlas.hpp" +#include "shaders/tile.hpp" + +namespace floormat { + +anim_mesh::anim_mesh() = default; + +std::array<UnsignedShort, 6> anim_mesh::make_index_array() +{ + using u16 = std::uint16_t; + return {{ + (u16)0, (u16)1, (u16)2, + (u16)2, (u16)1, (u16)3, + }}; +} + +void anim_mesh::draw(local_coords xy, const anim_atlas& atlas, const anim_frame& frame) +{ + const auto center_ = Vector3(xy.x, xy.y, 0.f) * TILE_SIZE; + const auto pos = atlas.frame_quad(center_, frame); + _positions_buffer.setSubData(0, pos); +} + +} // namespace floormat |