mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Fixed order of operations bug in gamma test.
This commit is contained in:
parent
1961cecb7c
commit
2e1bc043ef
@ -45,11 +45,15 @@ static void usage(void)
|
||||
printf("Usage: gamma [-h] [-f]\n");
|
||||
}
|
||||
|
||||
static void set_gamma(float value)
|
||||
static void set_gamma(GLFWwindow* window, float value)
|
||||
{
|
||||
GLFWmonitor* monitor = glfwGetWindowMonitor(window);
|
||||
if (!monitor)
|
||||
monitor = glfwGetPrimaryMonitor();
|
||||
|
||||
gamma_value = value;
|
||||
printf("Gamma: %f\n", gamma_value);
|
||||
glfwSetGamma(glfwGetPrimaryMonitor(), gamma_value);
|
||||
glfwSetGamma(monitor, gamma_value);
|
||||
}
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
@ -79,7 +83,7 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
||||
case GLFW_KEY_KP_ADD:
|
||||
case GLFW_KEY_Q:
|
||||
{
|
||||
set_gamma(gamma_value + STEP_SIZE);
|
||||
set_gamma(window, gamma_value + STEP_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -87,7 +91,7 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
||||
case GLFW_KEY_W:
|
||||
{
|
||||
if (gamma_value - STEP_SIZE > 0.f)
|
||||
set_gamma(gamma_value - STEP_SIZE);
|
||||
set_gamma(window, gamma_value - STEP_SIZE);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -105,6 +109,11 @@ int main(int argc, char** argv)
|
||||
GLFWmonitor* monitor = NULL;
|
||||
GLFWwindow* window;
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
if (!glfwInit())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
while ((ch = getopt(argc, argv, "fh")) != -1)
|
||||
{
|
||||
switch (ch)
|
||||
@ -123,11 +132,6 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
if (!glfwInit())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
||||
@ -147,7 +151,7 @@ int main(int argc, char** argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_gamma(1.f);
|
||||
set_gamma(window, 1.f);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
Loading…
Reference in New Issue
Block a user