View Full Version : Creating Spheres

11-19-2002, 08:32 AM
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...

11-19-2002, 08:53 AM
You can create a sphere using gluSphere, or simply use the formula for a sphere to create one yourself.

11-19-2002, 08:56 AM
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.

11-19-2002, 09:22 AM
search google for a guy named paul bourke. his page has just about everything under the sun when it comes to math/trig/geometry


11-19-2002, 02:13 PM
Is there a gluCylinder function too ?

Stack Overflow
11-19-2002, 03:01 PM
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


11-19-2002, 03:07 PM
...so there's no glutSolidCone( ) ?

11-19-2002, 03:36 PM
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?

11-20-2002, 05:26 AM
> what is the formula for a sphere?

r = [constant]


11-21-2002, 05:29 AM
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.