summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-12 16:44:13 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-12 16:44:13 +0100
commit4e005a393a5f8295d6498410d5ba7635977811e3 (patch)
treeb3b8d6dd2b9dcb08cd7d02e64a9fd31a77360b22 /src
parent664cfa76b05756cb5ee22cf9bfe463822aeae6a3 (diff)
a
Diffstat (limited to 'src')
-rw-r--r--src/wall-atlas.cpp18
-rw-r--r--src/wall-atlas.hpp4
2 files changed, 20 insertions, 2 deletions
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<const Frame> { 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<Direction> _dir_array;
Array<Frame> _frame_array;
Info _info;
- GL::Texture2D _texture;
+ GL::Texture2D _texture{NoCreate};
std::array<DirArrayIndex, 4> _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<Frame> frames, Array<Direction> directions,
std::array<DirArrayIndex, 4> direction_to_DirArrayIndex);
@@ -118,6 +117,7 @@ public:
ArrayView<const Frame> frames(const Group& a) const;
ArrayView<const Frame> raw_frame_array() const;
const Info& info() const;
+ GL::Texture2D& texture();
static size_t enum_to_index(enum rotation x);