From fcdab1645c19c4b80c8bbe84e3d207d8859169f7 Mon Sep 17 00:00:00 2001 From: BSzili Date: Sun, 28 Sep 2025 09:36:18 +0200 Subject: [PATCH 1/2] SDL2 gamma correction support --- Sources/Engine/Graphics/GfxLibrary.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 56c5baa9b..59139e4f4 100755 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -86,7 +86,7 @@ extern BOOL CVA_bModels; static FLOAT _fLastBrightness, _fLastContrast, _fLastGamma; static FLOAT _fLastBiasR, _fLastBiasG, _fLastBiasB; static INDEX _iLastLevels; -#ifdef PLATFORM_WIN32 // DG: not used on other platforms +#ifndef PLATFORM_PANDORA // DG: not used on other platforms static UWORD _auwGammaTable[256*3]; #endif @@ -1799,7 +1799,7 @@ INDEX _ctProbeShdU = 0; INDEX _ctProbeShdB = 0; INDEX _ctFullShdU = 0; SLONG _slFullShdUBytes = 0; -#ifdef PLATFORM_WIN32 // only used there +#ifndef PLATFORM_PANDORA // only used there static BOOL GenerateGammaTable(void); #endif @@ -2003,6 +2003,18 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) } } else +#else + if( gl_ulFlags & GLF_ADJUSTABLEGAMMA) { + // ... and required + const BOOL bTableSet = GenerateGammaTable(); + if( bTableSet) { + Uint16 *rampR = &_auwGammaTable[0]; + Uint16 *rampG = &_auwGammaTable[256]; + Uint16 *rampB = &_auwGammaTable[512]; + SDL_SetWindowGammaRamp((SDL_Window *) pvp->vp_hWnd, rampR, rampG, rampB); + } + } + else #endif // if not supported { @@ -2063,7 +2075,7 @@ void CGfxLibrary::UnlockRaster( CRaster *praToUnlock) } -#ifdef PLATFORM_WIN32 // DG: only used on windows +#ifndef PLATFORM_PANDORA // DG: only used on windows // generates gamma table and returns true if gamma table has been changed static BOOL GenerateGammaTable(void) { From 66983f6d4f977cf133ab2565615ad9af66a3c85a Mon Sep 17 00:00:00 2001 From: BSzili Date: Sun, 28 Sep 2025 11:14:29 +0200 Subject: [PATCH 2/2] Destroy the window and context after SE_EndEngine for non-Win32 --- Sources/SeriousSam/SeriousSam.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 6dd64c147..8645dda33 100755 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -696,7 +696,9 @@ void End(void) pdpNormal = NULL; } +#ifdef PLATFORM_WIN32 CloseMainWindow(); +#endif MainWindow_End(); DestroyMenus(); _pGame->End(); @@ -704,6 +706,9 @@ void End(void) // unlock the directory DirectoryLockOff(); SE_EndEngine(); +#ifndef PLATFORM_WIN32 + CloseMainWindow(); +#endif #if PLATFORM_UNIX SDL_Quit();