From d2b9714c5ab557de69a985bdb7e4a0ab0fd95864 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 5 Oct 2022 05:05:00 +0200 Subject: a --- loader-impl.cpp | 2 +- main.cpp | 12 +++++------- tile-atlas.cpp | 3 ++- 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 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(image, size); + auto atlas = std::make_shared(name, image, size); atlas_map[name] = atlas; return atlas; } diff --git a/main.cpp b/main.cpp index fec93cec..47a41118 100644 --- a/main.cpp +++ b/main.cpp @@ -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 #include #include +#include namespace Magnum::Examples { @@ -10,7 +11,7 @@ struct tile_atlas final { using quad = std::array; - tile_atlas(const ImageView2D& img, Vector2i dims); + tile_atlas(const Containers::StringView& name, const ImageView2D& img, Vector2i dims); std::array 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_; }; -- cgit v1.2.3