summaryrefslogtreecommitdiffhomepage
path: root/main.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-03 16:31:04 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-03 16:31:04 +0200
commit0e82239a9cf4be27fddd164bf654c6163eb51373 (patch)
tree7cfb203b1d9021c4f18c6206f38dfd93f1c026a2 /main.cpp
parentb6cd1bfb40bbb0ef657092454c81def4e1b4907b (diff)
a
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/main.cpp b/main.cpp
index 875f6b2d..6da96648 100644
--- a/main.cpp
+++ b/main.cpp
@@ -32,7 +32,7 @@ struct enum_bitset : std::bitset<(std::size_t)enum_type::MAX> {
struct app final : Platform::Application
{
using dpi_policy = Platform::Implementation::Sdl2DpiScalingPolicy;
- using shared_tile_atlas = std::shared_ptr<tile_atlas>;
+ using tile_atlas_ = std::shared_ptr<tile_atlas>;
explicit app(const Arguments& arguments);
virtual ~app();
@@ -44,6 +44,7 @@ struct app final : Platform::Application
void keyReleaseEvent(KeyEvent& event) override;
void do_key(KeyEvent::Key k, KeyEvent::Modifiers m, bool pressed, bool repeated);
void draw_chunk(chunk& c);
+ void update_window_scale();
enum class key : int {
camera_up, camera_left, camera_right, camera_down, camera_reset,
@@ -53,14 +54,14 @@ struct app final : Platform::Application
chunk make_test_chunk();
tile_shader _shader;
- shared_tile_atlas floor1 =
+ tile_atlas_ floor1 =
//loader.tile_atlas("../share/game/images/tiles.tga", {8,4});
//loader.tile_atlas("../share/game/images/tiles2.tga", {8,5});
//loader.tile_atlas("../share/game/images/floor1.tga", {4, 4});
loader.tile_atlas("../share/game/images/metal1.tga", {2, 2});
- shared_tile_atlas floor2 =
+ tile_atlas_ floor2 =
loader.tile_atlas("../share/game/images/floor1.tga", {4, 4});
- shared_tile_atlas wall1 =
+ tile_atlas_ wall1 =
loader.tile_atlas("../share/game/images/metal2.tga", {2, 2});
chunk _chunk = make_test_chunk();
floor_mesh _floor_mesh;
@@ -76,13 +77,18 @@ chunk app::make_test_chunk()
{
chunk c;
c.foreach_tile([&, this](tile& x, std::size_t k, local_coords) {
- //const auto& atlas = (pt.y*TILE_MAX_DIM+pt.x+1) % 2 == 0 ? floor1 : floor2;
const auto& atlas = floor1;
x.ground_image = { atlas, (std::uint8_t)(k % atlas->size()) };
});
return c;
}
+void app::update_window_scale()
+{
+ auto sz = windowSize();
+ _shader.set_scale({ (float)sz[0], (float)sz[1] });
+}
+
void app::draw_chunk(chunk& c)
{
_floor_mesh.draw(_shader, c);
@@ -150,6 +156,7 @@ void app::drawEvent() {
//GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::LessOrEqual);
//GL::Renderer::enable(GL::Renderer::Feature::DepthTest);
+ update_window_scale();
{
float dt = timeline.previousFrameDuration();
update(dt);