Please help with openGl

I wanted to render a section of a sphere and then find the normals at every point on the shape. I want the radius of the sphere to be 10cm. Can anybody tell me how to do that in opengl?

Rendering a sphere can be done with gluSphere. OpenGL itself won’t calculate normals for you, but the normal calculation for a sphere is pretty simple. For any point v on the sphere, the normal would be normalize(v - c), where c is the center of the sphere, and normalize sets the length of the resulting vector to 1.

Hi thanks for your reply but the gluSphere renders a whole sphere and i just want half of it

Then you can either do your own sphere calculations, or use clip planes to clip the gluSphere.

you will have to either do the math for half a sphere or create the object in maya or another package and load it into the program.

Thank you for the replies. DO you know if theres some example code out there someplace?


These are equations for every vertex in a sphere:
x = radius * cos(alpha)*sin(theta)
y = radius * sin(alpha)*sin(theta)
z = radius * cos(theta)

If you a half of sphere just render it with theta from 0 to 90 degrees and alpha from 0…360. Whole sphere would be theta from -90…90 degrees.

[This message has been edited by glYaro (edited 10-28-2003).]

THanks. I know the equation of the sphere. Unfortunately its the rendering that im having trouble with…