fixed build on MSVC6
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 11 Oct 2014 17:15:33 +0000 (17:15 +0000)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 11 Oct 2014 17:15:33 +0000 (17:15 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1707 7f0cb862-5218-0410-a997-914c9d46530a

CMakeLists.txt
progs/demos/shapes/glmatrix.c
progs/demos/shapes/glmatrix.h
progs/demos/shapes/shapes.c
src/mswin/fg_main_mswin.c

index 7cd2afc..0227a95 100644 (file)
@@ -228,6 +228,9 @@ IF(WIN32)
         SET( CMAKE_DEBUG_POSTFIX "d" )
     ENDIF(MSVC)
     
+    # enable the use of Win2000 APIs (needed for really old compilers like MSVC6)
+    ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500)
+    ADD_DEFINITIONS(-DWINVER=0x0500)
 ENDIF()
 
 IF(CMAKE_COMPILER_IS_GNUCC)
index 5128da8..485e324 100644 (file)
@@ -3,6 +3,10 @@
 #include <math.h>\r
 #include "glmatrix.h"\r
 \r
+#ifndef M_PI\r
+#define M_PI   3.141592653589793\r
+#endif\r
+\r
 #define MMODE_IDX(x)   ((x) - GL_MODELVIEW)\r
 #define MAT_STACK_SIZE 32\r
 #define MAT_IDENT      {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}\r
@@ -114,17 +118,17 @@ void gl_scalef(float x, float y, float z)
     gl_mult_matrixf(mat);\r
 }\r
 \r
-void gl_ortho(float left, float right, float bottom, float top, float near, float far)\r
+void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar)\r
 {\r
     float mat[] = MAT_IDENT;\r
 \r
     float dx = right - left;\r
     float dy = top - bottom;\r
-    float dz = far - near;\r
+    float dz = zfar - znear;\r
 \r
     float tx = -(right + left) / dx;\r
     float ty = -(top + bottom) / dy;\r
-    float tz = -(far + near) / dz;\r
+    float tz = -(zfar + znear) / dz;\r
 \r
     float sx = 2.f / dx;\r
     float sy = 2.f / dy;\r
@@ -140,21 +144,21 @@ void gl_ortho(float left, float right, float bottom, float top, float near, floa
     gl_mult_matrixf(mat);\r
 }\r
 \r
-void gl_frustum(float left, float right, float bottom, float top, float near, float far)\r
+void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar)\r
 {\r
     float mat[] = MAT_IDENT;\r
 \r
     float dx = right - left;\r
     float dy = top - bottom;\r
-    float dz = far - near;\r
+    float dz = zfar - znear;\r
 \r
     float a = (right + left) / dx;\r
     float b = (top + bottom) / dy;\r
-    float c = -(far + near) / dz;\r
-    float d = -2.f * far * near / dz;\r
+    float c = -(zfar + znear) / dz;\r
+    float d = -2.f * zfar * znear / dz;\r
 \r
-    mat[0] = 2.f * near / dx;\r
-    mat[5] = 2.f * near / dy;\r
+    mat[0] = 2.f * znear / dx;\r
+    mat[5] = 2.f * znear / dy;\r
     mat[8] = a;\r
     mat[9] = b;\r
     mat[10] = c;\r
@@ -165,11 +169,11 @@ void gl_frustum(float left, float right, float bottom, float top, float near, fl
     gl_mult_matrixf(mat);\r
 }\r
 \r
-void glu_perspective(float vfov, float aspect, float near, float far)\r
+void glu_perspective(float vfov, float aspect, float znear, float zfar)\r
 {\r
     float vfov_rad = (float)M_PI * vfov / 180.f;\r
-    float x = near * (float)tan(vfov_rad / 2.f);\r
-    gl_frustum(-aspect * x, aspect * x, -x, x, near, far);\r
+    float x = znear * (float)tan(vfov_rad / 2.f);\r
+    gl_frustum(-aspect * x, aspect * x, -x, x, znear, zfar);\r
 }\r
 \r
 /* return the matrix (16 elements, 4x4 matrix, row-major order */\r
index ab1c096..997a70d 100644 (file)
@@ -20,9 +20,9 @@ void gl_mult_matrixf(const float *mat);
 void gl_translatef(float x, float y, float z);\r
 void gl_rotatef(float angle, float x, float y, float z);\r
 void gl_scalef(float x, float y, float z);\r
-void gl_ortho(float left, float right, float bottom, float top, float near, float far);\r
-void gl_frustum(float left, float right, float bottom, float top, float near, float far);\r
-void glu_perspective(float vfov, float aspect, float near, float far);\r
+void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar);\r
+void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar);\r
+void glu_perspective(float vfov, float aspect, float znear, float zfar);\r
 \r
 /* getters */\r
 float* get_matrix(int mm);\r
