summaryrefslogtreecommitdiffhomepage
path: root/main/main.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-16 21:51:07 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-16 21:51:07 +0200
commit7ab99aabe8509e84b9b5b04aafa1e1ae20b40512 (patch)
treee86c02ccaa195b0dc239ff04e50f9efa8cb54a34 /main/main.cpp
parent0db5306c483c718076b14349f223840cce2862bd (diff)
a
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/main/main.cpp b/main/main.cpp
index e371713b..b032e2a2 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -7,22 +7,6 @@
namespace floormat {
-chunk app::make_test_chunk()
-{
- constexpr auto N = TILE_MAX_DIM;
- chunk c;
- for (auto [x, k, pt] : c) {
- const auto& atlas = pt.x > N/2 && pt.y >= N/2 ? floor2 : floor1;
- x.ground_image = { atlas, (std::uint8_t)(k % atlas->num_tiles().product()) };
- }
- constexpr auto K = N/2;
- c[{K, K }].wall_north = { wall1, 0 };
- c[{K, K }].wall_west = { wall2, 0 };
- c[{K, K+1}].wall_north = { wall1, 0 };
- c[{K+1, K }].wall_west = { wall2, 0 };
- return c;
-}
-
void app::drawEvent() {
#if 0
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color | GL::FramebufferClear::Depth);
@@ -52,6 +36,27 @@ void app::drawEvent() {
void app::draw_chunk(chunk& c)
{
+ {
+ int minx = 0, maxx = 0, miny = 0, maxy = 0;
+ auto fn = [&](int x, int y) {
+ const auto pos = pixel_to_tile({(float)x, (float)y}) / Vector2{TILE_MAX_DIM, TILE_MAX_DIM};
+ minx = std::min(minx, (int)std::floor(pos[0]));
+ maxx = std::max(maxx, (int)(pos[0]));
+ miny = std::min(miny, (int)std::floor(pos[1]));
+ maxy = std::max(maxy, (int)(pos[1]));
+ };
+ const auto sz = windowSize();
+ const auto x = sz[0], y = sz[1];
+ fn(0, 0);
+ fn(x, 0);
+ fn(0, y);
+ fn(x, y);
+
+ printf("%d %d -> %d %d\n", minx, miny, maxx, maxy);
+ fflush(stdout);
+ printf(""); // put breakpoint here
+ }
+
_shader.set_tint({1, 1, 1, 1});
_floor_mesh.draw(_shader, c);
_wall_mesh.draw(_shader, c);