diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-12 19:52:58 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-12 19:53:16 +0200 |
commit | d748a3c14e4f5346bc8aff6882c1d082cf3fbd22 (patch) | |
tree | 97325dd0d4e02319177bfb4dc88998401a25ace1 | |
parent | e919e87ffad2f7271b64190d6df358444d000d44 (diff) |
introduce constant for max chunks drawn on screen
-rw-r--r-- | main/draw.cpp | 12 | ||||
-rw-r--r-- | shaders/tile.hpp | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index 028f6ac6..e124389f 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -103,11 +103,13 @@ auto main_impl::get_draw_bounds() const noexcept -> draw_bounds y1 = std::max(y1, p.y); } - constexpr int16_t max = 7, min = -max; - x0 = std::clamp(x0, min, max); - x1 = std::clamp(x1, min, max); - y0 = std::clamp(y0, min, max); - y1 = std::clamp(y1, min, max); + constexpr int16_t maxx = tile_shader::max_screen_tiles.x()/2 - 1, minx = -maxx, + maxy = tile_shader::max_screen_tiles.y()/2 - 1, miny = -maxy; + + x0 = std::clamp(x0, minx, maxx); + x1 = std::clamp(x1, minx, maxx); + y0 = std::clamp(y0, miny, maxy); + y1 = std::clamp(y1, miny, maxy); return {x0, x1, y0, y1}; } diff --git a/shaders/tile.hpp b/shaders/tile.hpp index f1e14c9e..8c65b6fa 100644 --- a/shaders/tile.hpp +++ b/shaders/tile.hpp @@ -37,7 +37,8 @@ struct tile_shader : GL::AbstractShaderProgram template<typename T, typename... Xs> decltype(auto) draw(T&& mesh, Xs&&... xs); - static constexpr float depth_tile_size = 1/(double)(TILE_COUNT * 16 * 16); + static constexpr Vector2s max_screen_tiles{16, 16}; + static constexpr float depth_tile_size = 1/(double)(TILE_COUNT * max_screen_tiles.product()); static constexpr float scenery_depth_offset = 0.25f, character_depth_offset = 0.25f, wall_depth_offset = 0.125f; private: |