Erm … sorry to ask such a stupid question but how can i generate sphere without using Toolkits like GLU oder GLUT …

I also doesnt want to see the diffcult pages by paul bourke … a easy explain is all i want !!!

I have a basic knowledge of trigonmetry so u can tell me … but please explain easily …



Thanks for the Paul Bourke reference! I’d never heard of him before but his web page http://astronomy.swin.edu.au/~pbourke/
is most excellent. He discusses spheres here:


Btw, if that stuff seems to be over your head, review your spherical coordinates.

[This message has been edited by jmg (edited 10-22-2002).]

Spheres are one of the easier shapes to do because they are symetric. First you have to decide which co-ordinates are on the surface of your shape (in this case a sphere). For a sphere this is all points a distance r away from the centre. You need some control over reaching each co-ordinate so we will use two angles theta and phi. Think of the center of the sphere this is just a circle. The phi variable is the angle from the x axis. If we were just drawing a circle we would draw:

x= r cos (phi) and
y= r sin (phi)

I would imagine using a loop to increment phi and draw from one bit of phi to the next.
However we have a sphere. Now if you think of a sphere it is just lots of circles but with different radi. The radius can be worked out with a bit of trig. Draw a semi-circle
| |


Mark an angle from the verticle to a point on te semi circle. Draw a horizontal line. This line is the circle in thelast bit and has a radius of sin (theta)
This circle is at a height of r cos theta
OK so now we have all our points:

x = r sin (theta) Cos (phi)
y = rsin (theta) Sin (phi)
z = r Cos (theta)

We now make two loops and draw triangle through all these points connecting them all.

for (int i=0;i<maxsegs;i++){
for (int j=0;j<=maxsegs;j++){

Hope that helps,


P.S. All code writtern without testing and source so there may be mistakes but as long as you understand the idea it should be fine