From 688772111d56526b7297b9dcf31eb7cf12c20fdc Mon Sep 17 00:00:00 2001 From: Tai Chi Minh Ralph Eastwood Date: Mon, 12 Sep 2011 22:16:28 +0100 Subject: [PATCH] Initial implementation of gamma through Cocoa. --- src/cocoa_gamma.m | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/cocoa_gamma.m b/src/cocoa_gamma.m index ce69e312..ffb70f51 100644 --- a/src/cocoa_gamma.m +++ b/src/cocoa_gamma.m @@ -43,6 +43,18 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) { + uint32_t sampleCount; + int i; + CGGammaValue red[GLFW_GAMMA_RAMP_SIZE]; + CGGammaValue green[GLFW_GAMMA_RAMP_SIZE]; + CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE]; + CGGetDisplayTransferByTable(0, GLFW_GAMMA_RAMP_SIZE, red, green, blue, &sampleCount); + for (i = 0; i < GLFW_GAMMA_RAMP_SIZE; i++) + { + _glfwLibrary.currentRamp.red[i] = red[i] * 65535; + _glfwLibrary.currentRamp.green[i] = green[i] * 65535; + _glfwLibrary.currentRamp.blue[i] = blue[i] * 65535; + } } @@ -52,5 +64,16 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp) { + int i; + CGGammaValue red[GLFW_GAMMA_RAMP_SIZE]; + CGGammaValue green[GLFW_GAMMA_RAMP_SIZE]; + CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE]; + for (i = 0; i < GLFW_GAMMA_RAMP_SIZE; i++) + { + red[i] = ((float)_glfwLibrary.currentRamp.red[i]) / 65535.0f; + blue[i] = ((float)_glfwLibrary.currentRamp.green[i]) / 65535.0f; + green[i] = ((float)_glfwLibrary.currentRamp.blue[i]) / 65535.0f; + } + CGSetDisplayTransferByTable(0, GLFW_GAMMA_RAMP_SIZE, red, green, blue); }