glRotatef() - How to apply rotation in multiple axis?

2.1k views Asked by At

I am trying to rotate a cube 90 degrees on the Y axis, and then 90 degrees on the Z axis, but when I apply the rotation on the Z axis, it actually changes the angle only on the X axis.

This is my code:

glRotatef(90.0, 0.0, 1.0, 0.0);
glRotatef(90.0, 0.0, 0.0, 1.0);

What is the correct way to achieve the result I want - I.e. 90 degrees on Y and then 90 degrees on Z?

Is there a good tutorial that explains how to use glRotate() correctly with examples?

1

There are 1 answers

0
krehwell On

do it once but set which angle you want to rotate within one function

glRotatef(90.0, 0.0, 1.0, 1.0);