diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/tile-atlas.cpp | 13 | ||||
| -rw-r--r-- | src/tile-atlas.hpp | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp index ea5a7791..c3b2449c 100644 --- a/src/tile-atlas.cpp +++ b/src/tile-atlas.cpp @@ -20,8 +20,8 @@ tile_atlas::tile_atlas(Containers::StringView name, const ImageView2D& image, Ve .setMinificationFilter(GL::SamplerFilter::Linear) .setMaxAnisotropy(1) .setBorderColor(Color4{1, 0, 0, 1}) - .setStorage(GL::textureFormat(image.format()), image.size()) - .setSubImage({}, image); + .setStorage(1, GL::textureFormat(image.format()), image.size()) + .setSubImage(0, {}, image); } std::array<Vector2, 4> tile_atlas::texcoords_for_id(std::size_t id_) const @@ -31,11 +31,12 @@ std::array<Vector2, 4> tile_atlas::texcoords_for_id(std::size_t id_) const const Vector2ui id = { (UnsignedInt)id_ % dims_[0], (UnsignedInt)id_ / dims_[0] }; const Vector2 p0(id * sz), p1(sz); const auto x0 = p0.x(), x1 = p1.x()-1, y0 = p0.y(), y1 = p1.y()-1; + Vector2 size{size_}; return {{ - { x0+x1, y0+y1 }, // bottom right - { x0+x1, y0 }, // top right - { x0, y0+y1 }, // bottom left - { x0, y0 } // top left + { (x0+x1)/size[0], (y0+y1)/size[1] }, // bottom right + { (x0+x1)/size[0], y0/size[1] }, // top right + { x0/size[0], (y0+y1)/size[1] }, // bottom left + { x0/size[0], y0/size[1] } // top left }}; } diff --git a/src/tile-atlas.hpp b/src/tile-atlas.hpp index 81cfc857..08a090a4 100644 --- a/src/tile-atlas.hpp +++ b/src/tile-atlas.hpp @@ -1,6 +1,6 @@ #pragma once #include <Magnum/Magnum.h> -#include <Magnum/GL/RectangleTexture.h> +#include <Magnum/GL/Texture.h> #include <array> #include <string> @@ -21,11 +21,11 @@ struct tile_atlas final static constexpr std::array<UnsignedShort, 6> indices(std::size_t N); Vector2ui pixel_size() const { return size_; } Vector2ui num_tiles() const { return dims_; } - GL::RectangleTexture& texture() { return tex_; } + GL::Texture2D& texture() { return tex_; } Containers::StringView name() const { return name_; } private: - GL::RectangleTexture tex_; + GL::Texture2D tex_; std::string name_; Vector2ui size_, dims_; }; |
