diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-05 05:05:00 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-05 05:05:00 +0200 |
| commit | d2b9714c5ab557de69a985bdb7e4a0ab0fd95864 (patch) | |
| tree | 053fd6c2808451ce3645c09c53f9163f9da8c4e8 | |
| parent | 32f504c6afb811363b5af0a25fe213d37233c49d (diff) | |
a
| -rw-r--r-- | loader-impl.cpp | 2 | ||||
| -rw-r--r-- | main.cpp | 12 | ||||
| -rw-r--r-- | tile-atlas.cpp | 3 | ||||
| -rw-r--r-- | tile-atlas.hpp | 5 |
4 files changed, 12 insertions, 10 deletions
diff --git a/loader-impl.cpp b/loader-impl.cpp index 23552f77..24d43fdb 100644 --- a/loader-impl.cpp +++ b/loader-impl.cpp @@ -52,7 +52,7 @@ std::shared_ptr<tile_atlas> loader_impl::tile_atlas(const Containers::StringView if (it != atlas_map.end()) return it->second; auto image = tile_texture(name); - auto atlas = std::make_shared<struct tile_atlas>(image, size); + auto atlas = std::make_shared<struct tile_atlas>(name, image, size); atlas_map[name] = atlas; return atlas; } @@ -153,13 +153,14 @@ app::app(const Arguments& arguments): } void app::drawEvent() { - GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); - -#if 1 - GL::defaultFramebuffer.clear(GL::FramebufferClear::Depth); +#if 0 + GL::defaultFramebuffer.clear(GL::FramebufferClear::Color | GL::FramebufferClear::Depth); GL::Renderer::setDepthMask(true); GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::LessOrEqual); GL::Renderer::enable(GL::Renderer::Feature::DepthTest); +#else + GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); + GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::Never); #endif update_window_scale(); @@ -181,9 +182,6 @@ void app::drawEvent() { } #endif - //auto floor1_sampler = _shader.bind_sampler(floor1); - //auto wall_sampler = _shader.bind_sampler(wall1); - #if 1 draw_chunk(_chunk); #endif diff --git a/tile-atlas.cpp b/tile-atlas.cpp index 0d751e2c..1c263dec 100644 --- a/tile-atlas.cpp +++ b/tile-atlas.cpp @@ -4,7 +4,8 @@ namespace Magnum::Examples { -tile_atlas::tile_atlas(const ImageView2D& image, Vector2i dims) : +tile_atlas::tile_atlas(const Containers::StringView& name, const ImageView2D& image, Vector2i dims) : + name_{name}, size_{image.size()}, dims_{dims} { diff --git a/tile-atlas.hpp b/tile-atlas.hpp index 1eb66c29..27ee2a24 100644 --- a/tile-atlas.hpp +++ b/tile-atlas.hpp @@ -3,6 +3,7 @@ #include <Magnum/Magnum.h> #include <Magnum/GL/Texture.h> #include <array> +#include <string> namespace Magnum::Examples { @@ -10,7 +11,7 @@ struct tile_atlas final { using quad = std::array<Vector3, 4>; - tile_atlas(const ImageView2D& img, Vector2i dims); + tile_atlas(const Containers::StringView& name, const ImageView2D& img, Vector2i dims); std::array<Vector2, 4> texcoords_for_id(std::size_t id) const; static constexpr quad floor_quad(Vector3 center, Vector2 size); static constexpr quad wall_quad_N(Vector3 center, Vector3 size); @@ -19,9 +20,11 @@ struct tile_atlas final std::size_t size() const { return (std::size_t)dims_.product(); } Vector2i tile_size() const { return size_ / dims_; } GL::Texture2D& texture() { return tex_; } + std::string name() const { return name_; } private: GL::Texture2D tex_; + std::string name_; Vector2i size_, dims_; }; |