index ebac795..d132777 100644 (file)
@@ -44,6 +44,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 
 #include "glmatrix.h"
 
index fd7acbc..61caf55 100644 (file)
@@ -184,7 +184,7 @@ static struct WM_MESSAGE_MAP allMessages[] =
 
 
 
-#   if(_WIN32_WINNT >= 0x0500)
+#   if(_WIN32_WINNT >= 0x0500) && defined(WM_NCXBUTTONDOWN)
         DEFINE_MESSAGE(WM_NCXBUTTONDOWN),
         DEFINE_MESSAGE(WM_NCXBUTTONUP),
         DEFINE_MESSAGE(WM_NCXBUTTONDBLCLK),
@@ -241,7 +241,7 @@ static struct WM_MESSAGE_MAP allMessages[] =
             DEFINE_MESSAGE(WM_UNINITMENUPOPUP),
             DEFINE_MESSAGE(WM_MENUCOMMAND),
 
-#           if(_WIN32_WINNT >= 0x0500)
+#           if(_WIN32_WINNT >= 0x0500) && defined(WM_CHANGEUISTATE)
                 DEFINE_MESSAGE(WM_CHANGEUISTATE),
                 DEFINE_MESSAGE(WM_UPDATEUISTATE),
                 DEFINE_MESSAGE(WM_QUERYUISTATE),
@@ -272,7 +272,7 @@ static struct WM_MESSAGE_MAP allMessages[] =
 #   if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
         DEFINE_MESSAGE(WM_MOUSEWHEEL),
 #   endif
-#   if (_WIN32_WINNT >= 0x0500)
+#   if (_WIN32_WINNT >= 0x0500) && defined(WM_XBUTTONDOWN)
         DEFINE_MESSAGE(WM_XBUTTONDOWN),
         DEFINE_MESSAGE(WM_XBUTTONUP),
         DEFINE_MESSAGE(WM_XBUTTONDBLCLK),
@@ -364,7 +364,7 @@ static struct WM_MESSAGE_MAP allMessages[] =
         DEFINE_MESSAGE(WM_MOUSEHOVER),
         DEFINE_MESSAGE(WM_MOUSELEAVE),
 #   endif
-#   if(WINVER >= 0x0500)
+#   if(WINVER >= 0x0500) && defined(WM_NCMOUSEHOVER)
         DEFINE_MESSAGE(WM_NCMOUSEHOVER),
         DEFINE_MESSAGE(WM_NCMOUSELEAVE),
 #   endif /* WINVER >= 0x0500 */
@@ -398,7 +398,7 @@ static struct WM_MESSAGE_MAP allMessages[] =
         DEFINE_MESSAGE(WM_PRINTCLIENT),
 #   endif /* WINVER >= 0x0400 */
 
-#   if(_WIN32_WINNT >= 0x0500)
+#   if(_WIN32_WINNT >= 0x0500) && defined(WM_APPCOMMAND)
         DEFINE_MESSAGE(WM_APPCOMMAND),
 #   endif /* _WIN32_WINNT >= 0x0500 */
 
@@ -1283,7 +1283,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
         */
 #else
         /* int modkeys = GET_KEYSTATE_WPARAM( wParam ); */
-        short ticks = GET_WHEEL_DELTA_WPARAM( wParam );
+        short ticks = HIWORD( wParam );
         /* commented out as should not be needed here, mouse motion is processed in WM_MOUSEMOVE first:
         window->State.MouseX = GET_X_LPARAM( lParam );
         window->State.MouseY = GET_Y_LPARAM( lParam );