Hey, I am fairly new to OpenGL and I am currently in the process of programming a game. I am trying to make a cube that can rotate/translate (to give the affect that it is rolling) around the X/Z plane.

I am currently using :

glRotated(angle, 1.0, 0.0, 0.0); //rotate on the x axis

glRotated(angle1, 0.0, 1.0, 0.0); //rotate on the y axis

glRotated(angle2, 0.0, 0.0, 1.0); //rotate on the z axis

to perform the rotation, but as the object has local co-ordinates the axis position/direction is constantly changing with each rotation. Can anyone tell me how I can keep a fixed axis by which the object rotates around, rather then the axis rotating and the object following it.

I have tried creating 4 rotate functions per axis, so each one rotates by 90, then when the final one finishes, they are all reset back to 0. It was a very long shot but it didnt work obviously!

From what I can gather glMultMatrix seems to be the way forward, but I cannot get my head around the coding at all.

If it helps (anyone feels kind/bored enough to do the algorithm for me ) I have 3 rotation matrices as can be seen above, and my algorithm for rotation is :

if (Left == true)

{

//if (angle == 0){

angle2 = angle2 + 18;

xDisp = xDisp - 1;

Sleep(50);

whereby the boolean is set to false via an if statement when the angle reaches 90 / 180/ 270 respectively, and the left key is an idlefunction, so that the object will rotate by itself through those angles. I also have an if conditional for when it reaches 360 that resets the angle back to 0.

Any help will be very appreciated as I have been working on this for many hours, and all i want is a cube that can be user controlled and rolls around a screen. At the moment I feel ti would be easier to get blood from a stone.

[EDIT] I forgot to add that I have also tried transforming the cube back to the origin, then rotating, but obviously as the axis are changing directions, this does not work either.

Kind Regards,

EJDSlayer