diff options
author | 3gg <3gg@shellblade.net> | 2023-07-08 15:03:05 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-07-08 15:03:05 -0700 |
commit | 4fd6b58064bd26df93b05e39438dab649a65633c (patch) | |
tree | 4f7394f204933bdd6816d6dc5a38a2c16407c6d7 /gfx-iso/app | |
parent | 21a0d0c1c424f7db90c3282aad4bf6ad4ef809b7 (diff) |
Add pixel scaling.
Diffstat (limited to 'gfx-iso/app')
-rw-r--r-- | gfx-iso/app/app.h | 1 | ||||
-rw-r--r-- | gfx-iso/app/isogfx-demo.c | 9 | ||||
-rw-r--r-- | gfx-iso/app/main.c | 16 |
3 files changed, 20 insertions, 6 deletions
diff --git a/gfx-iso/app/app.h b/gfx-iso/app/app.h index 160da47..25e55eb 100644 --- a/gfx-iso/app/app.h +++ b/gfx-iso/app/app.h | |||
@@ -4,6 +4,7 @@ typedef struct IsoGfx IsoGfx; | |||
4 | typedef struct IsoGfxApp IsoGfxApp; | 4 | typedef struct IsoGfxApp IsoGfxApp; |
5 | 5 | ||
6 | typedef struct IsoGfxApp { | 6 | typedef struct IsoGfxApp { |
7 | int pixel_scale; // 0 or 1 for 1:1 scale. | ||
7 | void* state; | 8 | void* state; |
8 | void (*shutdown)(IsoGfx*, void* state); | 9 | void (*shutdown)(IsoGfx*, void* state); |
9 | void (*update)(IsoGfx*, void* state, double t, double dt); | 10 | void (*update)(IsoGfx*, void* state, double t, double dt); |
diff --git a/gfx-iso/app/isogfx-demo.c b/gfx-iso/app/isogfx-demo.c index 15ab6be..d463d1c 100644 --- a/gfx-iso/app/isogfx-demo.c +++ b/gfx-iso/app/isogfx-demo.c | |||
@@ -54,10 +54,11 @@ bool make_demo_app(IsoGfx* iso, IsoGfxApp* app) { | |||
54 | goto cleanup; | 54 | goto cleanup; |
55 | } | 55 | } |
56 | 56 | ||
57 | app->state = state; | 57 | app->pixel_scale = 2; |
58 | app->shutdown = shutdown; | 58 | app->state = state; |
59 | app->update = update; | 59 | app->shutdown = shutdown; |
60 | app->render = render; | 60 | app->update = update; |
61 | app->render = render; | ||
61 | 62 | ||
62 | return true; | 63 | return true; |
63 | 64 | ||
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) { | |||
43 | if (!make_demo_app(state->iso, &state->app)) { | 43 | if (!make_demo_app(state->iso, &state->app)) { |
44 | goto cleanup; | 44 | goto cleanup; |
45 | } | 45 | } |
46 | |||
47 | // Apply pixel scaling if requested by the app. | ||
48 | int texture_width, texture_height; | ||
49 | if (state->app.pixel_scale > 1) { | ||
50 | texture_width = SCREEN_WIDTH / state->app.pixel_scale; | ||
51 | texture_height = SCREEN_HEIGHT / state->app.pixel_scale; | ||
52 | isogfx_resize(state->iso, texture_width, texture_height); | ||
53 | } else { | ||
54 | texture_width = SCREEN_WIDTH; | ||
55 | texture_height = SCREEN_HEIGHT; | ||
56 | } | ||
57 | |||
46 | if (!(state->gfx = gfx_init())) { | 58 | if (!(state->gfx = gfx_init())) { |
47 | goto cleanup; | 59 | goto cleanup; |
48 | } | 60 | } |
@@ -50,8 +62,8 @@ static bool init(const GfxAppDesc* desc, void** app_state) { | |||
50 | 62 | ||
51 | if (!(state->screen_texture = gfx_make_texture( | 63 | if (!(state->screen_texture = gfx_make_texture( |
52 | render_backend, &(TextureDesc){ | 64 | render_backend, &(TextureDesc){ |
53 | .width = SCREEN_WIDTH, | 65 | .width = texture_width, |
54 | .height = SCREEN_HEIGHT, | 66 | .height = texture_height, |
55 | .dimension = Texture2D, | 67 | .dimension = Texture2D, |
56 | .format = TextureSRGBA8, | 68 | .format = TextureSRGBA8, |
57 | .filtering = NearestFiltering, | 69 | .filtering = NearestFiltering, |