Sphere mapping pain.

I’m trying to use the GL_SPHERE_MAP feature to create a sphere mapping for an envoriment texture.

Everything seems to work fine, except that rotating the camera doesn’t effect the generated texture.

If I rotate the object when drawing it, then the texture looks like it’s reflecting the envoriment. Where as rotating the camera as no effect.

What could I be doing wrong?

gl.glMatrixMode( GL.GL_TEXTURE );

ahh… this allows you to rotate the texture coords.

never mind I figured it out.

Quite true, but you don’t need that for sphere mapping. Here’s an example:


        if (sphereMap)
        {
            gl.glEnable(GL.GL_TEXTURE_GEN_S);
            gl.glEnable(GL.GL_TEXTURE_GEN_T);
            gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP);
            gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP);
        }
        else
        {
            gl.glDisable(GL.GL_TEXTURE_GEN_S);
            gl.glDisable(GL.GL_TEXTURE_GEN_T);
        }