From c824ad098935c07b9dbdbd9a7352519013f38676 Mon Sep 17 00:00:00 2001 From: 0xmac Date: Thu, 30 Jan 2025 09:17:09 +0100 Subject: [PATCH] Added window resize function --- src/sdlinit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sdlinit.c b/src/sdlinit.c index c56a872..a2970ee 100644 --- a/src/sdlinit.c +++ b/src/sdlinit.c @@ -1,7 +1,11 @@ #include +#include #include "config.h" #include "font.h" +extern float displayScale; +int WINMODE = 0; + static SDL_Window *window; static SDL_Renderer *renderer; static SDL_Texture *texture; @@ -16,7 +20,7 @@ void initWindow(){ window = SDL_CreateWindow("LS7 Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - SCREEN_WIDTH, SCREEN_HEIGHT, 0); + SDL_X_SIZE, SDL_Y_SIZE, WINMODE); if (window == NULL){ printf("Fatal! Could not create SDL Window: %s\n", SDL_GetError()); exit(EXIT_FAILURE); @@ -30,7 +34,7 @@ void initWindow(){ texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, - SCREEN_WIDTH, SCREEN_HEIGHT); + SDL_X_SIZE, SDL_Y_SIZE); if (texture == NULL){ printf("Fatal! Could not create SDL Texture: %s\n", SDL_GetError()); exit(EXIT_FAILURE); @@ -42,6 +46,10 @@ void initWindow(){ } } +void sdlResize(){ + SDL_SetWindowSize(window, SDL_X_SIZE * displayScale, SDL_Y_SIZE * displayScale); +} + void clearScreen(uint32_t pixels[], uint32_t color){ for (uint32_t i = 0; i < SDL_X_SIZE * SDL_Y_SIZE; i++) pixels[i] = color; }