texture mapping on cylinder, torus and teapot

Hello there,

I know how to texture map a 2d texture map on a cube… i need the texture map coordinates…

But how do i go about doing texture mapping for cylinders, torus and teapot…

I think there’s some way to automatically generate the texture coordinates… could it happen for these objects?

Has anyone seen an example anywhere about this?

Thanks…

In order to use automatic texture generation write this in the Init()-funktion:

glEnable(GL_TEXTURE_2D);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

glTexCoords2*()-funktions will be ignored.

You can also use GL_OBJECT_LINEAR og GL_SPHERE_MAP instead of GL_EYE_LINEAR.