mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-27 04:28:52 -05:00
Brought back non-relative gamma ramp generation.
This commit is contained in:
parent
e31042c0dc
commit
554bf5d321
22
src/gamma.c
22
src/gamma.c
|
@ -62,10 +62,6 @@ GLFWAPI void glfwSetGamma(float gamma)
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
float value = (float) i / ((float) (size - 1));
|
float value = (float) i / ((float) (size - 1));
|
||||||
int diffRed, diffGreen, diffBlue, newRed, newGreen, newBlue, pow1;
|
|
||||||
|
|
||||||
// Reference our gamma 1.0f
|
|
||||||
pow1 = value * 65535.f + 0.5;
|
|
||||||
|
|
||||||
// Apply gamma
|
// Apply gamma
|
||||||
value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f;
|
value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f;
|
||||||
|
@ -76,20 +72,10 @@ GLFWAPI void glfwSetGamma(float gamma)
|
||||||
else if (value > 65535.f)
|
else if (value > 65535.f)
|
||||||
value = 65535.f;
|
value = 65535.f;
|
||||||
|
|
||||||
// Use original gamma as reference
|
// Set the gamma ramp values
|
||||||
diffRed = _glfwLibrary.originalRamp.red[i] - pow1;
|
ramp.red[i] = (unsigned short) value;
|
||||||
diffGreen = _glfwLibrary.originalRamp.green[i] - pow1;
|
ramp.green[i] = (unsigned short) value;
|
||||||
diffBlue = _glfwLibrary.originalRamp.blue[i] - pow1;
|
ramp.blue[i] = (unsigned short) value;
|
||||||
|
|
||||||
// Calculate new values
|
|
||||||
newRed = diffRed + (unsigned short) value;
|
|
||||||
newGreen = diffGreen + (unsigned short) value;
|
|
||||||
newBlue = diffBlue + (unsigned short) value;
|
|
||||||
|
|
||||||
// Set the gamma ramp values (whilst clamping)
|
|
||||||
ramp.red[i] = newRed > 65535 ? 65535 : newRed < 0 ? 0 : newRed;
|
|
||||||
ramp.green[i] = newGreen > 65535 ? 65535 : newGreen < 0 ? 0 : newGreen;
|
|
||||||
ramp.blue[i] = newBlue > 65535 ? 65535 : newBlue < 0 ? 0 : newBlue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetGammaRamp(&ramp);
|
glfwSetGammaRamp(&ramp);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user