sphere texture problem

I have a small gluSphere (textured), when I move my scene around, the texture keeps getting re-aligned to face me (ie it moves). How can I stop this?

Also, Im not using
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

can someone tell be the difference between using these and not? Im not, and it works fine??

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
Just tells OpenGL how to calculate the texture coords IF auto texture coord generation is turned on.

To turn it on use glEnable(GL_TEXTURE_GEN_S);
and glEnable(GL_TEXTURE_GEN_T);

Make sure you have these disabled. Use the appropriate tokens to glDisable.

Never used those glu functions so I’m not sure what else the problem could be.

Lets look, maybe i an help (I’ve done a Texturing class yesterday)
First, I load my Textures like this :

glBindTexture(GL_TEXTURE_2D, Texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3,
Image->sizeX, Image->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, Image->data);

Where Image is AUX_RGBImageRec.
I dont think the bug is int this part. But So far just assure, we are loading the texture the same way.

Now here’s the important part:

in your RenderScene method, before glBegin(); and glEnd(); put this:
glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP_NV);
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP_NV);

for Reflection-mapping or this:

glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

for sphere-mapping.

NOW, it is URGENT, that you enable the automatic TexCoords generation:

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

And then if your code contains #include <gl/glut.h> put

glutSolidTeapot(double size);

after all that (erverything still in the RenderScene-method, of course)

and you should get a sphere- or reflection- mapped teapot.

easy tough…

Sorry for the layout (Mozilla nightly build is guilty , but FASTEST browser ever seen!!!)

cheers peoples, I’ll try those out

I got it working without the auto coord geration, so now ill try and get it going with that

Hey, when I use
glTexGenfGL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGenfGL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

and gluSphere()

The texture is drawn to always face me??

Yepp, that’s how sphere mapping works.

The texture you use is a reflectionmap of the environment, and GL_SPHERE_MAP calculates the proper texture coordinates so it appears that the object is reflecting the environment.