Search code examples
qtopenglfillglu

No-top and fill gluCylinder()


Well, i have my issues with gluCylinder(), it's not letting me do the things. What i'm trying to do is to give no-top to the cylinder and fill it inside.

void GLWindow::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1,0,0);
    glBegin(GL_POLYGON);
    GLUquadricObj *obj = gluNewQuadric();

    gluCylinder(obj, 1.0, 1, 3, 30, 30);

    glEnd();
}

So the question is, how do i give the Cylinder no-top (Means, it doesn't have top), i've been trying to modify the "top" parameter but had no success on it and how do i fill it inside?


Solution

  • So the question is, how do i give the Cylinder no-top (Means, it doesn't have top),

    GLU doesn't support this. BTW: GLU is not part of OpenGL, its a companion library and has been phased out ages ago. Just implement your own cylinder drawing code.

    how do i fill it inside?

    You mean like a solid? With OpenGL you can't. Heck OpenGL doesn't even know cylinders or objects at all. All it sees are vertices it interprets as the attributes to draw single points, lines or triangles. There's no scene, there are no geometric objects.