Texture Mapping

Does anyone know if you can texture map a cylinder (using gluCylinder, not creating your own from quads). If so, do you do it the same way you would to a cube? Thanks.

Either use OpenGL’s automatic texture coordinate generation (glTexGen*), or enable texture coordinate generation through glu when drawing your quadric. Don’t know how to do that though, but you can do a search on the net.

GLUquadricObj* pCylinder = gluNewQuadric();

// if you use lighting add
gluQuadricNormals(pCylinder, GLU_SMOOTH);

// For texcoords
gluQuadricTexture(pCylinder, GL_TRUE);

// Replace … with your cylinder parameters
gluCylinder(pCylinder, …);