projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
http://www.tienza.es/crux/src/www.jwz.org/xscreensaver/xscreensaver-5.06.tar.gz
[xscreensaver]
/
hacks
/
glx
/
sphere.c
diff --git
a/hacks/glx/sphere.c
b/hacks/glx/sphere.c
index 5aba74f0ddffbdf2c46dbe072f9ba2d84191d819..10e86d7698e1fd6b81229034067a9f5ae39deb73 100644
(file)
--- a/
hacks/glx/sphere.c
+++ b/
hacks/glx/sphere.c
@@
-1,4
+1,4
@@
-/* sphere, Copyright (c) 2002 Paul Bourke <pbourke@swin.edu.au>
+/* sphere, Copyright (c) 2002
, 2008
Paul Bourke <pbourke@swin.edu.au>
* Utility function to create a unit sphere in GL.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* Utility function to create a unit sphere in GL.
*
* Permission to use, copy, modify, distribute, and sell this software and its
@@
-15,21
+15,31
@@
* http://astronomy.swin.edu.au/~pbourke/opengl/sphere/
*/
* http://astronomy.swin.edu.au/~pbourke/opengl/sphere/
*/
-#include "config.h"
-#include <stdlib.h>
#include <math.h>
#include <math.h>
-#include <GL/glx.h>
+#include <stdlib.h>
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_COCOA
+# include <OpenGL/gl.h>
+#else
+# include <GL/gl.h>
+#endif
+#include "sphere.h"
typedef struct { GLfloat x, y, z; } XYZ;
typedef struct { GLfloat x, y, z; } XYZ;
-void
-unit_sphere (int stacks, int slices,
Bool wire
)
+int
+unit_sphere (int stacks, int slices,
int wire_p
)
{
{
+ int polys = 0;
int i,j;
double theta1, theta2, theta3;
XYZ e, p;
int i,j;
double theta1, theta2, theta3;
XYZ e, p;
- XYZ la
, lb
;
+ XYZ la
= { 0, 0, 0 }, lb = { 0, 0, 0 }
;
XYZ c = {0, 0, 0}; /* center */
double r = 1.0; /* radius */
int stacks2 = stacks * 2;
XYZ c = {0, 0, 0}; /* center */
double r = 1.0; /* radius */
int stacks2 = stacks * 2;
@@
-44,7
+54,7
@@
unit_sphere (int stacks, int slices, Bool wire)
glBegin (GL_POINTS);
glVertex3f (c.x, c.y, c.z);
glEnd();
glBegin (GL_POINTS);
glVertex3f (c.x, c.y, c.z);
glEnd();
- return;
+ return
1
;
}
glFrontFace(GL_CW);
}
glFrontFace(GL_CW);
@@
-54,12
+64,12
@@
unit_sphere (int stacks, int slices, Bool wire)
theta1 = j * (M_PI+M_PI) / stacks2 - M_PI_2;
theta2 = (j + 1) * (M_PI+M_PI) / stacks2 - M_PI_2;
theta1 = j * (M_PI+M_PI) / stacks2 - M_PI_2;
theta2 = (j + 1) * (M_PI+M_PI) / stacks2 - M_PI_2;
- glBegin (wire ? GL_LINE_LOOP : GL_TRIANGLE_STRIP);
+ glBegin (wire
_p
? GL_LINE_LOOP : GL_TRIANGLE_STRIP);
for (i = 0; i <= slices; i++)
{
theta3 = i * (M_PI+M_PI) / slices;
for (i = 0; i <= slices; i++)
{
theta3 = i * (M_PI+M_PI) / slices;
- if (wire && i != 0)
+ if (wire
_p
&& i != 0)
{
glVertex3f (lb.x, lb.y, lb.z);
glVertex3f (la.x, la.y, la.z);
{
glVertex3f (lb.x, lb.y, lb.z);
glVertex3f (la.x, la.y, la.z);
@@
-76,7
+86,7
@@
unit_sphere (int stacks, int slices, Bool wire)
glTexCoord2f (i / (double)slices,
2*(j+1) / (double)stacks2);
glVertex3f (p.x, p.y, p.z);
glTexCoord2f (i / (double)slices,
2*(j+1) / (double)stacks2);
glVertex3f (p.x, p.y, p.z);
- if (wire) la = p;
+ if (wire
_p
) la = p;
e.x = cos(theta1) * cos(theta3);
e.y = sin(theta1);
e.x = cos(theta1) * cos(theta3);
e.y = sin(theta1);
@@
-89,8
+99,10
@@
unit_sphere (int stacks, int slices, Bool wire)
glTexCoord2f (i / (double)slices,
2*j / (double)stacks2);
glVertex3f (p.x, p.y, p.z);
glTexCoord2f (i / (double)slices,
2*j / (double)stacks2);
glVertex3f (p.x, p.y, p.z);
- if (wire) lb = p;
+ if (wire_p) lb = p;
+ polys++;
}
glEnd();
}
}
glEnd();
}
+ return polys;
}
}