From 86d135281ee7ea9129ba4cf1409a82879f80a493 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Mon, 29 Jul 2024 14:01:46 +0300 Subject: [PATCH] proper getting of window size on resize --- src/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index ec571bd..749e551 100644 --- a/src/main.c +++ b/src/main.c @@ -36,10 +36,7 @@ static void poll_events(void) { break; switch (e.window.event) { - case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_SIZE_CHANGED: - ctx.window_w = e.window.data1; - ctx.window_h = e.window.data2; ctx.window_size_has_changed = true; break; } @@ -151,6 +148,14 @@ void main_loop(void) { render_queue_clear(); poll_events(); + + if (ctx.window_size_has_changed) { + t_vec2 size; + SDL_GetWindowSize(ctx.window, &size.x, &size.y); + ctx.window_w = size.x; + ctx.window_h = size.y; + } + input_state_update(&ctx.input); game_tick();