Drop gamma ramp code

We definitely won't be wanting to set the gamma for the entire display in the future.
This commit is contained in:
sfan5 2022-07-18 21:19:30 +02:00
parent abebac8bd4
commit 538c9e5cde
11 changed files with 1 additions and 258 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -20,12 +20,6 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#ifdef _IRR_LINUX_X11_VIDMODE_
#include <X11/extensions/xf86vmode.h>
#endif
#ifdef _IRR_LINUX_X11_RANDR_
#include <X11/extensions/Xrandr.h>
#endif
#include <X11/keysym.h>
#ifdef _IRR_LINUX_X11_XINPUT2_
@ -101,12 +95,6 @@ namespace irr
//! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & 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;

View File

@ -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
{

View File

@ -88,12 +88,6 @@ namespace irr
//! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & 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_
{

View File

@ -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 )
{

View File

@ -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();

View File

@ -1383,46 +1383,6 @@ bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & 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()
{

View File

@ -89,12 +89,6 @@ namespace irr
//! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & 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_;

View File

@ -139,7 +139,6 @@ set(link_libs
"$<$<PLATFORM_ID:Windows>:gdi32>"
"$<$<PLATFORM_ID:Windows>:winmm>"
${X11_X11_LIB}
${X11_Xxf86vm_LIB}
)
# Source files