diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-18 01:55:30 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-18 01:55:30 +0200 |
commit | aebec6e9b095149252bf1e4642c211ae98efdf84 (patch) | |
tree | dfb9919de3fa8bb1a7ff99c9cb3fcbf17186e7c2 /main/draw.cpp | |
parent | 2ce80cb4a85cc47dc10f0b70839b2d0f2381cca8 (diff) |
a
Diffstat (limited to 'main/draw.cpp')
-rw-r--r-- | main/draw.cpp | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index b7dd420a..18319f95 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -41,42 +41,14 @@ void app::drawEvent() { timeline.nextFrame(); } -std::array<std::int16_t, 4> app::get_draw_bounds() const noexcept -{ - using limits = std::numeric_limits<std::int16_t>; - constexpr auto MIN = limits::min(), MAX = limits::max(); - std::int16_t minx = MAX, maxx = MIN, miny = MAX, maxy = MIN; - { - auto fn = [&](std::int32_t x, std::int32_t y) { - const auto pos = pixel_to_tile(Vector2(x, y)).chunk(); - minx = std::min(minx, pos.x); - maxx = std::max(maxx, pos.x); - miny = std::min(miny, pos.y); - maxy = std::max(maxy, pos.y); - }; - const auto sz = windowSize(); - const auto x = sz[0]-1, y = sz[1]-1; - fn(0, 0); - fn(x, 0); - fn(0, y); - fn(x, y); - } - return { - std::int16_t(minx), std::int16_t(maxx), - std::int16_t(miny), std::int16_t(maxy), - }; -} - void app::draw_world() { #if 0 _floor_mesh.draw(_shader, *_world[chunk_coords{0, 0}]); _wall_mesh.draw(_shader, *_world[chunk_coords{0, 0}]); #else - auto [minx, maxx, miny, maxy] = get_draw_bounds(); - - printf("%hd %hd -> %hd %hd\n", minx, miny, maxx, maxy); - fflush(stdout); + auto foo = get_draw_bounds(); + auto [minx, maxx, miny, maxy] = foo; for (std::int16_t y = miny; y <= maxy; y++) for (std::int16_t x = minx; x <= maxx; x++) @@ -85,7 +57,9 @@ void app::draw_world() make_test_chunk(*_world[chunk_coords{x, y}]); const with_shifted_camera_offset o{_shader, x, y}; _floor_mesh.draw(_shader, *_world[chunk_coords{x, y}]); + printf("OFFSET %hd %hd ---> %f %f\n", x, y, _shader.camera_offset()[0], _shader.camera_offset()[1]); } + fflush(stdout); for (std::int16_t y = miny; y <= maxy; y++) for (std::int16_t x = minx; x <= maxx; x++) |