Simplified glfwSetGammaFormula to glfwSetGamma.

This commit is contained in:
Camilla Berglund 2011-09-06 15:43:31 +02:00
parent b11681a3ab
commit ca0dbdbb6e
4 changed files with 12 additions and 42 deletions

View File

@ -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);

View File

@ -282,7 +282,7 @@ version of GLFW.</p>
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>
<li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
<li>Added <code>glfwSetGammaFormula</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li>
<li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li>
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
<li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li>
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>

View File

@ -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;

View File

@ -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);