Rendering Simple Surfaces
The GLU library includes a set of functions for drawing various simple surfaces (spheres, cylinders, disks, and parts of disks) in a variety of styles and orientations. These functions are described in detail in the OpenGL Reference Manual.
To render simple surfaces
-
Create a quadric object with gluNewQuadric.
To destroy this object when you're finished with it, use gluDeleteQuadric.
-
Specify the desired rendering style, as listed below, with the appropriate function (unless you're satisfied with the default values):
-
Whether surface normals should be generated, and if so, whether there should be one normal per vertex or one normal per face: gluQuadricNormals
-
Whether texture coordinates should be generated: gluQuadricTexture
-
Which side of the quadric should be considered the outside and which the inside: gluQuadricOrientation
-
Whether the quadric should be drawn as a set of polygons, lines, or points: gluQuadricDrawStyle
-
After specifying the rendering style, invoke the rendering function for the desired type of quadric object: gluSphere, gluCylinder, gluDisk, or gluPartialDisk.
If an error occurs during rendering, the error-handling function you've specified with gluQuadricCallBack is invoked.
Use the *Radius, height, and similar arguments, rather than the glScale function, to scale the quadrics, so that you don't have to renormalize any unit-length normals that are generated. To force lighting calculations at a finer granularity, especially if the material specularity is high, set the loops and stacks arguments to values other than 1.