summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2023-09-05 10:18:24 +0200
committerErik Faye-Lund <erik.faye-lund@collabora.com>2023-09-08 11:06:27 +0200
commite3746fc48206d8f1c10926d18bde744db143ccd6 (patch)
treebd19dc6cc4d58dde68b2c90a466eab63977fb9c6
parent2cb31b80f1965449a63f3aca920e38ed3b4223c1 (diff)
use M_PI instead of bespoke defines
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
-rw-r--r--src/demos/morph3d.c7
-rw-r--r--src/redbook/accpersp.c4
-rw-r--r--src/redbook/dof.c4
-rw-r--r--src/redbook/shadowmap.c4
-rw-r--r--src/samples/sphere.c7
-rw-r--r--src/xdemos/shape.c6
6 files changed, 7 insertions, 25 deletions
diff --git a/src/demos/morph3d.c b/src/demos/morph3d.c
index a9cce790..bbfa46d4 100644
--- a/src/demos/morph3d.c
+++ b/src/demos/morph3d.c
@@ -157,9 +157,6 @@ So the angle is:
#define dodecaangle 63.434948822922009981
#define icoangle 41.810314895778596167
-#ifndef Pi
-#define Pi 3.1415926535897932385
-#endif
#define SQRT2 1.4142135623730951455
#define SQRT3 1.7320508075688771932
#define SQRT5 2.2360679774997898051
@@ -314,8 +311,8 @@ static float MaterialGray[] = { 0.2, 0.2, 0.2, 1.0 };
GLfloat AmpVr2=(Amp)/sqr((Edge)*cossec36_2); \
\
for(Fi=0;Fi<6;Fi++) { \
- x[Fi]=-cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); \
- y[Fi]=sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); \
+ x[Fi]=-cos(Fi * 2 * M_PI / 5 + M_PI / 10) / (Divisions) * cossec36_2 * (Edge); \
+ y[Fi]=sin(Fi * 2 * M_PI / 5 + M_PI / 10) / (Divisions) * cossec36_2 * (Edge); \
} \
\
for (Ri=1; Ri<=(Divisions); Ri++) { \
diff --git a/src/redbook/accpersp.c b/src/redbook/accpersp.c
index 0b6708d3..bb41b003 100644
--- a/src/redbook/accpersp.c
+++ b/src/redbook/accpersp.c
@@ -45,8 +45,6 @@
#include "glut_wrap.h"
#include "jitter.h"
-#define PI_ 3.14159265358979323846
-
/* accFrustum()
* The first 6 arguments are identical to the glFrustum() call.
*
@@ -105,7 +103,7 @@ static void accPerspective(GLdouble fovy, GLdouble aspect,
{
GLdouble fov2,left,right,bottom,top;
- fov2 = ((fovy*PI_) / 180.0) / 2.0;
+ fov2 = ((fovy * M_PI) / 180.0) / 2.0;
top = nnear / (cos(fov2) / sin(fov2));
bottom = -top;
diff --git a/src/redbook/dof.c b/src/redbook/dof.c
index 558c394f..3ec59ea3 100644
--- a/src/redbook/dof.c
+++ b/src/redbook/dof.c
@@ -51,8 +51,6 @@
#include "glut_wrap.h"
#include "jitter.h"
-#define PI_ 3.14159265358979323846
-
/* accFrustum()
* The first 6 arguments are identical to the glFrustum() call.
*
@@ -111,7 +109,7 @@ static void accPerspective(GLdouble fovy, GLdouble aspect,
{
GLdouble fov2,left,right,bottom,top;
- fov2 = ((fovy*PI_) / 180.0) / 2.0;
+ fov2 = ((fovy * M_PI) / 180.0) / 2.0;
top = nnear / (cos(fov2) / sin(fov2));
bottom = -top;
diff --git a/src/redbook/shadowmap.c b/src/redbook/shadowmap.c
index 1108bb5f..1144eeec 100644
--- a/src/redbook/shadowmap.c
+++ b/src/redbook/shadowmap.c
@@ -51,8 +51,6 @@
#define SHADOW_MAP_WIDTH 256
#define SHADOW_MAP_HEIGHT 256
-#define PI 3.14159265359
-
GLdouble fovy = 60.0;
GLdouble nearPlane = 10.0;
GLdouble farPlane = 100.0;
@@ -123,7 +121,7 @@ reshape( int width, int height )
static void
idle( void )
{
- angle += PI / 10000;
+ angle += M_PI / 10000;
torusAngle += .1;
glutPostRedisplay();
}
diff --git a/src/samples/sphere.c b/src/samples/sphere.c
index dbbc3a21..bac17447 100644
--- a/src/samples/sphere.c
+++ b/src/samples/sphere.c
@@ -32,11 +32,6 @@
#include "readtex.h"
-#ifndef PI
-#define PI 3.14159265358979323846
-#endif
-
-
GLenum doubleBuffer;
int W = 400, H = 400;
@@ -443,7 +438,7 @@ static void BuildCylinder(int numEdges)
float x[100], y[100], angle;
for (i = 0; i <= numEdges; i++) {
- angle = i * 2.0 * PI / numEdges;
+ angle = i * 2.0 * M_PI / numEdges;
x[i] = cos(angle); /* was cosf() */
y[i] = sin(angle); /* was sinf() */
}
diff --git a/src/xdemos/shape.c b/src/xdemos/shape.c
index 5ff09708..2dceb427 100644
--- a/src/xdemos/shape.c
+++ b/src/xdemos/shape.c
@@ -26,10 +26,6 @@
#include <X11/extensions/shape.h>
#include <GL/glx.h>
-#ifndef PI
-#define PI 3.1415926
-#endif
-
static int Width=500, Height=500;
@@ -182,7 +178,7 @@ static void make_shape_mask(Display *dpy, Window win, int width, int height,
int cx = width / 2;
int cy = height / 2;
float angle = 0.0;
- float step = 2.0 * PI / sides;
+ float step = 2.0 * M_PI / sides;
float radius = width / 2;
int i;
XPoint points[100];