1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Updated Win32 implementation of gamma ramp API.

This commit is contained in:
Camilla Berglund 2010-10-14 13:54:19 +02:00
parent 6d87163aa2
commit fe6fb57df0
3 changed files with 8 additions and 31 deletions

1
src/win32/platform.h Normal file → Executable file
View File

@ -270,7 +270,6 @@ typedef struct _GLFWlibraryWin32
ATOM classAtom; // Window class atom ATOM classAtom; // Window class atom
HHOOK keyboardHook; // Keyboard hook handle HHOOK keyboardHook; // Keyboard hook handle
DWORD foregroundLockTimeout; DWORD foregroundLockTimeout;
HDC desktopDC;
// Default monitor // Default monitor
struct { struct {

19
src/win32/win32_gamma.c Normal file → Executable file
View File

@ -41,14 +41,9 @@
// Save the gamma ramp to our internal copy // Save the gamma ramp to our internal copy
//======================================================================== //========================================================================
void _glfwPlatformSaveGammaRamp(int ramp) void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
{ {
if (!_glfwLibrary.gammaSize) _glfw_GetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp);
{
return;
}
_glfw_GetDeviceGammaRamp(_glfwLibrary.Win32.desktopDC,
_glfwLibrary.gammaRamp[ramp]);
} }
@ -56,12 +51,8 @@ void _glfwPlatformSaveGammaRamp(int ramp)
// Restore the gamma ramp to our internal copy of the gamma 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) _glfw_SetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp);
{
return;
}
_glfw_SetDeviceGammaRamp(_glfwLibrary.Win32.desktopDC,
_glfwLibrary.gammaRamp[ramp]);
} }

19
src/win32/win32_init.c Normal file → Executable file
View File

@ -160,18 +160,9 @@ int _glfwPlatformInit(void)
_glfwLibrary.Win32.instance = GetModuleHandle(NULL); _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 // Save the original gamma ramp
_glfwPlatformSaveGammaRamp(GLFW_GAMMA_ORIG); _glfwLibrary.originalRampSize = 256;
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwInitTimer(); _glfwInitTimer();
@ -186,11 +177,7 @@ int _glfwPlatformInit(void)
int _glfwPlatformTerminate(void) int _glfwPlatformTerminate(void)
{ {
// Restore the original gamma ramp // Restore the original gamma ramp
_glfwPlatformRestoreGammaRamp(GLFW_GAMMA_ORIG); _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
// Free the gamma ramps
free(_glfwLibrary.gammaRamp[GLFW_GAMMA_ORIG]);
free(_glfwLibrary.gammaRamp[GLFW_GAMMA_CURR]);
if (_glfwLibrary.Win32.classAtom) if (_glfwLibrary.Win32.classAtom)
{ {