How do you draw a cylinder with OpenGLES?
You'll need to do it via object loading. You can't call on 3D shape primitives using Open GL ES.
Look through Jeff Lamarche's blog, there's lots of really good resources on how to object load there. link text
You can indeed draw a cylinder in OpenGL ES by calculating the geometry of the object. The open source GLUT|ES project has geometry drawing routines for solids (cylinders, spheres, etc.) within its glutes_geometry.c source file. Unfortunately, these functions use the glBegin() and glEnd() calls, which aren't present in OpenGL ES.
Code for a partially working cylinder implementation for OpenGL ES can be found in the forum thread here.
First step is to write a subroutine that draws a triangle. I'll leave that up to you. Then just draw a series of triangles the make up the shape of a cylinder. The trick is to approximate a circle with a polygon with a large number of sides like 64. Here's some pseudo-code off the top of my head.
for (i = 0; i < 64; i++)
{
angle = 360 * i / 63; // Or perhaps 2 * PI * i / 63
cx[i] = sin(angle);
cy[i] = cos(angle);
}
for (i = 0; i < 63; i++)
{
v0 = Vertex(cx[i], cy[i], 0);
v1 = Vertex(cx[i + 1], cy[i + 1], 0);
v2 = Vertex(cx[i], cy[i], 1);
v3 = Vertex(cx[i + 1], cy[i + 1], 1);
DrawTriangle(v0, v1, v2);
DrawTriangle(v1, v3, v2);
// If you have it: DrawQuad(v0, v1, v3, v2);
}
There is almost certainly a mistake in the code. Most likely is that I've screwed up the winding order in the triangle draws so you could end up with only half the triangles apparently visible or a very odd case with only the back visible.
Performance will soon want you drawing triangle strips and fans for efficiency, but this should get you started.