# glRotate problem

Hi,

Ive created 2 sphears and rendering them something like this:

glPushMatrix();
glTranslatef();
glRotate(ang, 1, y, z);
draw sphear
glPopMatrix();

glPushMatrix();
glTranslatef();
glRotate(ang, x, y, 1);
draw sphear
glPopMatrix();

The first sphear rotates ok, (around x)
but the second one rotates around both x and z

Whats causing that?
Doesnt glPushMatrix means to load a clean matrix without any transformation?

(I dont want to use glLoadidentity()
but maybe thats the only way?

Hope not, then i need to relocate whole my world

Thanks guys.

glpushmatrix pushes the current matrix to the matrix stack (clever name for such a function )
glloadidentity sets the current matrix to identity and is perhaps what you mean by a ‘clean matrix’

[This message has been edited by satan (edited 02-14-2002).]

Ok,
but how do i rotate the sphears without having the first affecting the other?

tx

Unless of course, you had left some value for x when you rotate the 2nd sphere

Originally posted by Dies_Irae:
[b]Ok,
but how do i rotate the sphears without having the first affecting the other?

tx

[/b]

Everything appears ok to me except for the x, y, and z variables in the glRotate calls.

If you want to rotate around the X axis, the call should be:

``````   glRotate(ang, 1, 0, 0);
``````

If you want to rotate around the Z axis, the call should be:

``````   glRotate(ang, 0, 0, 1);
``````

I bet you put the x, y, and z values in because of the translations. Don’t do that.

Hey,

Yea sorry its like that, dont know why i typed like that,

glRotate(90, 1, 0, 0)

glRotate(90, 0, 0, 1)

If you Push and Pop matricies around them ,
the 2nd one should not rotate

(x 90 z 90) if thats true there must be something else with my code, time for some serious debuging