Search code examples
javaopengllwjglglrotate

LWJGL glRotatef using multiple axis


I am trying to rotate something on theoretically the y 90 degrees to show the side, and then 45 degrees on the z to put it at an upwards angle. I do so with:

glRotatef(90, 0, 1, 0);
glRotatef(45, 0, 0, 1);

The problem is that it isnt rotating off the original axis, and is instead turning based off the last position. I was wondering how to rotate the axis at the same time or to achieve the effect that it rotates from the original. I am not sure if I clarified enough so just tell me.


Solution

  • Not sure if this is what you mean, but of course you can use:

    glRotatef(45, 0, 2, 1);
    

    Or even:

    glRotatef(1, 0 ,90, 45);