Brought back non-relative gamma ramp generation.

This commit is contained in:
Camilla Berglund 2011-09-20 15:44:54 +02:00
parent e31042c0dc
commit 554bf5d321

View File

@ -62,10 +62,6 @@ GLFWAPI void glfwSetGamma(float gamma)
for (i = 0; i < size; i++)
{
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
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)
value = 65535.f;
// Use original gamma as reference
diffRed = _glfwLibrary.originalRamp.red[i] - pow1;
diffGreen = _glfwLibrary.originalRamp.green[i] - pow1;
diffBlue = _glfwLibrary.originalRamp.blue[i] - pow1;
// 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;
// Set the gamma ramp values
ramp.red[i] = (unsigned short) value;
ramp.green[i] = (unsigned short) value;
ramp.blue[i] = (unsigned short) value;
}
glfwSetGammaRamp(&ramp);