diff --git a/.gitattributes b/.gitattributes index cb11129..423886c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -97,6 +97,7 @@ freeglut/freeglut/progs/demos/smooth_opengl3/smooth_opengl3Static.dsp -text freeglut/freeglut/progs/demos/spaceball/Makefile.am -text freeglut/freeglut/progs/demos/spaceball/spaceball.c -text freeglut/freeglut/progs/demos/spaceball/spaceball.dsp -text +freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp -text freeglut/freeglut/progs/demos/spaceball/vmath.c -text freeglut/freeglut/progs/demos/spaceball/vmath.h -text freeglut/freeglut/progs/demos/spaceball/vmath.inl -text diff --git a/freeglut/freeglut/progs/demos/demos.dsw b/freeglut/freeglut/progs/demos/demos.dsw index 7231846..52b9eee 100644 --- a/freeglut/freeglut/progs/demos/demos.dsw +++ b/freeglut/freeglut/progs/demos/demos.dsw @@ -171,6 +171,18 @@ Package=<4> ############################################################################### +Project: "spaceball_static"=.\spaceball\spaceball_static.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Global: Package=<5> diff --git a/freeglut/freeglut/progs/demos/spaceball/spaceball.c b/freeglut/freeglut/progs/demos/spaceball/spaceball.c index 72ad77e..72dddba 100644 --- a/freeglut/freeglut/progs/demos/spaceball/spaceball.c +++ b/freeglut/freeglut/progs/demos/spaceball/spaceball.c @@ -15,6 +15,10 @@ #include #include "vmath.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950 +#endif + void draw_cube(void); /* callbacks */ @@ -58,7 +62,15 @@ void disp(void) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(pos.x, pos.y, pos.z); +#if defined(WIN32) + /* This is STRICTLY a place-holder until we get this working properly for windows. + * I do not pretend that this is equivalent to the non-Windows equivalent. I just + * want the thing to build without errors. + */ + glMultMatrixf((float*)xform); +#else glMultTransposeMatrixf((float*)xform); +#endif draw_cube(); @@ -119,7 +131,7 @@ void draw_cube(void) void reshape(int x, int y) { float aspect = (float)x / (float)y; - float halfy = tan(FOV / 2.0); + float halfy = (float)tan(FOV / 2.0); float halfx = halfy * aspect; glViewport(0, 0, x, y); @@ -150,16 +162,16 @@ void keyb(unsigned char key, int x, int y) void sbmot(int x, int y, int z) { - pos.x += x * 0.001; - pos.y += y * 0.001; - pos.z -= z * 0.001; + pos.x += x * 0.001f; + pos.y += y * 0.001f; + pos.z -= z * 0.001f; glutPostRedisplay(); } void sbrot(int x, int y, int z) { - float axis_len = sqrt(x * x + y * y + z * z); - rot = quat_rotate(rot, axis_len * 0.001, -x / axis_len, -y / axis_len, z / axis_len); + float axis_len = (float)sqrt(x * x + y * y + z * z); + rot = quat_rotate(rot, axis_len * 0.001f, -x / axis_len, -y / axis_len, z / axis_len); glutPostRedisplay(); } diff --git a/freeglut/freeglut/progs/demos/spaceball/spaceball.dsp b/freeglut/freeglut/progs/demos/spaceball/spaceball.dsp index dd99c59..cc47490 100644 --- a/freeglut/freeglut/progs/demos/spaceball/spaceball.dsp +++ b/freeglut/freeglut/progs/demos/spaceball/spaceball.dsp @@ -41,15 +41,15 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../Release" !ELSEIF "$(CFG)" == "spaceball - Win32 Debug" @@ -62,17 +62,18 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../Debug" !ENDIF @@ -83,10 +84,26 @@ LINK32=link.exe # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\spaceball.c +# End Source File +# Begin Source File + +SOURCE=.\vmath.c +# End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\vmath.h +# End Source File +# Begin Source File + +SOURCE=.\vmath.inl +# End Source File # End Group # Begin Group "Resource Files" diff --git a/freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp b/freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp new file mode 100644 index 0000000..5ed0ad5 --- /dev/null +++ b/freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="spaceball_static" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=spaceball_static - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "spaceball_static.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "spaceball_static.mak" CFG="spaceball_static - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "spaceball_static - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "spaceball_static - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "spaceball_static - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "spaceball_static___Win32_Release" +# PROP BASE Intermediate_Dir "spaceball_static___Win32_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseStatic" +# PROP Intermediate_Dir "ReleaseStatic" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../ReleaseStatic" + +!ELSEIF "$(CFG)" == "spaceball_static - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "spaceball_static___Win32_Debug" +# PROP BASE Intermediate_Dir "spaceball_static___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugStatic" +# PROP Intermediate_Dir "DebugStatic" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../DebugStatic" + +!ENDIF + +# Begin Target + +# Name "spaceball_static - Win32 Release" +# Name "spaceball_static - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\spaceball.c +# End Source File +# Begin Source File + +SOURCE=.\vmath.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\vmath.h +# End Source File +# Begin Source File + +SOURCE=.\vmath.inl +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/freeglut/freeglut/progs/demos/spaceball/vmath.c b/freeglut/freeglut/progs/demos/spaceball/vmath.c index 58f2c41..7ef3c25 100644 --- a/freeglut/freeglut/progs/demos/spaceball/vmath.c +++ b/freeglut/freeglut/progs/demos/spaceball/vmath.c @@ -4,10 +4,10 @@ quat_t quat_rotate(quat_t q, float angle, float x, float y, float z) { quat_t rq; - float half_angle = angle * 0.5; - float sin_half = sin(half_angle); + float half_angle = angle * 0.5f; + float sin_half = (float)sin(half_angle); - rq.w = cos(half_angle); + rq.w = (float)cos(half_angle); rq.x = x * sin_half; rq.y = y * sin_half; rq.z = z * sin_half; diff --git a/freeglut/freeglut/progs/demos/spaceball/vmath.h b/freeglut/freeglut/progs/demos/spaceball/vmath.h index 3d8a4ca..249a504 100644 --- a/freeglut/freeglut/progs/demos/spaceball/vmath.h +++ b/freeglut/freeglut/progs/demos/spaceball/vmath.h @@ -1,6 +1,13 @@ #ifndef VMATH_H_ #define VMATH_H_ +#if defined(WIN32) +#define INLINE +#else +#define INLINE inline +#endif + + typedef struct { float x, y, z; } vec3_t; typedef struct { float x, y, z, w; } vec4_t; @@ -9,18 +16,18 @@ typedef vec4_t quat_t; typedef float mat4_t[4][4]; /* vector functions */ -static inline vec3_t v3_cons(float x, float y, float z); -static inline float v3_dot(vec3_t v1, vec3_t v2); +static INLINE vec3_t v3_cons(float x, float y, float z); +static INLINE float v3_dot(vec3_t v1, vec3_t v2); /* quaternion functions */ -static inline quat_t quat_cons(float s, float x, float y, float z); -static inline vec3_t quat_vec(quat_t q); -static inline quat_t quat_mul(quat_t q1, quat_t q2); -static inline void quat_to_mat(mat4_t res, quat_t q); +static INLINE quat_t quat_cons(float s, float x, float y, float z); +static INLINE vec3_t quat_vec(quat_t q); +static INLINE quat_t quat_mul(quat_t q1, quat_t q2); +static INLINE void quat_to_mat(mat4_t res, quat_t q); quat_t quat_rotate(quat_t q, float angle, float x, float y, float z); /* matrix functions */ -static inline void m4_cons(mat4_t m, +static INLINE void m4_cons(mat4_t m, float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, diff --git a/freeglut/freeglut/progs/demos/spaceball/vmath.inl b/freeglut/freeglut/progs/demos/spaceball/vmath.inl index 0284a11..5b1871e 100644 --- a/freeglut/freeglut/progs/demos/spaceball/vmath.inl +++ b/freeglut/freeglut/progs/demos/spaceball/vmath.inl @@ -1,5 +1,5 @@ /* vector functions */ -static inline vec3_t v3_cons(float x, float y, float z) +static INLINE vec3_t v3_cons(float x, float y, float z) { vec3_t res; res.x = x; @@ -8,7 +8,7 @@ static inline vec3_t v3_cons(float x, float y, float z) return res; } -static inline vec3_t quat_vec(quat_t q) +static INLINE vec3_t quat_vec(quat_t q) { vec3_t v; v.x = q.x; @@ -17,13 +17,13 @@ static inline vec3_t quat_vec(quat_t q) return v; } -static inline float v3_dot(vec3_t v1, vec3_t v2) +static INLINE float v3_dot(vec3_t v1, vec3_t v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } /* quaternion functions */ -static inline quat_t quat_cons(float s, float x, float y, float z) +static INLINE quat_t quat_cons(float s, float x, float y, float z) { quat_t q; q.x = x; @@ -33,7 +33,7 @@ static inline quat_t quat_cons(float s, float x, float y, float z) return q; } -static inline quat_t quat_mul(quat_t q1, quat_t q2) +static INLINE quat_t quat_mul(quat_t q1, quat_t q2) { quat_t res; vec3_t v1 = quat_vec(q1); @@ -46,16 +46,16 @@ static inline quat_t quat_mul(quat_t q1, quat_t q2) return res; } -static inline void quat_to_mat(mat4_t res, quat_t q) +static INLINE void quat_to_mat(mat4_t res, quat_t q) { - m4_cons(res, 1.0 - 2.0 * q.y*q.y - 2.0 * q.z*q.z, 2.0 * q.x * q.y + 2.0 * q.w * q.z, 2.0 * q.z * q.x - 2.0 * q.w * q.y, 0, - 2.0 * q.x * q.y - 2.0 * q.w * q.z, 1.0 - 2.0 * q.x*q.x - 2.0 * q.z*q.z, 2.0 * q.y * q.z + 2.0 * q.w * q.x, 0, - 2.0 * q.z * q.x + 2.0 * q.w * q.y, 2.0 * q.y * q.z - 2.0 * q.w * q.x, 1.0 - 2.0 * q.x*q.x - 2.0 * q.y*q.y, 0, + m4_cons(res, 1.0f - 2.0f * q.y*q.y - 2.0f * q.z*q.z, 2.0f * q.x * q.y + 2.0f * q.w * q.z, 2.0f * q.z * q.x - 2.0f * q.w * q.y, 0, + 2.0f * q.x * q.y - 2.0f * q.w * q.z, 1.0f - 2.0f * q.x*q.x - 2.0f * q.z*q.z, 2.0f * q.y * q.z + 2.0f * q.w * q.x, 0, + 2.0f * q.z * q.x + 2.0f * q.w * q.y, 2.0f * q.y * q.z - 2.0f * q.w * q.x, 1.0f - 2.0f * q.x*q.x - 2.0f * q.y*q.y, 0, 0, 0, 0, 1); } /* matrix functions */ -static inline void m4_cons(mat4_t m, +static INLINE void m4_cons(mat4_t m, float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34,