Merge remote-tracking branch 'svn/trunk' into git_master

This commit is contained in:
Diederick Niehorster 2014-10-12 12:49:03 +08:00
commit 04390fdd5c
6 changed files with 32 additions and 25 deletions

View 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)

View File

@ -3,6 +3,10 @@
#include <math.h>
#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 */

View File

@ -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);

View File

@ -44,6 +44,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "glmatrix.h"

View 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 );

View File

@ -352,17 +352,16 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
XSetWMProtocols( fgDisplay.pDisplay.Display, window->Window.Handle,
&fgDisplay.pDisplay.DeleteWindow, 1 );
if (!isSubWindow && !window->IsMenu &&
((fgState.DisplayMode & GLUT_BORDERLESS) || (fgState.DisplayMode & GLUT_CAPTIONLESS)))
{
/* _MOTIF_WM_HINTS is replaced by _NET_WM_WINDOW_TYPE, but that property does not allow precise
/* _MOTIF_WM_HINTS is replaced by _NET_WM_WINDOW_TYPE, but that property does not allow precise
* control over the visual style of the window, which is what we are trying to achieve here.
* Stick with Motif and hope for the best... */
MotifWmHints hints = {0};
hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = (fgState.DisplayMode & GLUT_CAPTIONLESS) ? MWM_DECOR_BORDER:0;
printf("%i\n",hints.decorations);
XChangeProperty(fgDisplay.pDisplay.Display, window->Window.Handle,
XInternAtom( fgDisplay.pDisplay.Display, "_MOTIF_WM_HINTS", False ),
@ -370,7 +369,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
PropModeReplace,
(unsigned char*) &hints,
sizeof(MotifWmHints) / sizeof(long));
}
}
if (fgDisplay.pDisplay.NetWMSupported