diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-09-15 12:47:58 +0000 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-09-15 12:47:58 +0000 |
commit | 027af044ce8eb233e47cd7134da42f0b53cf2784 (patch) | |
tree | 48476fa4c032d965a6f39be1b2d836df1ea3f979 | |
parent | da0ca2b78fa42fcb8bedc4100074735bbcfc148f (diff) |
a
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | fake-json.hpp | 3 | ||||
m--------- | imgui | 0 | ||||
-rw-r--r-- | shaders/tile-shader.frag | 4 | ||||
-rw-r--r-- | shaders/tile-shader.vert | 2 | ||||
-rw-r--r-- | tile.hpp | 19 |
6 files changed, 20 insertions, 11 deletions
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 <nlohmann/json.hpp> #else diff --git a/imgui b/imgui new file mode 160000 +Subproject 2b1d8e3eafa3204e31aa2de5b42b380d4004293 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; } @@ -3,6 +3,7 @@ #include "hash.hpp" #include "defs.hpp" +#include <concepts> #include <cstddef> #include <tuple> #include <array> @@ -12,10 +13,14 @@ namespace Magnum::Examples { +static constexpr Vector3 TILE_SIZE = { 50, 50, 50 }; + struct tile_image final { std::shared_ptr<texture_atlas> 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<typename F> constexpr inline void foreach_tile(F&& fun) { foreach_tile_<F, chunk&>(fun); } - template<typename F> constexpr inline void foreach_tile(F&& fun) const { foreach_tile_<F, const chunk&>(fun); } + template<typename F> + requires std::invocable<F, tile&, int, int> + constexpr inline void foreach_tile(F&& fun) { foreach_tile_<F, chunk&>(std::forward<F>(fun)); } + + template<typename F> + requires std::invocable<F, const tile&, int, int> + constexpr inline void foreach_tile(F&& fun) const { foreach_tile_<F, const chunk&>(std::forward<F>(fun)); } private: template<typename F, typename Self> 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<Self>(*this).tiles[idx]); + fun(const_cast<Self>(*this).tiles[idx], i, j); } } |