From 027af044ce8eb233e47cd7134da42f0b53cf2784 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 15 Sep 2022 12:47:58 +0000 Subject: a --- .gitmodules | 3 +++ fake-json.hpp | 3 ++- imgui | 1 + shaders/tile-shader.frag | 4 +--- shaders/tile-shader.vert | 2 -- tile.hpp | 19 ++++++++++++++----- 6 files changed, 21 insertions(+), 11 deletions(-) create mode 160000 imgui diff --git a/.gitmodules b/.gitmodules index 115c205a..3cc0904d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "json"] path = json url = https://github.com/nlohmann/json.git +[submodule "imgui"] + path = imgui + url = https://github.com/ocornut/imgui.git diff --git a/fake-json.hpp b/fake-json.hpp index 5965fbbc..57943d37 100644 --- a/fake-json.hpp +++ b/fake-json.hpp @@ -1,5 +1,6 @@ #pragma once -#ifndef __CLION_IDE__ +//#define GAME_REAL_JSON +#if !defined __CLION_IDE__ || defined GAME_REAL_JSON # include #else diff --git a/imgui b/imgui new file mode 160000 index 00000000..2b1d8e3e --- /dev/null +++ b/imgui @@ -0,0 +1 @@ +Subproject commit 2b1d8e3eafa3204e31aa2de5b42b380d40042930 diff --git a/shaders/tile-shader.frag b/shaders/tile-shader.frag index 5d40df69..1cd1cf3d 100644 --- a/shaders/tile-shader.frag +++ b/shaders/tile-shader.frag @@ -4,12 +4,10 @@ layout(location = 2) uniform sampler2D textureData; layout(location = 1) uniform float y_scale; in vec2 interpolatedTextureCoordinates; -in float interpolated_frag_depth; out vec4 fragmentColor; void main() { fragmentColor.rgb = texture(textureData, interpolatedTextureCoordinates).rgb; - fragmentColor.a = 1.0; - gl_FragDepth = interpolated_frag_depth * y_scale; + fragmentColor.a = 1; } diff --git a/shaders/tile-shader.vert b/shaders/tile-shader.vert index 6241977b..239f4b07 100644 --- a/shaders/tile-shader.vert +++ b/shaders/tile-shader.vert @@ -6,7 +6,6 @@ layout(location = 0) uniform vec2 scale; layout(location = 3) uniform vec2 offset; out vec2 interpolatedTextureCoordinates; -out float interpolated_frag_depth; void main() { interpolatedTextureCoordinates = textureCoordinates; @@ -14,5 +13,4 @@ void main() { float cx = 2/scale.x, cy = 2/scale.y; float x = position.y, y = position.x, z = position.z; gl_Position = vec4((x-y+offset.x)*cx, (x+y+z*2)*cx*0.75-offset.y*cx, 0, 1); - interpolated_frag_depth = -position.z; } diff --git a/tile.hpp b/tile.hpp index de92ba5e..47876f3c 100644 --- a/tile.hpp +++ b/tile.hpp @@ -3,6 +3,7 @@ #include "hash.hpp" #include "defs.hpp" +#include #include #include #include @@ -12,10 +13,14 @@ namespace Magnum::Examples { +static constexpr Vector3 TILE_SIZE = { 50, 50, 50 }; + struct tile_image final { std::shared_ptr atlas; std::uint8_t variant = 0xff; + + explicit operator bool() const noexcept { return !!atlas; } }; struct tile final @@ -26,7 +31,7 @@ struct tile final tile_image ground_image_, wall_west_, wall_north_; pass_mode passability_ = pass_shoot_through; - explicit operator bool() const noexcept { return !!ground_image_.atlas; } + //explicit operator bool() const noexcept { return !!ground_image_.atlas; } }; struct local_coords final { @@ -67,8 +72,13 @@ struct chunk final constexpr tile& operator[](std::size_t i); constexpr const tile& operator[](std::size_t i) const; - template constexpr inline void foreach_tile(F&& fun) { foreach_tile_(fun); } - template constexpr inline void foreach_tile(F&& fun) const { foreach_tile_(fun); } + template + requires std::invocable + constexpr inline void foreach_tile(F&& fun) { foreach_tile_(std::forward(fun)); } + + template + requires std::invocable + constexpr inline void foreach_tile(F&& fun) const { foreach_tile_(std::forward(fun)); } private: template constexpr void foreach_tile_(F&& fun); @@ -107,8 +117,7 @@ constexpr void chunk::foreach_tile_(F&& fun) for (unsigned i = 0; i < N; i++) { unsigned idx = j*N + i; - if (tiles[idx]) - fun(*static_cast(*this).tiles[idx]); + fun(const_cast(*this).tiles[idx], i, j); } } -- cgit v1.2.3