From fe6fb57df00f64cc23f2d72172b67a01b80d09f1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 13:54:19 +0200 Subject: [PATCH] Updated Win32 implementation of gamma ramp API. --- src/win32/platform.h | 1 - src/win32/win32_gamma.c | 19 +++++-------------- src/win32/win32_init.c | 19 +++---------------- 3 files changed, 8 insertions(+), 31 deletions(-) mode change 100644 => 100755 src/win32/platform.h mode change 100644 => 100755 src/win32/win32_gamma.c mode change 100644 => 100755 src/win32/win32_init.c diff --git a/src/win32/platform.h b/src/win32/platform.h old mode 100644 new mode 100755 index fb9107b8..3ce580f2 --- a/src/win32/platform.h +++ b/src/win32/platform.h @@ -270,7 +270,6 @@ typedef struct _GLFWlibraryWin32 ATOM classAtom; // Window class atom HHOOK keyboardHook; // Keyboard hook handle DWORD foregroundLockTimeout; - HDC desktopDC; // Default monitor struct { diff --git a/src/win32/win32_gamma.c b/src/win32/win32_gamma.c old mode 100644 new mode 100755 index 71d2645f..f25df6e6 --- a/src/win32/win32_gamma.c +++ b/src/win32/win32_gamma.c @@ -41,14 +41,9 @@ // Save the gamma ramp to our internal copy //======================================================================== -void _glfwPlatformSaveGammaRamp(int ramp) +void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) { - if (!_glfwLibrary.gammaSize) - { - return; - } - _glfw_GetDeviceGammaRamp(_glfwLibrary.Win32.desktopDC, - _glfwLibrary.gammaRamp[ramp]); + _glfw_GetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp); } @@ -56,12 +51,8 @@ void _glfwPlatformSaveGammaRamp(int ramp) // Restore the gamma ramp to our internal copy of the gamma ramp //======================================================================== -void _glfwPlatformRestoreGammaRamp(int ramp) +void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp) { - if (!_glfwLibrary.gammaSize) - { - return; - } - _glfw_SetDeviceGammaRamp(_glfwLibrary.Win32.desktopDC, - _glfwLibrary.gammaRamp[ramp]); + _glfw_SetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp); } + diff --git a/src/win32/win32_init.c b/src/win32/win32_init.c old mode 100644 new mode 100755 index 54939cc3..4c8bfb22 --- a/src/win32/win32_init.c +++ b/src/win32/win32_init.c @@ -160,18 +160,9 @@ int _glfwPlatformInit(void) _glfwLibrary.Win32.instance = GetModuleHandle(NULL); - // Initialise the internal gamma ramp - _glfwLibrary.gammaSize = 256; - _glfwLibrary.gammaRamp[GLFW_GAMMA_ORIG] = - malloc(256 * sizeof(unsigned short) * 3); - _glfwLibrary.gammaRamp[GLFW_GAMMA_CURR] = - malloc(256 * sizeof(unsigned short) * 3); - - // Get the desktop DC - _glfwLibrary.Win32.desktopDC = GetDC(GetDesktopWindow()); - // Save the original gamma ramp - _glfwPlatformSaveGammaRamp(GLFW_GAMMA_ORIG); + _glfwLibrary.originalRampSize = 256; + _glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp); _glfwInitTimer(); @@ -186,11 +177,7 @@ int _glfwPlatformInit(void) int _glfwPlatformTerminate(void) { // Restore the original gamma ramp - _glfwPlatformRestoreGammaRamp(GLFW_GAMMA_ORIG); - - // Free the gamma ramps - free(_glfwLibrary.gammaRamp[GLFW_GAMMA_ORIG]); - free(_glfwLibrary.gammaRamp[GLFW_GAMMA_CURR]); + _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); if (_glfwLibrary.Win32.classAtom) {