From 09b48d11766eb7455611189a8a96fe38e322e537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Noel?= Date: Thu, 4 May 2023 15:43:34 +0200 Subject: [PATCH 1/2] don't rebuild GL context to toggle fullscreen --- Sources/SeriousSam/SeriousSam.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index c458598..74be824 100755 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -1033,10 +1033,16 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int // toggle full-screen on alt-enter if( msg.message==WM_SYSKEYDOWN && msg.wParam==VK_RETURN && !IsIconic(_hwndMain)) { - // !!! FIXME: SDL doesn't need to rebuild the GL context here to toggle fullscreen. - STUBBED("SDL doesn't need to rebuild the GL context here..."); +#ifdef PLATFORM_WIN32 StartNewMode( (GfxAPIType)sam_iGfxAPI, sam_iDisplayAdapter, sam_iScreenSizeI, sam_iScreenSizeJ, (enum DisplayDepth)sam_iDisplayDepth, !sam_bFullScreenActive); +#else + int res = SDL_SetWindowFullscreen((SDL_Window *) _hwndMain, sam_bFullScreenActive ? 0 : SDL_WINDOW_FULLSCREEN); + if (res == 0) + sam_bFullScreenActive = !sam_bFullScreenActive; + else + CPrintF("Can't toggle full-screen : %s\n", SDL_GetError()); +#endif if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. _pInput->ClearRelativeMouseMotion(); From 08c77c602cb10dcdf4dab3861ea3e7212b8093f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Noel?= Date: Thu, 4 May 2023 16:31:23 +0200 Subject: [PATCH 2/2] fixup! don't rebuild GL context to toggle fullscreen --- Sources/SeriousSam/SeriousSam.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 74be824..1dc1218 100755 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -1038,9 +1038,15 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int (enum DisplayDepth)sam_iDisplayDepth, !sam_bFullScreenActive); #else int res = SDL_SetWindowFullscreen((SDL_Window *) _hwndMain, sam_bFullScreenActive ? 0 : SDL_WINDOW_FULLSCREEN); - if (res == 0) + if (res == 0) { sam_bFullScreenActive = !sam_bFullScreenActive; - else + char achWindowTitle[256]; + if (sam_bFullScreenActive) + SDL_snprintf( achWindowTitle, sizeof (achWindowTitle), TRANS("Serious Sam (FullScreen %dx%d)"), sam_iScreenSizeI, sam_iScreenSizeJ); + else + SDL_snprintf( achWindowTitle, sizeof (achWindowTitle), TRANS("Serious Sam (Window %dx%d)"), sam_iScreenSizeI, sam_iScreenSizeJ); + SDL_SetWindowTitle((SDL_Window *) _hwndMain, achWindowTitle); + } else CPrintF("Can't toggle full-screen : %s\n", SDL_GetError()); #endif