diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 876a37328..22e5c5fb3 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -60,12 +60,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state); extern bool vid_hdr_active; -CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (self < 0 || self > 2) self = 2; - if (screen != nullptr) screen->SetGamma(); -} - namespace OpenGLRenderer { FGLRenderer *GLRenderer; @@ -282,35 +276,6 @@ void OpenGLFrameBuffer::SetVSync(bool vsync) glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding); } -//=========================================================================== -// -// DoSetGamma -// -// (Unfortunately Windows has some safety precautions that block gamma ramps -// that are considered too extreme. As a result this doesn't work flawlessly) -// -//=========================================================================== - -void OpenGLFrameBuffer::SetGamma() -{ - bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen())); - if (useHWGamma) - { - uint16_t gammaTable[768]; - - // This formula is taken from Doomsday - BuildGammaTable(gammaTable); - SetGammaTable(gammaTable); - - HWGammaActive = true; - } - else if (HWGammaActive) - { - ResetGammaTable(); - HWGammaActive = false; - } -} - //=========================================================================== // // @@ -466,7 +431,7 @@ TArray OpenGLFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo color_type = SS_RGB; // Screenshot should not use gamma correction if it was already applied to rendered image - gamma = 1 == vid_hwgamma || (2 == vid_hwgamma && !fullscreen) ? 1.0f : Gamma; + gamma = 1; if (vid_hdr_active && fullscreen) gamma *= 2.2f; return ScreenshotBuffer; diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 94467118b..97e328678 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -24,9 +24,6 @@ public: void InitializeState() override; void Update() override; - // Color correction - void SetGamma(); - void CleanForRestart() override; void UpdatePalette() override; uint32_t GetCaps() override; diff --git a/src/hwrenderer/utility/hw_cvars.cpp b/src/hwrenderer/utility/hw_cvars.cpp index 1d11e24b1..e228f7a63 100644 --- a/src/hwrenderer/utility/hw_cvars.cpp +++ b/src/hwrenderer/utility/hw_cvars.cpp @@ -54,30 +54,9 @@ CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) gl_seamless=self; } -CUSTOM_CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (screen != NULL) - { - screen->SetGamma(); - } -} - -CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (screen != NULL) - { - screen->SetGamma(); - } -} - -CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (screen != NULL) - { - screen->SetGamma(); - } -} - +CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); //========================================================================== diff --git a/src/posix/cocoa/gl_sysfb.h b/src/posix/cocoa/gl_sysfb.h index 9f8222013..a45f448f8 100644 --- a/src/posix/cocoa/gl_sysfb.h +++ b/src/posix/cocoa/gl_sysfb.h @@ -74,8 +74,6 @@ protected: void SetGammaTable(uint16_t* table); void ResetGammaTable(); - bool m_supportsGamma; - private: void SetFullscreenMode(); void SetWindowedMode(); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index f5fd5b00b..0746056da 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -219,31 +219,6 @@ public: EXTERN_CVAR(Float, Gamma) -CUSTOM_CVAR(Float, rgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (NULL != screen) - { - screen->SetGamma(); - } -} - -CUSTOM_CVAR(Float, ggamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (NULL != screen) - { - screen->SetGamma(); - } -} - -CUSTOM_CVAR(Float, bgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (NULL != screen) - { - screen->SetGamma(); - } -} - - // --------------------------------------------------------------------------- @@ -335,23 +310,6 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen) [m_window setContentView:glView]; - // Create table for system-wide gamma correction - - CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; - uint32_t actualChannelSize; - - const CGError result = CGGetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, - gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2], &actualChannelSize); - m_supportsGamma = kCGErrorSuccess == result && GAMMA_CHANNEL_SIZE == actualChannelSize; - - if (m_supportsGamma) - { - for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) - { - m_originalGamma[i] = static_cast(gammaTable[i] * 65535.0f); - } - } - assert(frameBuffer == nullptr); frameBuffer = this; @@ -431,31 +389,6 @@ void SystemGLFrameBuffer::SwapBuffers() [[NSOpenGLContext currentContext] flushBuffer]; } -void SystemGLFrameBuffer::SetGammaTable(uint16_t* table) -{ - if (m_supportsGamma) - { - CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; - - for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) - { - gammaTable[i] = static_cast(table[i] / 65535.0f); - } - - CGSetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, - gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2]); - } -} - -void SystemGLFrameBuffer::ResetGammaTable() -{ - if (m_supportsGamma) - { - SetGammaTable(m_originalGamma); - } -} - - int SystemGLFrameBuffer::GetClientWidth() { const int clientWidth = I_GetContentViewSize(m_window).width; diff --git a/src/posix/sdl/gl_sysfb.h b/src/posix/sdl/gl_sysfb.h index 44b92cf1a..f7ac38dd3 100644 --- a/src/posix/sdl/gl_sysfb.h +++ b/src/posix/sdl/gl_sysfb.h @@ -47,9 +47,6 @@ protected: void UpdateColors (); - Uint16 m_origGamma[3][256]; - bool m_supportsGamma; - static const int MIN_WIDTH = 320; static const int MIN_HEIGHT = 200; }; diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 6d8cbd212..d92c6fa9a 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -65,7 +65,6 @@ extern IVideo *Video; -EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Int, vid_adapter) EXTERN_CVAR (Int, vid_displaybits) EXTERN_CVAR (Int, vid_maxfps) @@ -250,13 +249,7 @@ SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen) GLContext = SDL_GL_CreateContext(Screen); if (GLContext != NULL) - { - m_supportsGamma = -1 != SDL_GetWindowGammaRamp(Screen, - m_origGamma[0], m_origGamma[1], m_origGamma[2] - ); - return; - } SDL_DestroyWindow(Screen); Screen = NULL; @@ -268,8 +261,6 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer () { if (Screen) { - ResetGammaTable(); - if (GLContext) { SDL_GL_DeleteContext(GLContext); @@ -280,22 +271,6 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer () } -void SystemGLFrameBuffer::SetGammaTable(uint16_t *tbl) -{ - if (m_supportsGamma) - { - SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); - } -} - -void SystemGLFrameBuffer::ResetGammaTable() -{ - if (m_supportsGamma) - { - SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); - } -} - bool SystemGLFrameBuffer::IsFullscreen () { return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; diff --git a/src/win32/base_sysfb.cpp b/src/win32/base_sysfb.cpp index 6e90ca81c..c5f14404b 100644 --- a/src/win32/base_sysfb.cpp +++ b/src/win32/base_sysfb.cpp @@ -357,7 +357,6 @@ SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) : HDC hDC = GetDC(Window); - m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); ReleaseDC(Window, hDC); } @@ -369,7 +368,6 @@ SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) : SystemBaseFrameBuffer::~SystemBaseFrameBuffer() { - ResetGammaTable(); if (!m_Fullscreen) SaveWindowedPos(); ShowWindow (Window, SW_SHOW); @@ -382,32 +380,6 @@ SystemBaseFrameBuffer::~SystemBaseFrameBuffer() } -//========================================================================== -// -// -// -//========================================================================== - -void SystemBaseFrameBuffer::ResetGammaTable() -{ - if (m_supportsGamma) - { - HDC hDC = GetDC(Window); - SetDeviceGammaRamp(hDC, (void *)m_origGamma); - ReleaseDC(Window, hDC); - } -} - -void SystemBaseFrameBuffer::SetGammaTable(uint16_t *tbl) -{ - if (m_supportsGamma) - { - HDC hDC = GetDC(Window); - SetDeviceGammaRamp(hDC, (void *)tbl); - ReleaseDC(Window, hDC); - } -} - //========================================================================== // // diff --git a/src/win32/base_sysfb.h b/src/win32/base_sysfb.h index 6d7470cef..9db8f8420 100644 --- a/src/win32/base_sysfb.h +++ b/src/win32/base_sysfb.h @@ -30,12 +30,8 @@ protected: void PositionWindow(bool fullscreen, bool initialcall = false); - void ResetGammaTable(); - void SetGammaTable(uint16_t * tbl); - float m_Gamma, m_Brightness, m_Contrast; uint16_t m_origGamma[768]; - bool m_supportsGamma; bool m_Fullscreen = false; char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here! char *m_displayDeviceName; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 839d19aca..b25b3b5b0 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -743,7 +743,6 @@ OptionMenu "VideoOptions" protected Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2 Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2 - Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" StaticText " " Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" @@ -2039,13 +2038,6 @@ OptionValue "FilterModes" 4, "$OPTVAL_TRILINEAR" } -OptionValue "HWGammaModes" -{ - 0, "$OPTVAL_ON" - 1, "$OPTVAL_OFF" - 2, "$OPTVAL_FULLSCREENONLY" -} - OptionValue "TonemapModes" { 0, "$OPTVAL_OFF"