Added gamma setting function.

This commit is contained in:
Camilla Berglund 2012-02-07 02:29:02 +01:00
parent 55a34c6967
commit b35ef1ac53

View File

@ -35,6 +35,8 @@
#include "getopt.h"
#define STEP_SIZE 0.1f
static GLfloat gamma = 1.0f;
static void usage(void)
@ -42,6 +44,13 @@ static void usage(void)
printf("Usage: gammatest [-h] [-f]\n");
}
static void set_gamma(float value)
{
gamma = value;
printf("Gamma: %f\n", gamma);
glfwSetGamma(gamma);
}
static void key_callback(GLFWwindow window, int key, int action)
{
if (action != GLFW_PRESS)
@ -50,21 +59,27 @@ static void key_callback(GLFWwindow window, int key, int action)
switch (key)
{
case GLFW_KEY_ESCAPE:
{
glfwCloseWindow(window);
break;
}
case GLFW_KEY_KP_ADD:
case GLFW_KEY_Q:
gamma += 0.1f;
printf("Gamma: %f\n", gamma);
glfwSetGamma(gamma);
{
set_gamma(gamma + STEP_SIZE);
break;
}
case GLFW_KEY_KP_SUBTRACT:
case GLFW_KEY_W:
gamma -= 0.1f;
printf("Gamma: %f\n", gamma);
glfwSetGamma(gamma);
{
if (gamma - STEP_SIZE > 0.f)
set_gamma(gamma - STEP_SIZE);
break;
}
}
}
static void size_callback(GLFWwindow window, int width, int height)
@ -124,8 +139,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
glfwSetGamma(gamma);
printf("Gamma: %f\n", gamma);
set_gamma(1.f);
glfwSwapInterval(1);
glfwSetKeyCallback(key_callback);