From 4fd6b58064bd26df93b05e39438dab649a65633c Mon Sep 17 00:00:00 2001
From: 3gg <3gg@shellblade.net>
Date: Sat, 8 Jul 2023 15:03:05 -0700
Subject: Add pixel scaling.

---
 gfx-iso/app/main.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'gfx-iso/app/main.c')

diff --git a/gfx-iso/app/main.c b/gfx-iso/app/main.c
index fa5a76b..5b441d3 100644
--- a/gfx-iso/app/main.c
+++ b/gfx-iso/app/main.c
@@ -43,6 +43,18 @@ static bool init(const GfxAppDesc* desc, void** app_state) {
   if (!make_demo_app(state->iso, &state->app)) {
     goto cleanup;
   }
+
+  // Apply pixel scaling if requested by the app.
+  int texture_width, texture_height;
+  if (state->app.pixel_scale > 1) {
+    texture_width  = SCREEN_WIDTH / state->app.pixel_scale;
+    texture_height = SCREEN_HEIGHT / state->app.pixel_scale;
+    isogfx_resize(state->iso, texture_width, texture_height);
+  } else {
+    texture_width  = SCREEN_WIDTH;
+    texture_height = SCREEN_HEIGHT;
+  }
+
   if (!(state->gfx = gfx_init())) {
     goto cleanup;
   }
@@ -50,8 +62,8 @@ static bool init(const GfxAppDesc* desc, void** app_state) {
 
   if (!(state->screen_texture = gfx_make_texture(
             render_backend, &(TextureDesc){
-                                .width     = SCREEN_WIDTH,
-                                .height    = SCREEN_HEIGHT,
+                                .width     = texture_width,
+                                .height    = texture_height,
                                 .dimension = Texture2D,
                                 .format    = TextureSRGBA8,
                                 .filtering = NearestFiltering,
-- 
cgit v1.2.3