i am new opengl learner. i know there is build in function to draw cylinder in glut something like
GLUquadricObj *quadratic;
quadratic=gluNewQuadric();
gluCylinder(quadratic,0.6f,0.6f,1.5f,20,20);
However, is there any other way to draw cylinder using glBegin(GL_POLYGON) and glvertex3d, i am not quite clear about the algorithm behind, please help.
Use sin/cos to trace around a circle in segments. Extend those segments upwards with 2 triangles. Then connect them to close the ends.
You may be able to find the source online for freeglut. Here’s some Java code I found: http://massapi.com/source/lwjgl-source-2.7.1/src/java/org/lwjgl/util/glu/Cylinder.java.html