I have a simple rectangular shape in my application which I am rotating fixing one of its side, and rotating around the X axis. The rotation looks something like the following figure (grey denotes the current rotation that I am getting with this figure)
I am using the following code to get this rotation
glPushMatrix();
glTranslatef(position of the axis point which has to be fixed for rotation);
glRotatef(rotationAmount, 1,0,0);
glTranslatef(-position of the axis point which has to be fixed for rotation);
Rectangle(xPosition, Position,200,100);
glPopMatrix();
However, I have to rotate this same figure with an additional rotation around y axis around one of its side (green arrow direction in the figure). How do I rotate this rectangle such that it keeps on rotating around x-axis and around y-axis simaltaneously?
I did try adding another glRotatef(rotateAroundYaxis amount,0,1,0) but the output does not actually looks like what I was expecting. The figure rotates in two quadrants instead of rotating around y-axis like a simple page turn.
While if I try these two rotations independently using only one of them in the program (not both of them together), i.e.
glRotatef(rotateAmount,1,0,0);
glRotatef(rotateYamount,0,-1,0);
I do get the required X and Y rotations independently, but when together, it combines into some weird rotation effect.