Browse Source

Remove ad-hoc M_PIs and enable VC++ macro

Fixes #564.
Camilla Berglund 10 years ago
parent
commit
d2113dc9f5
6 changed files with 29 additions and 22 deletions
  1. 5 5
      examples/boing.c
  2. 4 4
      examples/gears.c
  3. 5 5
      examples/particles.c
  4. 5 4
      examples/splitview.c
  5. 5 4
      examples/wave.c
  6. 5 0
      tests/cursor.c

+ 5 - 5
examples/boing.c

@@ -27,6 +27,11 @@
  * a hidden computer or VCR.
  *****************************************************************************/
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -102,11 +107,6 @@ double  dt;
  #define RAND_MAX 4095
 #endif
 
-/* PI */
-#ifndef M_PI
- #define M_PI 3.1415926535897932384626433832795
-#endif
-
 
 /*****************************************************************************
  * Truncate a degree.

+ 4 - 4
examples/gears.c

@@ -21,6 +21,10 @@
  *   - Enabled vsync
  */
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
 
 #include <math.h>
 #include <stdlib.h>
@@ -28,10 +32,6 @@
 #include <string.h>
 #include <GLFW/glfw3.h>
 
-#ifndef M_PI
-#define M_PI 3.141592654
-#endif
-
 /* If non-zero, the program exits after that many seconds
  */
 static int autoexit = 0;

+ 5 - 5
examples/particles.c

@@ -24,6 +24,11 @@
 //
 //========================================================================
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -43,11 +48,6 @@
 #define GL_SEPARATE_SPECULAR_COLOR_EXT    0x81FA
 #endif // GL_EXT_separate_specular_color
 
-// Some <math.h>'s do not define M_PI
-#ifndef M_PI
-#define M_PI 3.141592654
-#endif
-
 
 //========================================================================
 // Type definitions

+ 5 - 4
examples/splitview.c

@@ -14,14 +14,15 @@
 #define GLFW_INCLUDE_GLEXT
 #include <GLFW/glfw3.h>
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
+
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 
 //========================================================================
 // Global variables

+ 5 - 4
examples/wave.c

@@ -8,6 +8,11 @@
  * 2010-10-24: Formatting and cleanup - Camilla Berglund
  *****************************************************************************/
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -15,10 +20,6 @@
 #define GLFW_INCLUDE_GLU
 #include <GLFW/glfw3.h>
 
-#ifndef M_PI
- #define M_PI 3.1415926535897932384626433832795
-#endif
-
 // Maximum delta T to allow for differential calculations
 #define MAX_DELTA_T 0.01
 

+ 5 - 0
tests/cursor.c

@@ -32,6 +32,11 @@
 
 #include <GLFW/glfw3.h>
 
+#if defined(_MSC_VER)
+ // Make MS math.h define M_PI
+ #define _USE_MATH_DEFINES
+#endif
+
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>