Search code examples
openglglu

View the inside of a cylinder


If I draw a gluCylinder with a gluDisk on top. Without culling enabled, I get the desired cylinder with lid effect. However, if I enable culling, the disk (aka lid) disappears. Why is that? This is the main question. In addition, with culling enabled the back faces of the cylinder are also not drawn. I get why this is happening but I would still like to see the inside of the cylinder drawn. The code is:

    glPushMatrix()
    quadratic = gluNewQuadric()
    gluQuadricNormals(quadratic, GLU_SMOOTH)
    gluQuadricTexture(quadratic, GL_TRUE)
    glRotatef(90, 1, 0, 0)
    glTranslate(0, 0, -3*sz)
    gluCylinder(quadratic, 0.75*sz, 0.75*sz, 3.0*sz, 32, 32)
    gluDisk(quadratic, 0.0, 0.75*sz, 32, 32)
    glPopMatrix()

Solution

  • Your disk is facing in the wrong direction (wrong winding). Therefore, it is culled. You can try to reverse its orientation using gluQuadricOrientation, this should do the trick. For more information, refer to the OpenGL spec for gluDisk and glCullFace.