Getting the "spaceball" demo to build properly in Windows
[freeglut] / progs / demos / spaceball / spaceball.c
index 72ad77e..72dddba 100644 (file)
 #include <GL/freeglut.h>\r
 #include "vmath.h"\r
 \r
+#ifndef M_PI\r
+#define M_PI    3.14159265358979323846264338327950\r
+#endif\r
+\r
 void draw_cube(void);\r
 \r
 /* callbacks */\r
@@ -58,7 +62,15 @@ void disp(void)
   glMatrixMode(GL_MODELVIEW);\r
   glLoadIdentity();\r
   glTranslatef(pos.x, pos.y, pos.z);\r
+#if defined(WIN32)\r
+  /* This is STRICTLY a place-holder until we get this working properly for windows.\r
+   * I do not pretend that this is equivalent to the non-Windows equivalent.  I just\r
+   * want the thing to build without errors.\r
+   */\r
+  glMultMatrixf((float*)xform);\r
+#else\r
   glMultTransposeMatrixf((float*)xform);\r
+#endif\r
 \r
   draw_cube();\r
 \r
@@ -119,7 +131,7 @@ void draw_cube(void)
 void reshape(int x, int y)\r
 {\r
   float aspect = (float)x / (float)y;\r
-  float halfy = tan(FOV / 2.0);\r
+  float halfy = (float)tan(FOV / 2.0);\r
   float halfx = halfy * aspect;\r
 \r
   glViewport(0, 0, x, y);\r
@@ -150,16 +162,16 @@ void keyb(unsigned char key, int x, int y)
 \r
 void sbmot(int x, int y, int z)\r
 {\r
-  pos.x += x * 0.001;\r
-  pos.y += y * 0.001;\r
-  pos.z -= z * 0.001;\r
+  pos.x += x * 0.001f;\r
+  pos.y += y * 0.001f;\r
+  pos.z -= z * 0.001f;\r
   glutPostRedisplay();\r
 }\r
 \r
 void sbrot(int x, int y, int z)\r
 {\r
-  float axis_len = sqrt(x * x + y * y + z * z);\r
-  rot = quat_rotate(rot, axis_len * 0.001, -x / axis_len, -y / axis_len, z / axis_len);\r
+  float axis_len = (float)sqrt(x * x + y * y + z * z);\r
+  rot = quat_rotate(rot, axis_len * 0.001f, -x / axis_len, -y / axis_len, z / axis_len);\r
   glutPostRedisplay();\r
 }\r
 \r