From 4e005a393a5f8295d6498410d5ba7635977811e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Nov 2023 16:44:13 +0100 Subject: a --- src/wall-atlas.cpp | 18 ++++++++++++++++++ src/wall-atlas.hpp | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wall-atlas.cpp b/src/wall-atlas.cpp index 96758983..402d5d66 100644 --- a/src/wall-atlas.cpp +++ b/src/wall-atlas.cpp @@ -21,6 +21,23 @@ wall_atlas::wall_atlas(Info info, const ImageView2D& image, _info{ std::move(info) }, _direction_to_Direction_array_index{ direction_to_DirArrayIndex } { + const auto frame_count = frames.size(); + for (const Direction& dir : directions) + { + for (auto [_str, _group, tag] : Direction::members) + { + const auto* g = group(dir, tag); + if (!g) + continue; + fm_assert(g->count > 0 == g->index < (uint32_t)-1); + if (g->count > 0) + { + fm_assert(g->index < frame_count); + fm_assert(g->index + g->count <= frame_count); + } + } + } + _texture.setLabel(_info.name) .setWrapping(GL::SamplerWrapping::ClampToEdge) .setMagnificationFilter(GL::SamplerFilter::Nearest) @@ -91,6 +108,7 @@ auto wall_atlas::direction(size_t dir) const -> const Direction* uint8_t wall_atlas::direction_count() const { return (uint8_t)_dir_array.size(); } auto wall_atlas::raw_frame_array() const -> ArrayView { return _frame_array; } auto wall_atlas::info() const -> const Info& { return _info; } +GL::Texture2D& wall_atlas::texture() { fm_debug_assert(_texture.id()); return _texture; } StringView wall_atlas::name() const { return _info.name; } size_t wall_atlas::enum_to_index(enum rotation r) diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index 3d97c0e7..65b15183 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -95,7 +95,7 @@ class wall_atlas final Array _dir_array; Array _frame_array; Info _info; - GL::Texture2D _texture; + GL::Texture2D _texture{NoCreate}; std::array _direction_to_Direction_array_index; Direction* get_Direction(Direction_ num) const; @@ -104,7 +104,6 @@ public: fm_DECLARE_DELETED_MOVE_ASSIGNMENT(wall_atlas); wall_atlas() noexcept; ~wall_atlas() noexcept; - wall_atlas(Info info, const ImageView2D& image, Array frames, Array directions, std::array direction_to_DirArrayIndex); @@ -118,6 +117,7 @@ public: ArrayView frames(const Group& a) const; ArrayView raw_frame_array() const; const Info& info() const; + GL::Texture2D& texture(); static size_t enum_to_index(enum rotation x); -- cgit v1.2.3