From 554bf5d321d681bc9a6382702568403581f9bd20 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 20 Sep 2011 15:44:54 +0200 Subject: [PATCH] Brought back non-relative gamma ramp generation. --- src/gamma.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/gamma.c b/src/gamma.c index 9723a0ca..34cb22f5 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -62,34 +62,20 @@ 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; - + // Clamp values if (value < 0.f) value = 0.f; 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);