From 538c9e5cde425ecee1e802fd53344111683b60be Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 18 Jul 2022 21:19:30 +0200 Subject: [PATCH] Drop gamma ramp code We definitely won't be wanting to set the gamma for the entire display in the future. --- include/IrrCompileConfig.h | 13 +---- include/IrrlichtDevice.h | 8 --- source/Irrlicht/CIrrDeviceLinux.cpp | 91 ----------------------------- source/Irrlicht/CIrrDeviceLinux.h | 12 ---- source/Irrlicht/CIrrDeviceSDL.cpp | 19 ------ source/Irrlicht/CIrrDeviceSDL.h | 6 -- source/Irrlicht/CIrrDeviceStub.cpp | 54 ----------------- source/Irrlicht/CIrrDeviceStub.h | 9 --- source/Irrlicht/CIrrDeviceWin32.cpp | 40 ------------- source/Irrlicht/CIrrDeviceWin32.h | 6 -- source/Irrlicht/CMakeLists.txt | 1 - 11 files changed, 1 insertion(+), 258 deletions(-) diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index 20d7669..4c1cb73 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -272,19 +272,8 @@ define out. */ #undef _IRR_COMPILE_WITH_X11_ #endif -//! On some Linux systems the XF86 vidmode extension, X11 RandR, or XInput2 are missing. -//! Use these defines to add/remove support for those dependencies as needed. -//! XInput2 (library called Xi) is currently only used to support touch-input. #if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_) -#define _IRR_LINUX_X11_VIDMODE_ -//#define _IRR_LINUX_X11_RANDR_ -//#define _IRR_LINUX_X11_XINPUT2_ -#ifdef NO_IRR_LINUX_X11_VIDMODE_ -#undef _IRR_LINUX_X11_VIDMODE_ -#endif -#ifdef NO_IRR_LINUX_X11_RANDR_ -#undef _IRR_LINUX_X11_RANDR_ -#endif +//! XInput2 (library called Xi) is currently only used to support touch-input. #ifdef NO_IRR_LINUX_X11_XINPUT2_ #undef _IRR_LINUX_X11_XINPUT2_ #endif diff --git a/include/IrrlichtDevice.h b/include/IrrlichtDevice.h index 8841511..43107eb 100644 --- a/include/IrrlichtDevice.h +++ b/include/IrrlichtDevice.h @@ -270,14 +270,6 @@ namespace irr //! Is device motion available. virtual bool isDeviceMotionAvailable() = 0; - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp(f32 red, f32 green, f32 blue, - f32 relativebrightness, f32 relativecontrast) =0; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, - f32 &brightness, f32 &contrast) =0; - //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. /** When set to 0 no double- and tripleclicks will be generated. \param timeMs maximal time in milliseconds for two consecutive clicks to be recognized as double click diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index 243415d..6d4c1a7 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -1763,97 +1763,6 @@ void CIrrDeviceLinux::pollJoysticks() } -//! Set the current Gamma Value for the Display -bool CIrrDeviceLinux::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(XDisplay, &eventbase, &errorbase)) - { - XF86VidModeGamma gamma; - gamma.red=red; - gamma.green=green; - gamma.blue=blue; - XF86VidModeSetGamma(XDisplay, Screennr, &gamma); - return true; - } - #endif - #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_) - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(XDisplay, &eventbase, &errorbase)) - { - XRRQueryVersion(XDisplay, &eventbase, &errorbase); // major, minor - if (eventbase>=1 && errorbase>1) - { - #if (RANDR_MAJOR>1 || RANDR_MINOR>1) - XRRCrtcGamma *gamma = XRRGetCrtcGamma(XDisplay, Screennr); - if (gamma) - { - *gamma->red=(u16)red; - *gamma->green=(u16)green; - *gamma->blue=(u16)blue; - XRRSetCrtcGamma(XDisplay, Screennr, gamma); - XRRFreeGamma(gamma); - return true; - } - #endif - } - } - #endif - #endif - return false; -} - - -//! Get the current Gamma Value for the Display -bool CIrrDeviceLinux::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - brightness = 0.f; - contrast = 0.f; - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(XDisplay, &eventbase, &errorbase)) - { - XF86VidModeGamma gamma; - XF86VidModeGetGamma(XDisplay, Screennr, &gamma); - red = gamma.red; - green = gamma.green; - blue = gamma.blue; - return true; - } - #endif - #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_) - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(XDisplay, &eventbase, &errorbase)) - { - XRRQueryVersion(XDisplay, &eventbase, &errorbase); // major, minor - if (eventbase>=1 && errorbase>1) - { - #if (RANDR_MAJOR>1 || RANDR_MINOR>1) - XRRCrtcGamma *gamma = XRRGetCrtcGamma(XDisplay, Screennr); - if (gamma) - { - red = *gamma->red; - green = *gamma->green; - blue= *gamma->blue; - XRRFreeGamma(gamma); - return true; - } - #endif - } - } - #endif - #endif - return false; -} - - //! gets text from the clipboard //! \return Returns 0 if no string is in there, otherwise utf-8 text. const c8 *CIrrDeviceLinux::getTextFromClipboard() const diff --git a/source/Irrlicht/CIrrDeviceLinux.h b/source/Irrlicht/CIrrDeviceLinux.h index 52dec83..9e3479f 100644 --- a/source/Irrlicht/CIrrDeviceLinux.h +++ b/source/Irrlicht/CIrrDeviceLinux.h @@ -20,12 +20,6 @@ #include #include #include -#ifdef _IRR_LINUX_X11_VIDMODE_ -#include -#endif -#ifdef _IRR_LINUX_X11_RANDR_ -#include -#endif #include #ifdef _IRR_LINUX_X11_XINPUT2_ @@ -101,12 +95,6 @@ namespace irr //! Activate any joysticks, and generate events for them. virtual bool activateJoysticks(core::array & joystickInfo) _IRR_OVERRIDE_; - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_; - //! gets text from the clipboard //! \return Returns 0 if no string is in there, otherwise utf-8 text. virtual const c8 *getTextFromClipboard() const; diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index aacc8f8..331c8e5 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -1012,25 +1012,6 @@ bool CIrrDeviceSDL::isWindowMinimized() const } -//! Set the current Gamma Value for the Display -bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - /* - // todo: Gamma in SDL takes ints, what does Irrlicht use? - return (SDL_SetGamma(red, green, blue) != -1); - */ - return false; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ -/* brightness = 0.f; - contrast = 0.f; - return (SDL_GetGamma(&red, &green, &blue) != -1);*/ - return false; -} - //! returns color format of the window. video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const { diff --git a/source/Irrlicht/CIrrDeviceSDL.h b/source/Irrlicht/CIrrDeviceSDL.h index d630de1..0539150 100644 --- a/source/Irrlicht/CIrrDeviceSDL.h +++ b/source/Irrlicht/CIrrDeviceSDL.h @@ -88,12 +88,6 @@ namespace irr //! Activate any joysticks, and generate events for them. virtual bool activateJoysticks(core::array & joystickInfo) _IRR_OVERRIDE_; - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_; - //! Get the device type virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_ { diff --git a/source/Irrlicht/CIrrDeviceStub.cpp b/source/Irrlicht/CIrrDeviceStub.cpp index 3bad68a..95e7c5d 100644 --- a/source/Irrlicht/CIrrDeviceStub.cpp +++ b/source/Irrlicht/CIrrDeviceStub.cpp @@ -363,60 +363,6 @@ bool CIrrDeviceStub::isDeviceMotionAvailable() return false; } -/*! -*/ -void CIrrDeviceStub::calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ) -{ - s32 i; - s32 value; - s32 rbright = (s32) ( relativebrightness * (65535.f / 4 ) ); - f32 rcontrast = 1.f / (255.f - ( relativecontrast * 127.5f ) ); - - gamma = gamma > 0.f ? 1.0f / gamma : 0.f; - - for ( i = 0; i < 256; ++i ) - { - value = (s32)(pow( rcontrast * i, gamma)*65535.f + 0.5f ); - ramp[i] = (u16) core::s32_clamp ( value + rbright, 0, 65535 ); - } - -} - -void CIrrDeviceStub::calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ) -{ - /* The following is adapted from a post by Garrett Bass on OpenGL - Gamedev list, March 4, 2000. - */ - f32 sum = 0.0; - s32 i, count = 0; - - gamma = 1.0; - for ( i = 1; i < 256; ++i ) { - if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { - f32 B = (f32)i / 256.f; - f32 A = ramp[i] / 65535.f; - sum += (f32) ( logf(A) / logf(B) ); - count++; - } - } - if ( count && sum ) { - gamma = 1.0f / (sum / count); - } - -} - -//! Set the current Gamma Value for the Display -bool CIrrDeviceStub::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - return false; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceStub::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - return false; -} - //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. void CIrrDeviceStub::setDoubleClickTime( u32 timeMs ) { diff --git a/source/Irrlicht/CIrrDeviceStub.h b/source/Irrlicht/CIrrDeviceStub.h index 546b2ba..d59277b 100644 --- a/source/Irrlicht/CIrrDeviceStub.h +++ b/source/Irrlicht/CIrrDeviceStub.h @@ -145,12 +145,6 @@ namespace irr //! Is device motion available. virtual bool isDeviceMotionAvailable() _IRR_OVERRIDE_; - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_; - //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. //! When set to 0 no double- and tripleclicks will be generated. virtual void setDoubleClickTime( u32 timeMs ) _IRR_OVERRIDE_; @@ -177,9 +171,6 @@ namespace irr */ virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent); - void calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ); - void calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ); - //! Checks whether the input device should take input from the IME bool acceptsIME(); diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 0ea188b..d8d1702 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -1383,46 +1383,6 @@ bool CIrrDeviceWin32::activateJoysticks(core::array & joystickInf } -//! Set the current Gamma Value for the Display -bool CIrrDeviceWin32::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - bool r; - u16 ramp[3][256]; - - calculateGammaRamp( ramp[0], red, brightness, contrast ); - calculateGammaRamp( ramp[1], green, brightness, contrast ); - calculateGammaRamp( ramp[2], blue, brightness, contrast ); - - HDC dc = GetDC(0); - r = SetDeviceGammaRamp ( dc, ramp ) == TRUE; - ReleaseDC(HWnd, dc); - return r; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - bool r; - u16 ramp[3][256]; - - HDC dc = GetDC(0); - r = GetDeviceGammaRamp ( dc, ramp ) == TRUE; - ReleaseDC(HWnd, dc); - - if (r) - { - calculateGammaFromRamp(red, ramp[0]); - calculateGammaFromRamp(green, ramp[1]); - calculateGammaFromRamp(blue, ramp[2]); - } - - brightness = 0.f; - contrast = 0.f; - - return r; -} - - //! Process system events void CIrrDeviceWin32::handleSystemMessages() { diff --git a/source/Irrlicht/CIrrDeviceWin32.h b/source/Irrlicht/CIrrDeviceWin32.h index 02c42b7..863f2a6 100644 --- a/source/Irrlicht/CIrrDeviceWin32.h +++ b/source/Irrlicht/CIrrDeviceWin32.h @@ -89,12 +89,6 @@ namespace irr //! Activate any joysticks, and generate events for them. virtual bool activateJoysticks(core::array & joystickInfo) _IRR_OVERRIDE_; - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_; - //! Remove all messages pending in the system message loop virtual void clearSystemMessages() _IRR_OVERRIDE_; diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 0aeb533..07c10cd 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -139,7 +139,6 @@ set(link_libs "$<$:gdi32>" "$<$:winmm>" ${X11_X11_LIB} - ${X11_Xxf86vm_LIB} ) # Source files -- 2.44.0