Introduce ResizeWindow()

This commit is contained in:
obligaron 2021-12-04 16:29:48 +01:00 committed by Anders Jenbo
commit eb7b9d7054
2 changed files with 29 additions and 0 deletions

View file

@ -296,6 +296,34 @@ void ReinitializeRenderer()
#endif
}
void ResizeWindow()
{
if (ghMainWnd == nullptr)
return;
Size windowSize = GetPreferedWindowSize();
#ifdef USE_SDL1
SetVideoModeToPrimary(!gbForceWindowed && sgOptions.Graphics.bFullscreen, windowSize.width, windowSize.height);
#else
int flags = 0;
if (sgOptions.Graphics.bUpscale) {
if (!gbForceWindowed && sgOptions.Graphics.bFullscreen) {
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
SDL_SetWindowResizable(ghMainWnd, SDL_TRUE);
} else if (!gbForceWindowed && sgOptions.Graphics.bFullscreen) {
flags |= SDL_WINDOW_FULLSCREEN;
SDL_SetWindowResizable(ghMainWnd, SDL_FALSE);
}
SDL_SetWindowFullscreen(ghMainWnd, flags);
SDL_SetWindowSize(ghMainWnd, windowSize.width, windowSize.height);
#endif
ReinitializeRenderer();
}
SDL_Surface *GetOutputSurface()
{
#ifdef USE_SDL1

View file

@ -14,6 +14,7 @@ Uint16 GetViewportHeight();
bool SpawnWindow(const char *lpWindowName);
void ReinitializeRenderer();
void ResizeWindow();
void UiErrorOkDialog(const char *caption, const char *text, bool error = true);
} // namespace devilution