From 5bbc2b4949857e4df3ab39f40bc149481af02881 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 15 Mar 2015 15:40:43 +0100 Subject: [PATCH] Added and documented glfwSetGamma value checks. --- include/GLFW/glfw3.h | 3 ++- src/monitor.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 13f1e828..f6cdd978 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1424,7 +1424,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); /*! @brief Generates a gamma ramp and sets it for the specified monitor. * * This function generates a 256-element gamma ramp from the specified exponent - * and then calls @ref glfwSetGammaRamp with it. + * and then calls @ref glfwSetGammaRamp with it. The value must be a finite + * number greater than zero. * * @param[in] monitor The monitor whose gamma ramp to set. * @param[in] gamma The desired exponent. diff --git a/src/monitor.c b/src/monitor.c index 1ab57489..71fa8ed2 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -28,6 +28,7 @@ #include "internal.h" #include +#include #include #include #include @@ -385,10 +386,9 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) _GLFW_REQUIRE_INIT(); - if (gamma <= 0.f) + if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX) { - _glfwInputError(GLFW_INVALID_VALUE, - "Gamma value must be greater than zero"); + _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value"); return; }