From 4afc67c1df77161825a4a050bcec787b057fd9c6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 27 Jul 2011 17:09:17 +0200 Subject: [PATCH] Various Windows and VC++ 2010 fixes. --- examples/getopt.c | 6 ++++++ examples/heightmap.c | 4 +++- include/GL/glfw3.h | 30 +++++++++++++++++++++++++++--- src/gamma.c | 2 +- src/win32_platform.h | 7 +++++-- src/win32_window.c | 5 +++-- tests/events.c | 2 ++ tests/getopt.c | 7 ++++++- tests/windows.c | 2 +- 9 files changed, 54 insertions(+), 11 deletions(-) mode change 100644 => 100755 include/GL/glfw3.h diff --git a/examples/getopt.c b/examples/getopt.c index b891b0a5..9d79b9a7 100644 --- a/examples/getopt.c +++ b/examples/getopt.c @@ -34,12 +34,18 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ +#define _CRT_SECURE_NO_WARNINGS + #include #include #include #include "getopt.h" +/* 2011-07-27 Camilla Berglund + * + * Added _CRT_SECURE_NO_WARNINGS macro. + */ /* 2009-10-12 Camilla Berglund * * Removed unused global static variable 'ID'. diff --git a/examples/heightmap.c b/examples/heightmap.c index f37c732f..1d3dd72e 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -23,6 +23,8 @@ // //======================================================================== +#define _CRT_SECURE_NO_WARNINGS + #include #include #include @@ -422,7 +424,7 @@ static void update_map(int num_iter) if (fabs(pd) <= 1.0f) { /* tx,tz is within the circle */ - GLfloat new_height = disp + (cos(pd*3.14f)*disp); + GLfloat new_height = disp + (float) (cos(pd*3.14f)*disp); map_vertices[1][ii] += new_height; } } diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h old mode 100644 new mode 100755 index 1836d134..ab9629f1 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -75,7 +75,7 @@ extern "C" { #else #define APIENTRY #endif - #define GL_APIENTRY_DEFINED + #define GLFW_APIENTRY_DEFINED #endif /* APIENTRY */ @@ -96,7 +96,7 @@ extern "C" { /* Others (e.g. MinGW, Cygwin) */ #define WINGDIAPI extern #endif - #define GL_WINGDIAPI_DEFINED + #define GLFW_WINGDIAPI_DEFINED #endif /* WINGDIAPI */ /* Some files also need CALLBACK defined */ @@ -112,7 +112,7 @@ extern "C" { /* Other Windows compilers */ #define CALLBACK __stdcall #endif - #define GLU_CALLBACK_DEFINED + #define GLFW_CALLBACK_DEFINED #endif /* CALLBACK */ /* Microsoft Visual C++, Borland C++ and Pelles C needs wchar_t */ @@ -594,6 +594,30 @@ GLFWAPI void glfwEnable(GLFWwindow window, int token); GLFWAPI void glfwDisable(GLFWwindow window, int token); +/************************************************************************* + * Global definition cleanup + *************************************************************************/ + +/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */ + +#ifdef GLFW_APIENTRY_DEFINED + #undef APIENTRY + #undef GLFW_APIENTRY_DEFINED +#endif + +#ifdef GLFW_WINGDIAPI_DEFINED + #undef WINGDIAPI + #undef GLFW_WINGDIAPI_DEFINED +#endif + +#ifdef GLFW_CALLBACK_DEFINED + #undef CALLBACK + #undef GLFW_CALLBACK_DEFINED +#endif + +/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ + + #ifdef __cplusplus } #endif diff --git a/src/gamma.c b/src/gamma.c index 83847e10..d0c45d01 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -57,7 +57,7 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain) float value = (float) i / ((float) (size - 1)); // Apply gamma - value = pow(value, 1.f / gamma) * 65535.f + 0.5f; + value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f; // Apply gain value = gain * (value - 32767.5f) + 32767.5f; diff --git a/src/win32_platform.h b/src/win32_platform.h index d6a5787d..2ff73116 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -34,13 +34,16 @@ // We don't need all the fancy stuff #define NOMINMAX -#define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN +#ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN +#endif + #include #include -#include "../../include/GL/wglext.h" +#include "../include/GL/wglext.h" //======================================================================== diff --git a/src/win32_window.c b/src/win32_window.c index 56b5908e..8e72c417 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1556,7 +1556,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) { - int bpp, newMode = 0, refresh; + //int bpp, refresh; + int newMode = 0; GLboolean sizeChanged = GL_FALSE; if (window->mode == GLFW_FULLSCREEN) @@ -1647,7 +1648,7 @@ void _glfwPlatformRefreshWindowParams(void) { PIXELFORMATDESCRIPTOR pfd; DEVMODE dm; - int pixelFormat, mode; + int pixelFormat; _GLFWwindow* window = _glfwLibrary.currentWindow; diff --git a/tests/events.c b/tests/events.c index ca114e33..6ae6718a 100644 --- a/tests/events.c +++ b/tests/events.c @@ -31,6 +31,8 @@ // //======================================================================== +#define _CRT_SECURE_NO_WARNINGS + #include #include diff --git a/tests/getopt.c b/tests/getopt.c index b891b0a5..712cf28a 100644 --- a/tests/getopt.c +++ b/tests/getopt.c @@ -34,18 +34,23 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ +#define _CRT_SECURE_NO_WARNINGS + #include #include #include #include "getopt.h" +/* 2011-07-27 Camilla Berglund + * + * Added _CRT_SECURE_NO_WARNINGS macro. + */ /* 2009-10-12 Camilla Berglund * * Removed unused global static variable 'ID'. */ - char* optarg = NULL; int optind = 0; int opterr = 1; diff --git a/tests/windows.c b/tests/windows.c index b84c9262..ddb8a224 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -66,7 +66,7 @@ int main(void) glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); - glClearColor(i & 1, i >> 1, 0.0, 0.0); + glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), 0.0, 0.0); } while (running)