We definitely won't be wanting to set the gamma for the entire display in the future.
#undef _IRR_COMPILE_WITH_X11_\r
#endif\r
\r
-//! On some Linux systems the XF86 vidmode extension, X11 RandR, or XInput2 are missing.\r
-//! Use these defines to add/remove support for those dependencies as needed.\r
-//! XInput2 (library called Xi) is currently only used to support touch-input.\r
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)\r
-#define _IRR_LINUX_X11_VIDMODE_\r
-//#define _IRR_LINUX_X11_RANDR_\r
-//#define _IRR_LINUX_X11_XINPUT2_\r
-#ifdef NO_IRR_LINUX_X11_VIDMODE_\r
-#undef _IRR_LINUX_X11_VIDMODE_\r
-#endif\r
-#ifdef NO_IRR_LINUX_X11_RANDR_\r
-#undef _IRR_LINUX_X11_RANDR_\r
-#endif\r
+//! XInput2 (library called Xi) is currently only used to support touch-input.\r
#ifdef NO_IRR_LINUX_X11_XINPUT2_\r
#undef _IRR_LINUX_X11_XINPUT2_\r
#endif\r
//! Is device motion available.\r
virtual bool isDeviceMotionAvailable() = 0;\r
\r
- //! Set the current Gamma Value for the Display\r
- virtual bool setGammaRamp(f32 red, f32 green, f32 blue,\r
- f32 relativebrightness, f32 relativecontrast) =0;\r
-\r
- //! Get the current Gamma Value for the Display\r
- virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue,\r
- f32 &brightness, f32 &contrast) =0;\r
-\r
//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.\r
/** When set to 0 no double- and tripleclicks will be generated.\r
\param timeMs maximal time in milliseconds for two consecutive clicks to be recognized as double click\r
}\r
\r
\r
-//! Set the current Gamma Value for the Display\r
-bool CIrrDeviceLinux::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )\r
-{\r
- #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_)\r
- s32 eventbase, errorbase;\r
- #ifdef _IRR_LINUX_X11_VIDMODE_\r
- if (XF86VidModeQueryExtension(XDisplay, &eventbase, &errorbase))\r
- {\r
- XF86VidModeGamma gamma;\r
- gamma.red=red;\r
- gamma.green=green;\r
- gamma.blue=blue;\r
- XF86VidModeSetGamma(XDisplay, Screennr, &gamma);\r
- return true;\r
- }\r
- #endif\r
- #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_)\r
- else\r
- #endif\r
- #ifdef _IRR_LINUX_X11_RANDR_\r
- if (XRRQueryExtension(XDisplay, &eventbase, &errorbase))\r
- {\r
- XRRQueryVersion(XDisplay, &eventbase, &errorbase); // major, minor\r
- if (eventbase>=1 && errorbase>1)\r
- {\r
- #if (RANDR_MAJOR>1 || RANDR_MINOR>1)\r
- XRRCrtcGamma *gamma = XRRGetCrtcGamma(XDisplay, Screennr);\r
- if (gamma)\r
- {\r
- *gamma->red=(u16)red;\r
- *gamma->green=(u16)green;\r
- *gamma->blue=(u16)blue;\r
- XRRSetCrtcGamma(XDisplay, Screennr, gamma);\r
- XRRFreeGamma(gamma);\r
- return true;\r
- }\r
- #endif\r
- }\r
- }\r
- #endif\r
- #endif\r
- return false;\r
-}\r
-\r
-\r
-//! Get the current Gamma Value for the Display\r
-bool CIrrDeviceLinux::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )\r
-{\r
- brightness = 0.f;\r
- contrast = 0.f;\r
- #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_)\r
- s32 eventbase, errorbase;\r
- #ifdef _IRR_LINUX_X11_VIDMODE_\r
- if (XF86VidModeQueryExtension(XDisplay, &eventbase, &errorbase))\r
- {\r
- XF86VidModeGamma gamma;\r
- XF86VidModeGetGamma(XDisplay, Screennr, &gamma);\r
- red = gamma.red;\r
- green = gamma.green;\r
- blue = gamma.blue;\r
- return true;\r
- }\r
- #endif\r
- #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_)\r
- else\r
- #endif\r
- #ifdef _IRR_LINUX_X11_RANDR_\r
- if (XRRQueryExtension(XDisplay, &eventbase, &errorbase))\r
- {\r
- XRRQueryVersion(XDisplay, &eventbase, &errorbase); // major, minor\r
- if (eventbase>=1 && errorbase>1)\r
- {\r
- #if (RANDR_MAJOR>1 || RANDR_MINOR>1)\r
- XRRCrtcGamma *gamma = XRRGetCrtcGamma(XDisplay, Screennr);\r
- if (gamma)\r
- {\r
- red = *gamma->red;\r
- green = *gamma->green;\r
- blue= *gamma->blue;\r
- XRRFreeGamma(gamma);\r
- return true;\r
- }\r
- #endif\r
- }\r
- }\r
- #endif\r
- #endif\r
- return false;\r
-}\r
-\r
-\r
//! gets text from the clipboard\r
//! \return Returns 0 if no string is in there, otherwise utf-8 text.\r
const c8 *CIrrDeviceLinux::getTextFromClipboard() const\r
#include <X11/Xlib.h>\r
#include <X11/Xutil.h>\r
#include <X11/cursorfont.h>\r
-#ifdef _IRR_LINUX_X11_VIDMODE_\r
-#include <X11/extensions/xf86vmode.h>\r
-#endif\r
-#ifdef _IRR_LINUX_X11_RANDR_\r
-#include <X11/extensions/Xrandr.h>\r
-#endif\r
#include <X11/keysym.h>\r
\r
#ifdef _IRR_LINUX_X11_XINPUT2_\r
//! Activate any joysticks, and generate events for them.\r
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;\r
\r
- //! Set the current Gamma Value for the Display\r
- virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_;\r
-\r
- //! Get the current Gamma Value for the Display\r
- virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_;\r
-\r
//! gets text from the clipboard\r
//! \return Returns 0 if no string is in there, otherwise utf-8 text.\r
virtual const c8 *getTextFromClipboard() const;\r
}\r
\r
\r
-//! Set the current Gamma Value for the Display\r
-bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )\r
-{\r
- /*\r
- // todo: Gamma in SDL takes ints, what does Irrlicht use?\r
- return (SDL_SetGamma(red, green, blue) != -1);\r
- */\r
- return false;\r
-}\r
-\r
-//! Get the current Gamma Value for the Display\r
-bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )\r
-{\r
-/* brightness = 0.f;\r
- contrast = 0.f;\r
- return (SDL_GetGamma(&red, &green, &blue) != -1);*/\r
- return false;\r
-}\r
-\r
//! returns color format of the window.\r
video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const\r
{\r
//! Activate any joysticks, and generate events for them.\r
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;\r
\r
- //! Set the current Gamma Value for the Display\r
- virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_;\r
-\r
- //! Get the current Gamma Value for the Display\r
- virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_;\r
-\r
//! Get the device type\r
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_\r
{\r
return false;\r
}\r
\r
-/*!\r
-*/\r
-void CIrrDeviceStub::calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast )\r
-{\r
- s32 i;\r
- s32 value;\r
- s32 rbright = (s32) ( relativebrightness * (65535.f / 4 ) );\r
- f32 rcontrast = 1.f / (255.f - ( relativecontrast * 127.5f ) );\r
-\r
- gamma = gamma > 0.f ? 1.0f / gamma : 0.f;\r
-\r
- for ( i = 0; i < 256; ++i )\r
- {\r
- value = (s32)(pow( rcontrast * i, gamma)*65535.f + 0.5f );\r
- ramp[i] = (u16) core::s32_clamp ( value + rbright, 0, 65535 );\r
- }\r
-\r
-}\r
-\r
-void CIrrDeviceStub::calculateGammaFromRamp ( f32 &gamma, const u16 *ramp )\r
-{\r
- /* The following is adapted from a post by Garrett Bass on OpenGL\r
- Gamedev list, March 4, 2000.\r
- */\r
- f32 sum = 0.0;\r
- s32 i, count = 0;\r
-\r
- gamma = 1.0;\r
- for ( i = 1; i < 256; ++i ) {\r
- if ( (ramp[i] != 0) && (ramp[i] != 65535) ) {\r
- f32 B = (f32)i / 256.f;\r
- f32 A = ramp[i] / 65535.f;\r
- sum += (f32) ( logf(A) / logf(B) );\r
- count++;\r
- }\r
- }\r
- if ( count && sum ) {\r
- gamma = 1.0f / (sum / count);\r
- }\r
-\r
-}\r
-\r
-//! Set the current Gamma Value for the Display\r
-bool CIrrDeviceStub::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )\r
-{\r
- return false;\r
-}\r
-\r
-//! Get the current Gamma Value for the Display\r
-bool CIrrDeviceStub::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )\r
-{\r
- return false;\r
-}\r
-\r
//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.\r
void CIrrDeviceStub::setDoubleClickTime( u32 timeMs )\r
{\r
//! Is device motion available.\r
virtual bool isDeviceMotionAvailable() _IRR_OVERRIDE_;\r
\r
- //! Set the current Gamma Value for the Display\r
- virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_;\r
-\r
- //! Get the current Gamma Value for the Display\r
- virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_;\r
-\r
//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.\r
//! When set to 0 no double- and tripleclicks will be generated.\r
virtual void setDoubleClickTime( u32 timeMs ) _IRR_OVERRIDE_;\r
*/\r
virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent);\r
\r
- void calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast );\r
- void calculateGammaFromRamp ( f32 &gamma, const u16 *ramp );\r
-\r
//! Checks whether the input device should take input from the IME\r
bool acceptsIME();\r
\r
}\r
\r
\r
-//! Set the current Gamma Value for the Display\r
-bool CIrrDeviceWin32::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )\r
-{\r
- bool r;\r
- u16 ramp[3][256];\r
-\r
- calculateGammaRamp( ramp[0], red, brightness, contrast );\r
- calculateGammaRamp( ramp[1], green, brightness, contrast );\r
- calculateGammaRamp( ramp[2], blue, brightness, contrast );\r
-\r
- HDC dc = GetDC(0);\r
- r = SetDeviceGammaRamp ( dc, ramp ) == TRUE;\r
- ReleaseDC(HWnd, dc);\r
- return r;\r
-}\r
-\r
-//! Get the current Gamma Value for the Display\r
-bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )\r
-{\r
- bool r;\r
- u16 ramp[3][256];\r
-\r
- HDC dc = GetDC(0);\r
- r = GetDeviceGammaRamp ( dc, ramp ) == TRUE;\r
- ReleaseDC(HWnd, dc);\r
-\r
- if (r)\r
- {\r
- calculateGammaFromRamp(red, ramp[0]);\r
- calculateGammaFromRamp(green, ramp[1]);\r
- calculateGammaFromRamp(blue, ramp[2]);\r
- }\r
-\r
- brightness = 0.f;\r
- contrast = 0.f;\r
-\r
- return r;\r
-}\r
-\r
-\r
//! Process system events\r
void CIrrDeviceWin32::handleSystemMessages()\r
{\r
//! Activate any joysticks, and generate events for them.\r
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;\r
\r
- //! Set the current Gamma Value for the Display\r
- virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_;\r
-\r
- //! Get the current Gamma Value for the Display\r
- virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_;\r
-\r
//! Remove all messages pending in the system message loop\r
virtual void clearSystemMessages() _IRR_OVERRIDE_;\r
\r
"$<$<PLATFORM_ID:Windows>:gdi32>"
"$<$<PLATFORM_ID:Windows>:winmm>"
${X11_X11_LIB}
- ${X11_Xxf86vm_LIB}
)
# Source files