From ca0dbdbb6e96ee4a9623dece45a4f7864f5291f0 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 6 Sep 2011 15:43:31 +0200
Subject: [PATCH] Simplified glfwSetGammaFormula to glfwSetGamma.
---
include/GL/glfw3.h | 2 +-
readme.html | 2 +-
src/gamma.c | 10 ++--------
tests/gamma.c | 40 ++++++++--------------------------------
4 files changed, 12 insertions(+), 42 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index efb22e87..d583c364 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -535,7 +535,7 @@ GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount);
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
/* Gamma ramp functions */
-GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain);
+GLFWAPI void glfwSetGamma(float gamma);
GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
diff --git a/readme.html b/readme.html
index 28c8de34..f93c0dda 100644
--- a/readme.html
+++ b/readme.html
@@ -282,7 +282,7 @@ version of GLFW.
Added sharing
simple OpenGL object sharing test program
Added a parameter to glfwOpenWindow
for specifying a context the new window's context will share objects with
Added initial window title parameter to glfwOpenWindow
- Added glfwSetGammaFormula
, glfwSetGammaRamp
and glfwGetGammaRamp
functions and GLFWgammaramp
type for monitor gamma ramp control
+ Added glfwSetGamma
, glfwSetGammaRamp
and glfwGetGammaRamp
functions and GLFWgammaramp
type for monitor gamma ramp control
Changed buffer bit depth parameters of glfwOpenWindow
to window hints
Renamed glfw.h
to glfw3.h
to avoid conflicts with 2.x series
Renamed GLFW_WINDOW
token to GLFW_WINDOWED
diff --git a/src/gamma.c b/src/gamma.c
index d0c45d01..787098a0 100644
--- a/src/gamma.c
+++ b/src/gamma.c
@@ -38,10 +38,10 @@
//////////////////////////////////////////////////////////////////////////
//========================================================================
-// Calculate the gamma ramp table from specified values
+// Calculate a gamma ramp from the specified value and set it
//========================================================================
-GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
+GLFWAPI void glfwSetGamma(float gamma)
{
int i, size = 256;
GLFWgammaramp ramp;
@@ -59,12 +59,6 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
// Apply gamma
value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f;
- // Apply gain
- value = gain * (value - 32767.5f) + 32767.5f;
-
- // Apply black-level
- value += blacklevel * 65535.f;
-
// Clamp values
if (value < 0.f)
value = 0.f;
diff --git a/tests/gamma.c b/tests/gamma.c
index 0c567b22..c6d259ca 100644
--- a/tests/gamma.c
+++ b/tests/gamma.c
@@ -35,9 +35,7 @@
#include "getopt.h"
-static GLfloat ggamma = 1.0f;
-static GLfloat ggain = 1.0f;
-static GLfloat gblacklevel = 0.0f;
+static GLfloat gamma = 1.0f;
static void usage(void)
{
@@ -55,36 +53,15 @@ static void key_callback(GLFWwindow window, int key, int action)
glfwCloseWindow(window);
break;
case GLFW_KEY_Q:
- ggamma += 0.1f;
- printf("Gamma: %f\n", ggamma);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
+ gamma += 0.1f;
+ printf("Gamma: %f\n", gamma);
+ glfwSetGamma(gamma);
break;
case GLFW_KEY_W:
- ggamma -= 0.1f;
- printf("Gamma: %f\n", ggamma);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
+ gamma -= 0.1f;
+ printf("Gamma: %f\n", gamma);
+ glfwSetGamma(gamma);
break;
- case GLFW_KEY_A:
- ggain += 0.1f;
- printf("Gain: %f\n", ggain);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
- break;
- case GLFW_KEY_S:
- ggain -= 0.1f;
- printf("Gain: %f\n", ggain);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
- break;
- case GLFW_KEY_Z:
- gblacklevel += 0.1f;
- printf("Black Level: %f\n", gblacklevel);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
- break;
- case GLFW_KEY_X:
- gblacklevel -= 0.1f;
- printf("Black Level: %f\n", gblacklevel);
- glfwSetGammaFormula( ggamma, gblacklevel, ggain );
- break;
-
}
}
@@ -145,8 +122,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
- printf("Gamma: %f\nGain: %f\nBlack Level: %f\n",
- ggamma, ggain, gblacklevel);
+ printf("Gamma: %f\n", gamma);
glfwSwapInterval(1);
glfwSetKeyCallback(key_callback);