Hey there,
i have to crate a cylinder with GL_QUADS but its not working, it shows a rectangle only..
can someone pleas help me .. (i am very very new in qt and OpenGL)


void OGLWidget::initializeGL()
{
initializeOpenGLFunctions();

glClearColor(0,0,0,1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);

}




void OGLWidget::paintGL()
{
const double PI = 3.14159;
glColor4f(1, 0, 0, 1.0);

/* top triangle */
double i, result = 0.1;
double height = 1, radius = 0.5;
glPushMatrix();
glTranslatef(0, -0.5, 0);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, height, 0); /* center */
for (i = 0; i <= 2 * PI; i += result)
glVertex3f(radius * cos(i), height, radius * sin(i));
glEnd();

// bottom triangle
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, 0, 0); /* center */
for (i = 2 * PI; i >= 0; i -= result)
glVertex3f(radius * cos(i), 0, radius * sin(i));
glVertex3f(radius, height, 0);
glEnd();

/* middle tube */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= 2 * PI; i += result)
{
glVertex3f(radius * cos(i), 0, radius * sin(i));
glVertex3f(radius * cos(i), height, radius * sin(i));
}
/*loop back to zero degrees */
glVertex3f(radius, 0, 0);
glVertex3f(radius, height, 0);
glEnd();
glPopMatrix();
}

void OGLWidget::resizeGL(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

}