mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Take into account the original gamma before applying gamma.
This commit is contained in:
+28
-9
@@ -48,12 +48,21 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
||||
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 now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
||||
// i.e. 256. I don't think anyone would want to change the gamma on
|
||||
// Mac anyway...
|
||||
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
||||
return;
|
||||
|
||||
CGGetDisplayTransferByTable(CGMainDisplayID(), 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;
|
||||
ramp->red[i] = red[i] * 65535;
|
||||
ramp->green[i] = green[i] * 65535;
|
||||
ramp->blue[i] = blue[i] * 65535;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,15 +74,25 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
||||
void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
|
||||
{
|
||||
int i;
|
||||
int size = GLFW_GAMMA_RAMP_SIZE;
|
||||
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++)
|
||||
|
||||
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
||||
// i.e. 256. I don't think anyone would want to change the gamma on
|
||||
// Mac anyway...
|
||||
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
||||
return;
|
||||
|
||||
// Convert to float & take the difference of the original gamma and
|
||||
// the linear function.
|
||||
for (i = 0; i < 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;
|
||||
red[i] = ramp->red[i] / 65535.f;
|
||||
green[i] = ramp->green[i] / 65535.f;
|
||||
blue[i] = ramp->blue[i] / 65535.f;
|
||||
}
|
||||
CGSetDisplayTransferByTable(0, GLFW_GAMMA_RAMP_SIZE, red, green, blue);
|
||||
CGSetDisplayTransferByTable(CGMainDisplayID(), GLFW_GAMMA_RAMP_SIZE, red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user