From 8cfdff8bdcd8f4dd04268fe7f40e4b576f28d34e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Nov 2025 18:54:20 +0100 Subject: [PATCH] use a video_mode_t thing for our custom resolution perhaps we may merge it into windowedmodes? not sure but this works for now --- src/sdl/i_video.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 57b579b37..ca229dc8a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -86,6 +86,9 @@ // maximum number of windowed modes (see windowedModes[][]) #define MAXWINMODES (33) +// detect our custom resolution +#define CUSTOMMODENUM 9999 + static void I_FillScreenResolutionsList(void); typedef struct @@ -96,10 +99,7 @@ typedef struct } video_mode_t; static video_mode_t windowedModes[MAXWINMODES] = {{NULL, 0, 0}}; - -#define CUSTOMMODENUM 9999 -static INT32 custom_width = 0; -static INT32 custom_height = 0; +static video_mode_t customMode = {NULL, 0, 0}; rendermode_t rendermode = render_none; @@ -496,6 +496,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) if (windowmoved) { + // if we say moved our game window to a different screen + // refetch our resolutions I_FillScreenResolutionsList(); #ifdef HWRENDER @@ -1563,7 +1565,7 @@ static void I_AppendResolution(SDL_DisplayMode *mode, int *current_resolution_in snprintf(mode_name, sizeof(mode_name), "%dx%d", mode->w, mode->h); - for(i = 0; i < *list_size; i++) + for (i = 0; i < *list_size; i++) if (!strcmp(mode_name, windowedModes[i].name)) return; @@ -1571,7 +1573,7 @@ static void I_AppendResolution(SDL_DisplayMode *mode, int *current_resolution_in windowedModes[*list_size].w = mode->w; windowedModes[*list_size].h = mode->h; - if (mode->w == custom_width && mode->h == custom_height) + if (mode->w == customMode.w && mode->h == customMode.h) *current_resolution_index = *list_size; (*list_size)++; @@ -1642,7 +1644,7 @@ static void I_FillScreenResolutionsList(void) windowedModes[list_size].name = NULL; } - snprintf(desired_resolution, sizeof(desired_resolution), "%dx%d", custom_width, custom_height); + snprintf(desired_resolution, sizeof(desired_resolution), "%dx%d", customMode.w, customMode.h); // [FG] if the desired resolution not in the list, append it if (current_resolution_index == -1) @@ -1704,8 +1706,8 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) if ((w >= BASEVIDWIDTH && h >= BASEVIDHEIGHT) && (rendermode == render_opengl || (w <= MAXVIDWIDTH && h <= MAXVIDHEIGHT))) { - custom_width = w; - custom_height = h; + customMode.w = w; + customMode.h = h; return CUSTOMMODENUM; } @@ -1749,11 +1751,11 @@ INT32 VID_SetMode(INT32 modeNum) vid.height = windowedModes[modeNum].h; vid.modenum = modeNum; } - else if (modeNum == CUSTOMMODENUM && custom_width && custom_height) + else if (modeNum == CUSTOMMODENUM && customMode.w && customMode.h) { // at this point these values are assumed to be okay - vid.width = custom_width; - vid.height = custom_height; + vid.width = customMode.w; + vid.height = customMode.h; vid.modenum = modeNum; }