diff options
| -rw-r--r-- | main/draw.cpp | 14 | ||||
| -rw-r--r-- | src/camera-offset.cpp | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index 85a4dcdd..b7dd420a 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -69,18 +69,30 @@ std::array<std::int16_t, 4> app::get_draw_bounds() const noexcept void app::draw_world() { +#if 0 _floor_mesh.draw(_shader, *_world[chunk_coords{0, 0}]); _wall_mesh.draw(_shader, *_world[chunk_coords{0, 0}]); -#if 0 +#else auto [minx, maxx, miny, maxy] = get_draw_bounds(); + printf("%hd %hd -> %hd %hd\n", minx, miny, maxx, maxy); + fflush(stdout); + for (std::int16_t y = miny; y <= maxy; y++) for (std::int16_t x = minx; x <= maxx; x++) + { + if (!_world.contains(chunk_coords{x, y})) + 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}]); + } for (std::int16_t y = miny; y <= maxy; y++) for (std::int16_t x = minx; x <= maxx; x++) + { + const with_shifted_camera_offset o{_shader, x, y}; _wall_mesh.draw(_shader, *_world[chunk_coords{x, y}]); + } #endif } diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp index 3087cf13..0bf51c3f 100644 --- a/src/camera-offset.cpp +++ b/src/camera-offset.cpp @@ -12,8 +12,8 @@ with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, shor _shader{shader}, _offset{shader.camera_offset()} { - const auto offset = _offset + tile_shader::project({float(x)*TILE_MAX_DIM*TILE_SIZE[0], - float(y)*TILE_MAX_DIM*TILE_SIZE[1], + const auto offset = _offset + tile_shader::project({float(x)*TILE_MAX_DIM*TILE_SIZE[0]*.5f, + float(y)*TILE_MAX_DIM*TILE_SIZE[1]*.5f, 0}); _shader.set_camera_offset(offset); ASSERT(std::abs(offset[0]) < 1 << 24 && std::abs(offset[1]) < 1 << 24); |
