help!!how to draw a cylinder by Glut or other simple methods?

i want to draw a circinal table which consists of cylinders.
can i draw that in a simple ways?
thanks a lot first.

It seems that you have GLUT. Try to modify the glutSolidCone procedure of it. Notice its params? It has only a base param for the radius of the bottom. Yes, add another param to it to specify the radius of the top. That’s easy.

Oh I forgot. This can only make a cylinder without top and bottom, which is definitely not suitable for your round table. It seems no simple way to make it. Try make polygons instead then.

Perhaps you should look into the functions




and combine them in the appropriate manner

some very simple code to do it
GLUquadricObj* quad= gluNewQuadric();
void drawCylinder(float width, float height)

gluCylinder(quad,width,width,  height,20,20);
glTranslatef(0,0, height);


now remember to delete that quadric object and you are set… until you need texturing

in which case you just call

gluQuadricTexture(GLUquadricObj *quadObject,
GLboolean textureCoords)

with GL_TRUE as the second param

good luck

i worked it out.
It’s very kind of you.Dong Ke and mr x.
thanx a lot.