Drawing a cylinder

I have used the gluCylinder function, but was wondering if there was source code available somewhere that draws a cylinder in OpenGL using the OpenGL primatives. Any suggestions would be appreciated, thanks!

draw a 2d circle eg with sin+cos + just give it some height

Download Mesa

All the source code is included, so you can have a look at all the source code including gluCylinder.


I think what I would do is first decide how many sides you want it to have, 6 sides 8, 10,100? Then draw 2 flat polygons with that many sides, those will be the top and bottom (for a solid cylinder). Next draw quads from each top vertex to its corresponding bottom vertex. Continue all around and there is your cylinder.

Not sure if this would work let us know how it goes.

[This message has been edited by element (edited 07-27-2001).]

Thanks everyone! I got it…appreciate the help!

maybe instead of glutCylinder try the glu version… Quadrics…