Added window resize function

This commit is contained in:
0xmac 2025-01-30 09:17:09 +01:00
parent de0686edb7
commit c824ad0989

View File

@ -1,7 +1,11 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_video.h>
#include "config.h" #include "config.h"
#include "font.h" #include "font.h"
extern float displayScale;
int WINMODE = 0;
static SDL_Window *window; static SDL_Window *window;
static SDL_Renderer *renderer; static SDL_Renderer *renderer;
static SDL_Texture *texture; static SDL_Texture *texture;
@ -16,7 +20,7 @@ void initWindow(){
window = SDL_CreateWindow("LS7 Emulator", window = SDL_CreateWindow("LS7 Emulator",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, 0); SDL_X_SIZE, SDL_Y_SIZE, WINMODE);
if (window == NULL){ if (window == NULL){
printf("Fatal! Could not create SDL Window: %s\n", SDL_GetError()); printf("Fatal! Could not create SDL Window: %s\n", SDL_GetError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -30,7 +34,7 @@ void initWindow(){
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_STREAMING,
SCREEN_WIDTH, SCREEN_HEIGHT); SDL_X_SIZE, SDL_Y_SIZE);
if (texture == NULL){ if (texture == NULL){
printf("Fatal! Could not create SDL Texture: %s\n", SDL_GetError()); printf("Fatal! Could not create SDL Texture: %s\n", SDL_GetError());
exit(EXIT_FAILURE); 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){ void clearScreen(uint32_t pixels[], uint32_t color){
for (uint32_t i = 0; i < SDL_X_SIZE * SDL_Y_SIZE; i++) pixels[i] = color; for (uint32_t i = 0; i < SDL_X_SIZE * SDL_Y_SIZE; i++) pixels[i] = color;
} }