summaryrefslogtreecommitdiff
path: root/gfx-iso/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'gfx-iso/src/app.c')
-rw-r--r--gfx-iso/src/app.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/gfx-iso/src/app.c b/gfx-iso/src/app.c
index e07f318..aaeb205 100644
--- a/gfx-iso/src/app.c
+++ b/gfx-iso/src/app.c
@@ -13,8 +13,8 @@
13#include <stdbool.h> 13#include <stdbool.h>
14#include <stdlib.h> 14#include <stdlib.h>
15 15
16static const int SCREEN_WIDTH = 1408; 16static const int WINDOW_WIDTH = 1408;
17static const int SCREEN_HEIGHT = 960; 17static const int WINDOW_HEIGHT = 960;
18static const int MAX_FPS = 60; 18static const int MAX_FPS = 60;
19 19
20typedef struct AppState { 20typedef struct AppState {
@@ -35,8 +35,13 @@ static bool init(GfxAppState* gfx_app_state, int argc, const char** argv) {
35 35
36 IsoGfxApp* app = state->app; 36 IsoGfxApp* app = state->app;
37 37
38 // Virtual screen dimensions.
39 const int scale = app->pixel_scale == 0 ? 1 : app->pixel_scale;
40 const int screen_width = WINDOW_WIDTH / scale;
41 const int screen_height = WINDOW_HEIGHT / scale;
42
38 if (!(state->iso = isogfx_new(&(IsoGfxDesc){ 43 if (!(state->iso = isogfx_new(&(IsoGfxDesc){
39 .screen_width = SCREEN_WIDTH, .screen_height = SCREEN_HEIGHT}))) { 44 .screen_width = screen_width, .screen_height = screen_height}))) {
40 goto cleanup; 45 goto cleanup;
41 } 46 }
42 47
@@ -44,16 +49,7 @@ static bool init(GfxAppState* gfx_app_state, int argc, const char** argv) {
44 goto cleanup; 49 goto cleanup;
45 } 50 }
46 51
47 // Apply pixel scaling if requested by the app. 52 isogfx_resize(state->iso, screen_width, screen_height);
48 int texture_width, texture_height;
49 if (app->pixel_scale > 1) {
50 texture_width = SCREEN_WIDTH / app->pixel_scale;
51 texture_height = SCREEN_HEIGHT / 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 53
58 if (!(state->gfx = gfx_init())) { 54 if (!(state->gfx = gfx_init())) {
59 goto cleanup; 55 goto cleanup;
@@ -62,8 +58,8 @@ static bool init(GfxAppState* gfx_app_state, int argc, const char** argv) {
62 58
63 if (!(state->screen_texture = gfx_make_texture( 59 if (!(state->screen_texture = gfx_make_texture(
64 gfxcore, &(TextureDesc){ 60 gfxcore, &(TextureDesc){
65 .width = texture_width, 61 .width = screen_width,
66 .height = texture_height, 62 .height = screen_height,
67 .dimension = Texture2D, 63 .dimension = Texture2D,
68 .format = TextureSRGBA8, 64 .format = TextureSRGBA8,
69 .filtering = NearestFiltering, 65 .filtering = NearestFiltering,
@@ -183,8 +179,8 @@ void iso_run(int argc, const char** argv, IsoGfxApp* app) {
183 &(GfxAppDesc){ 179 &(GfxAppDesc){
184 .argc = argc, 180 .argc = argc,
185 .argv = argv, 181 .argv = argv,
186 .width = SCREEN_WIDTH, 182 .width = WINDOW_WIDTH,
187 .height = SCREEN_HEIGHT, 183 .height = WINDOW_HEIGHT,
188 .max_fps = MAX_FPS, 184 .max_fps = MAX_FPS,
189 .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, 185 .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0,
190 .title = "Isometric Renderer", 186 .title = "Isometric Renderer",