Creating Spheres

Is there a function in OpenGL that will create a sphere? How do you create sphere if there is no GL_SPHERE command or something similar…

You can create a sphere using gluSphere, or simply use the formula for a sphere to create one yourself.

what is the formula for a sphere? isn’t it something like sine squared times cosine squared or something like that? Its been awhile since I took a math class.

search google for a guy named paul bourke. his page has just about everything under the sun when it comes to math/trig/geometry

jebus

Is there a gluCylinder function too ?

There are a few different versions.

Wire/Solid Cube - 1 Parameter
glutWireCube ( 2.0 );
glutSolidCube ( 2.0 );

Wire/Solid Sphere - 3 Parameters
glutWireSphere ( 2.0, 30, 30 );
glutSolidSphere ( 2.0, 30, 30 );

Wire/Solid Cone - 4 Parameters
glutWireCone( 0.5, 1.0, 8, 8 );
glutSolidCone( 0.5, 1.0, 8, 8 );

Be sure to include glut.h and glut32.lib

-VC6-OGL

…so there’s no glutSolidCone( ) ?

What if I made my own cylinder. I was thinking of trying a for loop that would create a polygon side and iterate it in a circle. If I want the cylinder to circle around the Y-axis what values do you change the x,y,z in glVertex3f(x,y,z) by?

> what is the formula for a sphere?

r = [constant]

GLUquadricObj *pObj = gluNewQuadric();
gluQuadricTexture(pObj, true);
gluSphere(pObj, size, 32, 32);

I use GLquadrics, they can be used to create spheres and cones, cylinders etc, search the internet for examples of GLquadrics. They also provide texture mapping co-ordinates, so they are excellent for rendering textures on spheres.