Skip to content
Snippets Groups Projects
Commit 22d35248 authored by Lactozilla's avatar Lactozilla :speech_balloon:
Browse files

Set fullscreen resolution defaults to the current display's size

parent 9d9be887
No related branches found
No related tags found
No related merge requests found
...@@ -100,10 +100,18 @@ const char *VID_GetModeName(INT32 modenum); ...@@ -100,10 +100,18 @@ const char *VID_GetModeName(INT32 modenum);
void VID_PrepareModeList(void); /// note hack for SDL void VID_PrepareModeList(void); /// note hack for SDL
/** \brief Returns true if the window is maximized, and false if not
*/
boolean VID_IsMaximized(void); boolean VID_IsMaximized(void);
/** \brief Restores the window
*/
void VID_RestoreWindow(void); void VID_RestoreWindow(void);
/** \brief Gets the current display's size; returns true if it succeeded, and false if not
*/
boolean VID_GetNativeResolution(INT32 *width, INT32 *height);
/** \brief can video system do fullscreen /** \brief can video system do fullscreen
*/ */
extern boolean allow_fullscreen; extern boolean allow_fullscreen;
......
...@@ -146,6 +146,8 @@ static void Impl_SetupSoftwareBuffer(void); ...@@ -146,6 +146,8 @@ static void Impl_SetupSoftwareBuffer(void);
static void Impl_InitOpenGL(void); static void Impl_InitOpenGL(void);
static void Impl_SetDefaultWindowSizes(void);
#if defined(HAVE_IMAGE) #if defined(HAVE_IMAGE)
#define USE_WINDOW_ICON #define USE_WINDOW_ICON
#endif #endif
...@@ -360,6 +362,8 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b ...@@ -360,6 +362,8 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
SDL_SetWindowSize(window, width, height); SDL_SetWindowSize(window, width, height);
if (fullscreen) if (fullscreen)
SDL_SetWindowFullscreen(window, fullscreen_type); SDL_SetWindowFullscreen(window, fullscreen_type);
Impl_SetDefaultWindowSizes();
} }
if (Impl_RenderContextReset() == SDL_FALSE) if (Impl_RenderContextReset() == SDL_FALSE)
...@@ -410,6 +414,36 @@ static UINT32 VID_GetRefreshRate(void) ...@@ -410,6 +414,36 @@ static UINT32 VID_GetRefreshRate(void)
return m.refresh_rate; return m.refresh_rate;
} }
static void Impl_SetDefaultWindowSizes(void)
{
INT32 native_width, native_height;
if (!VID_GetNativeResolution(&native_width, &native_height))
return;
char *result, *buffer1, *buffer2;
result = va("%d", native_width);
buffer1 = malloc(strlen(result) + 1);
if (!buffer1)
return;
strcpy(buffer1, result);
result = va("%d", native_height);
buffer2 = malloc(strlen(result) + 1);
if (!buffer2)
{
free(buffer1);
return;
}
strcpy(buffer2, result);
cv_scr_width.defaultvalue = buffer1;
cv_scr_height.defaultvalue = buffer2;
}
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
{ {
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
...@@ -1473,38 +1507,45 @@ boolean VID_CheckRenderer(void) ...@@ -1473,38 +1507,45 @@ boolean VID_CheckRenderer(void)
return rendererchanged; return rendererchanged;
} }
#if 0 static boolean Impl_GetCurrentDisplayMode(INT32 *width, INT32 *height)
static void Impl_GetCurrentDisplayMode(INT32 *width, INT32 *height)
{ {
int i = SDL_GetWindowDisplayIndex(window); int i = SDL_GetWindowDisplayIndex(window);
SDL_DisplayMode resolution;
if (i < 0) if (i < 0)
return; return false;
SDL_DisplayMode resolution;
if (!SDL_GetCurrentDisplayMode(i, &resolution)) if (SDL_GetCurrentDisplayMode(i, &resolution) == 0)
{ {
if ((*width) == 0) if ((*width) == 0)
(*width) = (INT32)(resolution.w); (*width) = (INT32)(resolution.w);
if ((*height) == 0) if ((*height) == 0)
(*height) = (INT32)(resolution.h); (*height) = (INT32)(resolution.h);
return true;
} }
return false;
} }
void VID_GetNativeResolution(INT32 *width, INT32 *height) boolean VID_GetNativeResolution(INT32 *width, INT32 *height)
{ {
INT32 w = 0, h = 0; INT32 w = 0, h = 0;
if (!w || !h) boolean success = Impl_GetCurrentDisplayMode(&w, &h);
Impl_GetCurrentDisplayMode(&w, &h);
if (!w) w = BASEVIDWIDTH; if (!success)
if (!h) h = BASEVIDHEIGHT; {
w = BASEVIDWIDTH;
h = BASEVIDHEIGHT;
}
if (width)
*width = w;
if (height)
*height = h;
if (width) *width = w; return success;
if (height) *height = h;
} }
#endif
void VID_SetSize(INT32 width, INT32 height) void VID_SetSize(INT32 width, INT32 height)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment