diff options
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 |