From a91c4e11d70265093dc3a7c15ed3f1b07883e9df Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 11 Oct 2014 17:15:33 +0000 Subject: [PATCH] fixed build on MSVC6 git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1707 7f0cb862-5218-0410-a997-914c9d46530a --- CMakeLists.txt | 3 +++ progs/demos/shapes/glmatrix.c | 28 ++++++++++++++++------------ progs/demos/shapes/glmatrix.h | 6 +++--- progs/demos/shapes/shapes.c | 1 + src/mswin/fg_main_mswin.c | 12 ++++++------ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd2afc..0227a95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/progs/demos/shapes/glmatrix.c b/progs/demos/shapes/glmatrix.c index 5128da8..485e324 100644 --- a/progs/demos/shapes/glmatrix.c +++ b/progs/demos/shapes/glmatrix.c @@ -3,6 +3,10 @@ #include #include "glmatrix.h" +#ifndef M_PI +#define M_PI 3.141592653589793 +#endif + #define MMODE_IDX(x) ((x) - GL_MODELVIEW) #define MAT_STACK_SIZE 32 #define MAT_IDENT {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} @@ -114,17 +118,17 @@ void gl_scalef(float x, float y, float z) gl_mult_matrixf(mat); } -void gl_ortho(float left, float right, float bottom, float top, float near, float far) +void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar) { float mat[] = MAT_IDENT; float dx = right - left; float dy = top - bottom; - float dz = far - near; + float dz = zfar - znear; float tx = -(right + left) / dx; float ty = -(top + bottom) / dy; - float tz = -(far + near) / dz; + float tz = -(zfar + znear) / dz; float sx = 2.f / dx; float sy = 2.f / dy; @@ -140,21 +144,21 @@ void gl_ortho(float left, float right, float bottom, float top, float near, floa gl_mult_matrixf(mat); } -void gl_frustum(float left, float right, float bottom, float top, float near, float far) +void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar) { float mat[] = MAT_IDENT; float dx = right - left; float dy = top - bottom; - float dz = far - near; + float dz = zfar - znear; float a = (right + left) / dx; float b = (top + bottom) / dy; - float c = -(far + near) / dz; - float d = -2.f * far * near / dz; + float c = -(zfar + znear) / dz; + float d = -2.f * zfar * znear / dz; - mat[0] = 2.f * near / dx; - mat[5] = 2.f * near / dy; + mat[0] = 2.f * znear / dx; + mat[5] = 2.f * znear / dy; mat[8] = a; mat[9] = b; mat[10] = c; @@ -165,11 +169,11 @@ void gl_frustum(float left, float right, float bottom, float top, float near, fl gl_mult_matrixf(mat); } -void glu_perspective(float vfov, float aspect, float near, float far) +void glu_perspective(float vfov, float aspect, float znear, float zfar) { float vfov_rad = (float)M_PI * vfov / 180.f; - float x = near * (float)tan(vfov_rad / 2.f); - gl_frustum(-aspect * x, aspect * x, -x, x, near, far); + float x = znear * (float)tan(vfov_rad / 2.f); + gl_frustum(-aspect * x, aspect * x, -x, x, znear, zfar); } /* return the matrix (16 elements, 4x4 matrix, row-major order */ diff --git a/progs/demos/shapes/glmatrix.h b/progs/demos/shapes/glmatrix.h index ab1c096..997a70d 100644 --- a/progs/demos/shapes/glmatrix.h +++ b/progs/demos/shapes/glmatrix.h @@ -20,9 +20,9 @@ void gl_mult_matrixf(const float *mat); void gl_translatef(float x, float y, float z); void gl_rotatef(float angle, float x, float y, float z); void gl_scalef(float x, float y, float z); -void gl_ortho(float left, float right, float bottom, float top, float near, float far); -void gl_frustum(float left, float right, float bottom, float top, float near, float far); -void glu_perspective(float vfov, float aspect, float near, float far); +void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar); +void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar); +void glu_perspective(float vfov, float aspect, float znear, float zfar); /* getters */ float* get_matrix(int mm); diff --git a/progs/demos/shapes/shapes.c b/progs/demos/shapes/shapes.c index ebac795..d132777 100644 --- a/progs/demos/shapes/shapes.c +++ b/progs/demos/shapes/shapes.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "glmatrix.h" diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index fd7acbc..61caf55 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -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 ); -- 1.7.10.4