View Full Version : help!!how to draw a cylinder by Glut or other simple methods?

10-30-2001, 09:33 AM
i want to draw a circinal table which consists of cylinders.
can i draw that in a simple ways?
thanks a lot first.

Dong Ke
10-30-2001, 02:58 PM
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.

Dong Ke
10-30-2001, 03:02 PM
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.

10-30-2001, 03:31 PM
Perhaps you should look into the functions




and combine them in the appropriate manner

10-30-2001, 04:15 PM
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

10-31-2001, 12:14 PM
i worked it out.
It's very kind of you.Dong Ke and mr x.
thanx a lot.