gluSphere with texture, result is reversed texture.

Hi.

I am creating some planets. I am using some images of our dear planet as textures, and using gluSphere to render the planet. However, the result is a “reversed” earth. Not vertically, so that the north pole is the south pole and vice versa. Rather, it’s flipped horisontally, so that the earth appears “backwards” for lack of a better word. Now, my other textures (stars & background, - simple textured quads) work as they should. It is only a problem (at least so far), when using gluSphere.

I am not doing anything really special, so I am hoping someone has witnessed this before, and know what I am doing wrong?


gl.glPushMatrix();
			
			gl.glTranslatef(xpos, ypos, -1);
			
			
			// get a nice orbital angle.
			gl.glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
			gl.glRotatef(20.0f, 1.0f, 0.0f, 0.0f);
			// set orbit radius
			gl.glTranslatef(orbitRadius, 0.0f, 0.0f);
			
			// textures don't map properly for planets.
			// Rotate a bit so the planets appear correct.
			gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
			gl.glRotated(-rotationAngle, 0.0f, 0.0f, 1.0f);
			
			// bind the texture.
			planetTextures.get(textureRef).bind();
			
			glu.gluSphere(gluq, planetRadius, planetDetailLevel, planetDetailLevel);
			gl.glPopMatrix();
			
			rotationAngle += rotationSpeed;


Hi, I see noone answered to this. I guess I am lost :wink:

In addition to the problem mentioned before, it seems that textures do not blend properly when rendered infront of these spheres. I have png images that are partially transparent (Parts of the image have alpha 0). The parts that are completely transparent appear as they are supposed to, transparent, when drawn in front of other quads, triangles, etc. But when they are drawn in front of these spheres, the transparent parts are black.

It is annoying. Hopefully this additional information will bring someone to write what they think could be the problem.

Thanks.

The simplest cause of your problem with the texturing could just be that that’s how gluSphere defines the texture coordinates. If you find you still need to rotate things 90 degrees, it would be better to do that step using the texture matrix stack, just to keep things organized and clear. Transparency is somewhat complicated and even if something is transparent, the end result can be greatly affected by the order in which things are rendered and by the blend mode and function. I would look into the redbook for more information about that.