rotating sphere with earth texture

Hello opengl gurus,

I have a sphere that I used gluSphere to create. I read a jpg file of the earth and put this texture to the sphere. What I want to do is to be able to rotate the sphere around the x and y axis. I have read several reports about the dreaded gimbal lock problem. I think this is my problem as well. Here is the code that I am using to rotate the sphere.

glTranslatef(-(x_Translation), 0.0, y_Translation);

glRotatef(x_Rotation, 1.0f, 0.0f, 0.0);
glRotatef(y_Rotation, 0.0f, 1.0f, 0.0);
glRotatef(z, 0.0f, 0.0f, 1.0f);

//Draw the sphere object and the trajectory
gluSphere(quadObj, 0.7, 30, 30);

But the sphere rotates in every direction. Can someone help me with setting this up to where the sphere will only rotate around the x and y axis. I am a beginner so I don’t know anything about quaternions.


I forgot to add that I am using the z rotation to turn the globe up so that the poles are on the y-axis.

I guess you want it to spin on planets axis???
You will need to rotate it on the Z-axis, then adjust the x/y axis rotations for correct orintation of planet.

look at my textured sphere demo on my website called glball.

yeah, he’s right…
FIRST rotate around Z, THEN the actual rotation on the X and Y-axis.