summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-14 15:01:26 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-14 15:01:26 +0200
commit191b4f734b46f6fe6d54fd4eb9ac9f69bf46b727 (patch)
tree2fd6a98c160aaecebbbaf3a65edeb0ea43888fe9
parent6956c790db1c0d3a1fab8ff811ecda7d26e5a764 (diff)
shader: make depth offset constants constexpr
-rw-r--r--shaders/shader.cpp7
-rw-r--r--shaders/shader.hpp9
2 files changed, 6 insertions, 10 deletions
diff --git a/shaders/shader.cpp b/shaders/shader.cpp
index 28b7159c..0c66bef2 100644
--- a/shaders/shader.cpp
+++ b/shaders/shader.cpp
@@ -78,11 +78,4 @@ float tile_shader::depth_value(const local_coords& xy, float offset) noexcept
return ((float)xy.x + (float)xy.y + offset) * depth_tile_size;
}
-const Vector2s tile_shader::max_screen_tiles = {8, 8};
-const float tile_shader::character_depth_offset = 1 + 1./64;
-const float tile_shader::scenery_depth_offset = 1 + 1./64;
-const float tile_shader::wall_depth_offset = 1;
-const float tile_shader::z_depth_offset = 1 + 2./64;
-const float tile_shader::depth_tile_size = 1/(double)(TILE_MAX_DIM * 2 * max_screen_tiles.product());
-
} // namespace floormat
diff --git a/shaders/shader.hpp b/shaders/shader.hpp
index 280850b9..a8f778da 100644
--- a/shaders/shader.hpp
+++ b/shaders/shader.hpp
@@ -37,9 +37,12 @@ struct tile_shader : GL::AbstractShaderProgram
template<typename T, typename... Xs>
decltype(auto) draw(T&& mesh, Xs&&... xs);
- static const Vector2s max_screen_tiles;
- static const float depth_tile_size;
- static const float character_depth_offset, scenery_depth_offset, wall_depth_offset, z_depth_offset;
+ static constexpr Vector2s max_screen_tiles = {8, 8};
+ static constexpr float character_depth_offset = 1 + 1./64;
+ static constexpr float scenery_depth_offset = 1 + 1./64;
+ static constexpr float wall_depth_offset = 1;
+ static constexpr float z_depth_offset = 1 + 2./64;
+ static constexpr float depth_tile_size = 1/(double)(TILE_MAX_DIM * 2 * max_screen_tiles.product());
private:
void _draw();