proper getting of window size on resize

This commit is contained in:
veclav talica 2024-07-29 14:01:46 +03:00
parent 0697f845dd
commit 86d135281e

View File

@ -36,10 +36,7 @@ static void poll_events(void) {
break; break;
switch (e.window.event) { switch (e.window.event) {
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
ctx.window_w = e.window.data1;
ctx.window_h = e.window.data2;
ctx.window_size_has_changed = true; ctx.window_size_has_changed = true;
break; break;
} }
@ -151,6 +148,14 @@ void main_loop(void) {
render_queue_clear(); render_queue_clear();
poll_events(); 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); input_state_update(&ctx.input);
game_tick(); game_tick();