I am drawing a cube which I want to move on its own 3 axis (not the ones from the base coordinates). The cube will never be located on the origin, this is why i need to use the glTranslatef() function.
I don't understand:
When I rotate the cube on its y-axis everything goes fine. When I try to rotate it on its x-axis it doesn't work properly: it starts moving accros my screen and doesn't stay on its position.
works fine: (my cube rotates on its own axis while staying in its own position(0,0.5,0))
glTranslatef(0, 0, 0);
glRotatef(getCubeAngle(), 0.0f, 1.0f, 0.0f);
glTranslatef( 0.5, 0, 0.0);
doesn't work fine: (cube rotates on its own axis + the cube starts moving over my screen along the x-axis)
glTranslatef(0, 0, 0);
glRotatef(getCubeAngle(), 0.0f, 1.0f, 0.0f);
glTranslatef( 0.5, 0, 0.0);
/*glTranslatef( 0.0, 0.5, 0.0); with this line instead it works well*/
why?