From b2fa10ae5be608722bc86972453354d0391a023d Mon Sep 17 00:00:00 2001 From: siavash Date: Thu, 4 Jul 2013 23:42:18 +0430 Subject: [PATCH 1/6] Small tweaks. --- src/gamma.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gamma.c b/src/gamma.c index c538b590..1ec3b0e5 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -81,18 +81,18 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) for (i = 0; i < 256; i++) { - float value; + float inv255, value; // Calculate intensity - value = i / 255.f; + inv255 = 1.f / 255.f; + value = i * inv255; // Apply gamma curve - value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f; + value = powf(value, 1.f / gamma) * 65535.f + 0.5f; // Clamp to value range - if (value < 0.f) - value = 0.f; - else if (value > 65535.f) - value = 65535.f; + // There isn't any need to check for values smaller than zero. + // It is always positive and bigger than 0.5f. + value = value < 65535.f ? value : 65535.f; values[i] = (unsigned short) value; } From 92adb6d266924868842773a47afc8d655a02b8ec Mon Sep 17 00:00:00 2001 From: siavash Date: Thu, 4 Jul 2013 23:46:16 +0430 Subject: [PATCH 2/6] Get rid of unnecessary else statement. --- src/glx_context.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/glx_context.c b/src/glx_context.c index d8989dff..724037f4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -191,14 +191,12 @@ static GLXContext createLegacyContext(_GLFWwindow* window, share, True); } - else - { - return glXCreateNewContext(_glfw.x11.display, - fbconfig, - GLX_RGBA_TYPE, - share, - True); - } + + return glXCreateNewContext(_glfw.x11.display, + fbconfig, + GLX_RGBA_TYPE, + share, + True); } From 16f036bb53aa986de35570da71f94d525a85b16b Mon Sep 17 00:00:00 2001 From: siavash Date: Fri, 5 Jul 2013 00:06:04 +0430 Subject: [PATCH 3/6] Very small change. --- src/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index c415462e..f63d71e1 100644 --- a/src/input.c +++ b/src/input.c @@ -64,7 +64,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode) _glfw.cursorPosY = window->cursorPosY; _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); + _glfwPlatformSetCursorPos(window, width * 0.5, height * 0.5); } _glfwPlatformSetCursorMode(window, newMode); From 321b90e2d3992f25d3848bfca82a967e288d271e Mon Sep 17 00:00:00 2001 From: siavash Date: Fri, 5 Jul 2013 00:14:00 +0430 Subject: [PATCH 4/6] Fixed indention. --- src/gamma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gamma.c b/src/gamma.c index 1ec3b0e5..0bf24e4e 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -84,15 +84,15 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) float inv255, value; // Calculate intensity - inv255 = 1.f / 255.f; + inv255 = 1.f / 255.f; value = i * inv255; // Apply gamma curve value = powf(value, 1.f / gamma) * 65535.f + 0.5f; // Clamp to value range - // There isn't any need to check for values smaller than zero. - // It is always positive and bigger than 0.5f. - value = value < 65535.f ? value : 65535.f; + // There isn't any need to check for values smaller than zero. + // It is always positive and bigger than 0.5f. + value = value < 65535.f ? value : 65535.f; values[i] = (unsigned short) value; } From e49b5ffa26b55d259fe2a5a259e446b53462c922 Mon Sep 17 00:00:00 2001 From: siavash Date: Fri, 5 Jul 2013 04:12:22 +0430 Subject: [PATCH 5/6] Fixed coding style and removed C99 function. --- src/gamma.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gamma.c b/src/gamma.c index 0bf24e4e..d09d25e7 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -87,12 +87,13 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) inv255 = 1.f / 255.f; value = i * inv255; // Apply gamma curve - value = powf(value, 1.f / gamma) * 65535.f + 0.5f; + value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f; - // Clamp to value range + // Clamp to value range [0.f, 65535.f] // There isn't any need to check for values smaller than zero. // It is always positive and bigger than 0.5f. - value = value < 65535.f ? value : 65535.f; + if (value > 65535.f) + value = 65535.f; values[i] = (unsigned short) value; } From c0e8caebe6ad6a9602558aba0b3437b7e614ef5b Mon Sep 17 00:00:00 2001 From: siavash Date: Fri, 5 Jul 2013 04:34:19 +0430 Subject: [PATCH 6/6] Rolled back a few changes. --- src/gamma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gamma.c b/src/gamma.c index d09d25e7..21e13a70 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -81,11 +81,10 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) for (i = 0; i < 256; i++) { - float inv255, value; + float value; // Calculate intensity - inv255 = 1.f / 255.f; - value = i * inv255; + value = i / 255.f; // Apply gamma curve value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f;