Texture mapping problem

I’ve just encountered a problem in mapping texture.
I use glutSolidTorus to draw a solid torus. I successfully mapping texture to the torus. However, when I rotate it about x,y,z axis, it seems that the texture doesn’t move with the torus.
My code is as follows:

gluQuadricTexture(quadric, true);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, text);
glutSolidTorus(r * 0.25, r, 61, 37);

How can I fix this problem?

Of course it doesn’t; you turned on texture coordinate generation. This computes texture coordinates based on the positions of the triangles. Rotating the object changes the positions, and therefore it changes the texture coordinates. You want texture coordinates that are fixed, and therefore don’t change under object rotation.

You will have to provide texture coordinates rather than generating them.