Silicon Graphics

[Prev] [TOC] [Next]



(-) OpenGL Programming Guide
(-) Appendix CThe OpenGL Utility Library

Rendering Spheres, Cylinders, and Disks

The GLU includes a set of routines to draw various simple surfaces (spheres, cylinders, disks, and parts of disks) in a variety of styles and orientations. These routines are described in detail in the OpenGL Reference Manual; their use is discussed briefly in the following paragraphs, and their prototypes are also listed.

To create a quadric object, use gluNewQuadric(). (To destroy this object when you're finished with it, use gluDeleteQuadric().) Then specify the desired rendering style, as follows, with the appropriate routine (unless you're satisfied with the default values):

After you've specified the rendering style, simply invoke the rendering routine for the desired type of quadric object: gluSphere(), gluCylinder(), gluDisk(), or gluPartialDisk(). If an error occurs during rendering, the error-handling routine you've specified with gluQuadricCallBack() is invoked.

It's better to use the *Radius, height, and similar arguments to scale the quadrics rather than the glScale*() command, so that unit-length normals that are generated don't have to be renormalized. Set the loops and stacks arguments to values other than 1 to force lighting calculations at a finer granularity, especially if the material specularity is high.

The prototypes are listed in three categories.

Manage quadric objects:

GLUquadricObj* gluNewQuadric (void);


void gluDeleteQuadric (GLUquadricObj *state);


void gluQuadricCallback (GLUquadricObj *qobj, GLenum which, void (*fn)());

Control the rendering:

void gluQuadricNormals (GLUquadricObj *quadObject, GLenum normals);


void gluQuadricTexture (GLUquadricObj *quadObject, GLboolean textureCoords);


void gluQuadricOrientation (GLUquadricObj *quadObject, GLenum orientation);


void gluQuadricDrawStyle (GLUquadricObj *quadObject, GLenum drawStyle);

Specify a quadric primitive:

void gluCylinder (GLUquadricObj *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks);


void gluDisk (GLUquadricObj *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops);


void gluPartialDisk (GLUquadricObj *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops, GLdouble startAngle, GLdouble sweepAngle);


void gluSphere (GLUquadricObj *qobj, GLdouble radius, GLint slices,GLint stacks);


[Prev] [TOC] [Next]

OpenGL Programming Guide


Maintained by Maintainer: Send e-mail to .htm">name@address.