mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Simplified glfwSetGammaFormula to glfwSetGamma.
This commit is contained in:
parent
b11681a3ab
commit
ca0dbdbb6e
@ -535,7 +535,7 @@ GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount);
|
|||||||
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
|
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
|
||||||
|
|
||||||
/* Gamma ramp functions */
|
/* Gamma ramp functions */
|
||||||
GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain);
|
GLFWAPI void glfwSetGamma(float gamma);
|
||||||
GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
|
GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
|
||||||
GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
|
GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ version of GLFW.</p>
|
|||||||
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
|
<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 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 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>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.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>
|
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>
|
||||||
|
10
src/gamma.c
10
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;
|
int i, size = 256;
|
||||||
GLFWgammaramp ramp;
|
GLFWgammaramp ramp;
|
||||||
@ -59,12 +59,6 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
|
|||||||
// 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;
|
||||||
|
|
||||||
// Apply gain
|
|
||||||
value = gain * (value - 32767.5f) + 32767.5f;
|
|
||||||
|
|
||||||
// Apply black-level
|
|
||||||
value += blacklevel * 65535.f;
|
|
||||||
|
|
||||||
// Clamp values
|
// Clamp values
|
||||||
if (value < 0.f)
|
if (value < 0.f)
|
||||||
value = 0.f;
|
value = 0.f;
|
||||||
|
@ -35,9 +35,7 @@
|
|||||||
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
static GLfloat ggamma = 1.0f;
|
static GLfloat gamma = 1.0f;
|
||||||
static GLfloat ggain = 1.0f;
|
|
||||||
static GLfloat gblacklevel = 0.0f;
|
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
@ -55,36 +53,15 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
glfwCloseWindow(window);
|
glfwCloseWindow(window);
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_Q:
|
case GLFW_KEY_Q:
|
||||||
ggamma += 0.1f;
|
gamma += 0.1f;
|
||||||
printf("Gamma: %f\n", ggamma);
|
printf("Gamma: %f\n", gamma);
|
||||||
glfwSetGammaFormula( ggamma, gblacklevel, ggain );
|
glfwSetGamma(gamma);
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_W:
|
case GLFW_KEY_W:
|
||||||
ggamma -= 0.1f;
|
gamma -= 0.1f;
|
||||||
printf("Gamma: %f\n", ggamma);
|
printf("Gamma: %f\n", gamma);
|
||||||
glfwSetGammaFormula( ggamma, gblacklevel, ggain );
|
glfwSetGamma(gamma);
|
||||||
break;
|
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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Gamma: %f\nGain: %f\nBlack Level: %f\n",
|
printf("Gamma: %f\n", gamma);
|
||||||
ggamma, ggain, gblacklevel);
|
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(key_callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user