From fe6fb57df00f64cc23f2d72172b67a01b80d09f1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 13:54:19 +0200 Subject: [PATCH 1/5] 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) { From 0374c11c438cbbebf0cd59620308be49c02e9d63 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 14:09:26 +0200 Subject: [PATCH 2/5] Corrected API version. --- src/win32/win32_gamma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/win32_gamma.c b/src/win32/win32_gamma.c index f25df6e6..6208909a 100755 --- a/src/win32/win32_gamma.c +++ b/src/win32/win32_gamma.c @@ -1,7 +1,7 @@ //======================================================================== // GLFW - An OpenGL framework // Platform: Win32/WGL -// API version: 2.7 +// API version: 3.0 // WWW: http://www.glfw.org/ //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard From 21f6f695a658277e01143a0499aba2d4a54679e6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 14:10:07 +0200 Subject: [PATCH 3/5] Corrected copyright. --- src/win32/win32_gamma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/win32/win32_gamma.c b/src/win32/win32_gamma.c index 6208909a..c85a66d2 100755 --- a/src/win32/win32_gamma.c +++ b/src/win32/win32_gamma.c @@ -4,8 +4,7 @@ // API version: 3.0 // WWW: http://www.glfw.org/ //------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2010 Camilla Berglund +// Copyright (c) 2010 Camilla Berglund // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages From c592cd5dbfcb87541afc42b75a1e9ab94641c9a9 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 14:13:39 +0200 Subject: [PATCH 4/5] Function comment header updates. --- src/gamma.c | 2 +- src/win32/win32_gamma.c | 10 +++++----- src/x11/x11_gamma.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/gamma.c mode change 100644 => 100755 src/x11/x11_gamma.c diff --git a/src/gamma.c b/src/gamma.c old mode 100644 new mode 100755 index ff97d600..b2416a98 --- a/src/gamma.c +++ b/src/gamma.c @@ -82,7 +82,7 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain) //======================================================================== -// Return the currently set gamma ramp +// Return the cached currently set gamma ramp //======================================================================== GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp) diff --git a/src/win32/win32_gamma.c b/src/win32/win32_gamma.c index c85a66d2..fc01cc44 100755 --- a/src/win32/win32_gamma.c +++ b/src/win32/win32_gamma.c @@ -32,12 +32,12 @@ #include -//************************************************************************ -//**** GLFW internal functions **** -//************************************************************************ +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// //======================================================================== -// Save the gamma ramp to our internal copy +// Retrieve the currently set gamma ramp //======================================================================== void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) @@ -47,7 +47,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) //======================================================================== -// Restore the gamma ramp to our internal copy of the gamma ramp +// Push the specified gamma ramp to the monitor //======================================================================== void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp) diff --git a/src/x11/x11_gamma.c b/src/x11/x11_gamma.c old mode 100644 new mode 100755 index 264e4c98..85522bef --- a/src/x11/x11_gamma.c +++ b/src/x11/x11_gamma.c @@ -33,12 +33,12 @@ #include -//************************************************************************ -//**** GLFW internal functions **** -//************************************************************************ +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// //======================================================================== -// Save the original gamma ramp so that we can restore it later +// Retrieve the currently set gamma ramp //======================================================================== void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) @@ -78,7 +78,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) //======================================================================== -// Make the specified gamma ramp current +// Push the specified gamma ramp to the monitor //======================================================================== void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp) From 66754f135889ed625d9fb7ae16fdc9b5e954d6d9 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Oct 2010 14:14:50 +0200 Subject: [PATCH 5/5] Removed executable bits (gah). --- src/gamma.c | 0 src/win32/platform.h | 0 src/win32/win32_gamma.c | 0 src/win32/win32_init.c | 0 src/x11/x11_gamma.c | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/gamma.c mode change 100755 => 100644 src/win32/platform.h mode change 100755 => 100644 src/win32/win32_gamma.c mode change 100755 => 100644 src/win32/win32_init.c mode change 100755 => 100644 src/x11/x11_gamma.c diff --git a/src/gamma.c b/src/gamma.c old mode 100755 new mode 100644 diff --git a/src/win32/platform.h b/src/win32/platform.h old mode 100755 new mode 100644 diff --git a/src/win32/win32_gamma.c b/src/win32/win32_gamma.c old mode 100755 new mode 100644 diff --git a/src/win32/win32_init.c b/src/win32/win32_init.c old mode 100755 new mode 100644 diff --git a/src/x11/x11_gamma.c b/src/x11/x11_gamma.c old mode 100755 new mode 100644