mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Added gamma setting function.
This commit is contained in:
parent
55a34c6967
commit
b35ef1ac53
@ -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,20 +59,26 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user