Create a complete solid cylinder with GLUT.


September 2010.
Code:

//Output a cylinder with both lids.
//Erwan Martin
#define SOLID_CLOSED_CYLINDER(QUAD, BASE, TOP, HEIGHT, SLICES, STACKS) \
gluCylinder(QUAD, BASE, TOP, HEIGHT, SLICES, STACKS); \
glRotatef(180, 1,0,0); \
gluDisk(QUAD, 0.0f, BASE, SLICES, 1); \
glRotatef(180, 1,0,0); \
glTranslatef(0.0f, 0.0f, HEIGHT); \
gluDisk(QUAD, 0.0f, TOP, SLICES, 1); \
glTranslatef(0.0f, 0.0f, -HEIGHT);

Usage:

GLUquadric *quadric = gluNewQuadric();
gluQuadricDrawStyle(quadric, GLU_FILL);
gluQuadricOrientation(quadric, GLU_INSIDE);
SOLID_CLOSED_CYLINDER(quadric, 0.17f, 0.17f, 0.15f, 20, 20)
gluDeleteQuadric(quadric);

Reference: