GluCylinders

GluCylinders is sample C++ code illustrating how to draw cylinders and slant cylinders with the gluQuadric routines of OpenGL.   It is intended to accompany the book 3D Computer Graphics: A mathematical approach with OpenGL, by S. Buss, Cambridge University Press, 2003.   However, it can be used independently as well.

GluCylinders Draws a cylinder and slant cylinder. The red cylinder is drawn without any face culling and without any top or bottom disks. The green cylinder is drawn with back faces culled, and with a top and bottom disk.

Arrow keys control the viewpoint. The command "w" toggles wireframe mode, but since there is no Phong lighting the cylinders look terrible in "Fill" mode.

To use these in your own code, just copy out the set of four routines at the end of GluCylinders.c. The code as written generates cylinders that have smooth normals. If you need texture coordinates generated, you will need to call gluQuadricTexture, for this, see the OpenGL documentation (in the red book, or elsewhere).

There are several options for downloading the files.