summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anim-atlas.cpp14
-rw-r--r--src/anim-atlas.hpp3
-rw-r--r--src/loader.hpp13
-rw-r--r--src/scenery.hpp11
4 files changed, 32 insertions, 9 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index 65b0038c..1aadab21 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -1,5 +1,6 @@
#include "anim-atlas.hpp"
#include <Corrade/Containers/StringStlView.h>
+#include <Magnum/GL/TextureFormat.h>
namespace floormat {
@@ -28,10 +29,17 @@ decltype(anim_atlas::_group_indices) anim_atlas::make_group_indices(const anim_i
}
anim_atlas::anim_atlas() noexcept = default;
-anim_atlas::anim_atlas(StringView name, GL::Texture2D&& tex, anim_info info) noexcept :
- _tex{std::move(tex)}, _name{name},
+anim_atlas::anim_atlas(StringView name, const ImageView2D& image, anim_info info) noexcept :
+ _name{name},
_info{std::move(info)}, _group_indices{make_group_indices(_info)}
{
+ _tex.setWrapping(GL::SamplerWrapping::ClampToEdge)
+ .setMagnificationFilter(GL::SamplerFilter::Nearest)
+ .setMinificationFilter(GL::SamplerFilter::Linear)
+ .setMaxAnisotropy(1)
+ .setBorderColor(Color4{1, 0, 0, 1})
+ .setStorage(1, GL::textureFormat(image.format()), image.size())
+ .setSubImage(0, {}, image);
}
anim_atlas::~anim_atlas() noexcept = default;
@@ -74,4 +82,6 @@ auto anim_atlas::frame_texcoords(const anim_frame& frame) const noexcept -> texc
}};
}
+
+
} // namespace floormat
diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp
index 4e73f9c8..a7553c5c 100644
--- a/src/anim-atlas.hpp
+++ b/src/anim-atlas.hpp
@@ -5,6 +5,7 @@
#include <array>
#include <Corrade/Containers/String.h>
#include <Magnum/Math/Vector2.h>
+#include <Magnum/ImageView.h>
#include <Magnum/GL/Texture.h>
namespace floormat {
@@ -17,7 +18,7 @@ struct anim_atlas final
using texcoords = std::array<Vector2, 4>;
anim_atlas() noexcept;
- anim_atlas(StringView name, GL::Texture2D&& tex, anim_info info) noexcept;
+ anim_atlas(StringView name, const ImageView2D& tex, anim_info info) noexcept;
~anim_atlas() noexcept;
anim_atlas(anim_atlas&&) noexcept;
diff --git a/src/loader.hpp b/src/loader.hpp
index 9dae4b11..0aaaa42e 100644
--- a/src/loader.hpp
+++ b/src/loader.hpp
@@ -1,20 +1,25 @@
#pragma once
#include <memory>
+#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Trade/ImageData.h>
-#define IMAGE_PATH "share/floormat/images/"
+#define FM_IMAGE_PATH "share/floormat/images/"
+#define FM_ANIM_PATH "share/floormat/anim/"
namespace floormat {
struct tile_atlas;
+struct anim_atlas;
struct loader_
{
- virtual StringView shader(Containers::StringView filename) = 0;
- virtual Trade::ImageData2D tile_texture(Containers::StringView filename) = 0;
- virtual std::shared_ptr<struct tile_atlas> tile_atlas(Containers::StringView filename, Vector2ub size) = 0;
+ virtual StringView shader(StringView filename) = 0;
+ virtual Trade::ImageData2D tile_texture(StringView filename) = 0;
+ virtual std::shared_ptr<struct tile_atlas> tile_atlas(StringView filename, Vector2ub size) = 0;
+ virtual ArrayView<String> anim_atlas_list() = 0;
+ virtual std::shared_ptr<struct anim_atlas> anim_atlas(StringView name) = 0;
static void destroy();
loader_(const loader_&) = delete;
diff --git a/src/scenery.hpp b/src/scenery.hpp
index 731b999b..1b0dc673 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -13,10 +13,17 @@ struct scenery final
{
using frame_t = std::uint16_t;
- frame_t frame : 13 = 0;
- rotation r : 3 = rotation::N;
+ frame_t frame : 12 = (1 << 12) - 1;
+ rotation r : 4 = rotation::N;
+
+ constexpr operator bool() const noexcept;
};
static_assert(sizeof(scenery) == sizeof(std::uint16_t));
+constexpr scenery::operator bool() const noexcept
+{
+ return frame == (1 << 13) - 1;
+}
+
} // namespace floormat