Getting the "spaceball" demo to build properly in Windows
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@844 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
11adf5e005
commit
0be6f5a309
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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/Makefile.am -text
|
||||||
freeglut/freeglut/progs/demos/spaceball/spaceball.c -text
|
freeglut/freeglut/progs/demos/spaceball/spaceball.c -text
|
||||||
freeglut/freeglut/progs/demos/spaceball/spaceball.dsp -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.c -text
|
||||||
freeglut/freeglut/progs/demos/spaceball/vmath.h -text
|
freeglut/freeglut/progs/demos/spaceball/vmath.h -text
|
||||||
freeglut/freeglut/progs/demos/spaceball/vmath.inl -text
|
freeglut/freeglut/progs/demos/spaceball/vmath.inl -text
|
||||||
|
@ -171,6 +171,18 @@ Package=<4>
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "spaceball_static"=.\spaceball\spaceball_static.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
Global:
|
Global:
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846264338327950
|
||||||
|
#endif
|
||||||
|
|
||||||
void draw_cube(void);
|
void draw_cube(void);
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
@ -58,7 +62,15 @@ void disp(void)
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(pos.x, pos.y, pos.z);
|
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);
|
glMultTransposeMatrixf((float*)xform);
|
||||||
|
#endif
|
||||||
|
|
||||||
draw_cube();
|
draw_cube();
|
||||||
|
|
||||||
@ -119,7 +131,7 @@ void draw_cube(void)
|
|||||||
void reshape(int x, int y)
|
void reshape(int x, int y)
|
||||||
{
|
{
|
||||||
float aspect = (float)x / (float)y;
|
float aspect = (float)x / (float)y;
|
||||||
float halfy = tan(FOV / 2.0);
|
float halfy = (float)tan(FOV / 2.0);
|
||||||
float halfx = halfy * aspect;
|
float halfx = halfy * aspect;
|
||||||
|
|
||||||
glViewport(0, 0, x, y);
|
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)
|
void sbmot(int x, int y, int z)
|
||||||
{
|
{
|
||||||
pos.x += x * 0.001;
|
pos.x += x * 0.001f;
|
||||||
pos.y += y * 0.001;
|
pos.y += y * 0.001f;
|
||||||
pos.z -= z * 0.001;
|
pos.z -= z * 0.001f;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sbrot(int x, int y, int z)
|
void sbrot(int x, int y, int z)
|
||||||
{
|
{
|
||||||
float axis_len = sqrt(x * x + y * y + z * z);
|
float axis_len = (float)sqrt(x * x + y * y + z * z);
|
||||||
rot = quat_rotate(rot, axis_len * 0.001, -x / axis_len, -y / axis_len, z / axis_len);
|
rot = quat_rotate(rot, axis_len * 0.001f, -x / axis_len, -y / axis_len, z / axis_len);
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ RSC=rc.exe
|
|||||||
# PROP Intermediate_Dir "Release"
|
# PROP Intermediate_Dir "Release"
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# 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 BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
@ -49,7 +49,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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 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"
|
!ELSEIF "$(CFG)" == "spaceball - Win32 Debug"
|
||||||
|
|
||||||
@ -62,9 +62,10 @@ LINK32=link.exe
|
|||||||
# PROP Use_Debug_Libraries 1
|
# PROP Use_Debug_Libraries 1
|
||||||
# PROP Output_Dir "Debug"
|
# PROP Output_Dir "Debug"
|
||||||
# PROP Intermediate_Dir "Debug"
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# 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 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 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 BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
@ -72,7 +73,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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 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
|
!ENDIF
|
||||||
|
|
||||||
@ -83,10 +84,26 @@ LINK32=link.exe
|
|||||||
# Begin Group "Source Files"
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
# 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
|
# End Group
|
||||||
# Begin Group "Header Files"
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
# 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
|
# End Group
|
||||||
# Begin Group "Resource Files"
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
112
freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp
Normal file
112
freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp
Normal file
@ -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
|
@ -4,10 +4,10 @@
|
|||||||
quat_t quat_rotate(quat_t q, float angle, float x, float y, float z)
|
quat_t quat_rotate(quat_t q, float angle, float x, float y, float z)
|
||||||
{
|
{
|
||||||
quat_t rq;
|
quat_t rq;
|
||||||
float half_angle = angle * 0.5;
|
float half_angle = angle * 0.5f;
|
||||||
float sin_half = sin(half_angle);
|
float sin_half = (float)sin(half_angle);
|
||||||
|
|
||||||
rq.w = cos(half_angle);
|
rq.w = (float)cos(half_angle);
|
||||||
rq.x = x * sin_half;
|
rq.x = x * sin_half;
|
||||||
rq.y = y * sin_half;
|
rq.y = y * sin_half;
|
||||||
rq.z = z * sin_half;
|
rq.z = z * sin_half;
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#ifndef VMATH_H_
|
#ifndef VMATH_H_
|
||||||
#define 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; } vec3_t;
|
||||||
typedef struct { float x, y, z, w; } vec4_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];
|
typedef float mat4_t[4][4];
|
||||||
|
|
||||||
/* vector functions */
|
/* 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);
|
||||||
static inline float v3_dot(vec3_t v1, vec3_t v2);
|
static INLINE float v3_dot(vec3_t v1, vec3_t v2);
|
||||||
|
|
||||||
/* quaternion functions */
|
/* 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);
|
||||||
static inline vec3_t quat_vec(quat_t q);
|
static INLINE vec3_t quat_vec(quat_t 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);
|
||||||
static inline void quat_to_mat(mat4_t res, quat_t q);
|
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);
|
quat_t quat_rotate(quat_t q, float angle, float x, float y, float z);
|
||||||
|
|
||||||
/* matrix functions */
|
/* 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 m11, float m12, float m13, float m14,
|
||||||
float m21, float m22, float m23, float m24,
|
float m21, float m22, float m23, float m24,
|
||||||
float m31, float m32, float m33, float m34,
|
float m31, float m32, float m33, float m34,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* vector functions */
|
/* 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;
|
vec3_t res;
|
||||||
res.x = x;
|
res.x = x;
|
||||||
@ -8,7 +8,7 @@ static inline vec3_t v3_cons(float x, float y, float z)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline vec3_t quat_vec(quat_t q)
|
static INLINE vec3_t quat_vec(quat_t q)
|
||||||
{
|
{
|
||||||
vec3_t v;
|
vec3_t v;
|
||||||
v.x = q.x;
|
v.x = q.x;
|
||||||
@ -17,13 +17,13 @@ static inline vec3_t quat_vec(quat_t q)
|
|||||||
return v;
|
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;
|
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* quaternion functions */
|
/* 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;
|
quat_t q;
|
||||||
q.x = x;
|
q.x = x;
|
||||||
@ -33,7 +33,7 @@ static inline quat_t quat_cons(float s, float x, float y, float z)
|
|||||||
return q;
|
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;
|
quat_t res;
|
||||||
vec3_t v1 = quat_vec(q1);
|
vec3_t v1 = quat_vec(q1);
|
||||||
@ -46,16 +46,16 @@ static inline quat_t quat_mul(quat_t q1, quat_t q2)
|
|||||||
return res;
|
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,
|
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.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.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.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,
|
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);
|
0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* matrix functions */
|
/* 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 m11, float m12, float m13, float m14,
|
||||||
float m21, float m22, float m23, float m24,
|
float m21, float m22, float m23, float m24,
|
||||||
float m31, float m32, float m33, float m34,
|
float m31, float m32, float m33, float m34,
|
||||||
|
Reference in New Issue
Block a user