mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +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");
|
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;
|
gamma_value = value;
|
||||||
printf("Gamma: %f\n", gamma_value);
|
printf("Gamma: %f\n", gamma_value);
|
||||||
glfwSetGamma(glfwGetPrimaryMonitor(), gamma_value);
|
glfwSetGamma(monitor, gamma_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
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_KP_ADD:
|
||||||
case GLFW_KEY_Q:
|
case GLFW_KEY_Q:
|
||||||
{
|
{
|
||||||
set_gamma(gamma_value + STEP_SIZE);
|
set_gamma(window, gamma_value + STEP_SIZE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +91,7 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
|||||||
case GLFW_KEY_W:
|
case GLFW_KEY_W:
|
||||||
{
|
{
|
||||||
if (gamma_value - STEP_SIZE > 0.f)
|
if (gamma_value - STEP_SIZE > 0.f)
|
||||||
set_gamma(gamma_value - STEP_SIZE);
|
set_gamma(window, gamma_value - STEP_SIZE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -105,6 +109,11 @@ int main(int argc, char** argv)
|
|||||||
GLFWmonitor* monitor = NULL;
|
GLFWmonitor* monitor = NULL;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "fh")) != -1)
|
while ((ch = getopt(argc, argv, "fh")) != -1)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@ -123,11 +132,6 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
|
||||||
|
|
||||||
if (!glfwInit())
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
if (monitor)
|
if (monitor)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
||||||
@ -147,7 +151,7 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_gamma(1.f);
|
set_gamma(window, 1.f);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user