Rotate a globe sphere with cursor keys

How can we rotate a globe sphere with cursor keys? I tried:

glRotatef(rotx,1.0f,0.0f,0.0f,);
glRotatef(roty,0.0f,1.0f,0.0f);

and increased/decreased the variables rotx,roty but when I rotate the sphere around x axis and then around y axis, the result isn’t the one i want

…the result isn’t the one i want

Then what do you want?

It seems that when the angle rotx is not 0, when I try to rotate the sphere around y axis, it’s rotating around x axis too(although it’s not)…I want to rotate the sphere only left and right…do I have to use gluLookAt instead of glRotatef?

Have you tried using the Z axia in place or X or Y?

Originally posted by Puma1140:
It seems that when the angle rotx is not 0, when I try to rotate the sphere around y axis, it’s rotating around x axis too(although it’s not)…I want to rotate the sphere only left and right…do I have to use gluLookAt instead of glRotatef?

Hi,

You need to set flags for that.

if(ROTX_FLAG == true)
{
glRotatef(rotx,1,0,0);
}
if(ROTY_FLAG ==true)
{
glRotatef(roty,0,1,0);
}
Hope it can help.

Unfortunately, this doesn’t work either…

Hi,

What do you mean that is not work? What do you have currently? Could you rotate the object in x, y, z axis? Please confirm it first?

i sent a post to coding->advanced Moving camera position 12/12/2003 it will help