Hi. I am simply trying to rotate a triangle using rotatef but whenever I use it it not only rotates but travels around the screen. I have read multiple threads here about rotatef but they don’t seem to fix my problem. Here is my code:
glVertex2i( 40, -40);
I have seen people give reasonable explanations about how it is rotating around the origin and I need to translate to a new origin but I am pretty sure I am using glTranslate correctly? Is rotatef only to be used for 3d?
Swap your rotate and translate lines .
Wow… Why does it magically work when you tell me?! I swear I had it that way at one time. All those useless hours spent… I could have also sworn that some site said that you rotate first then translate. But thank you for giving me peace of mind!
Actually you first rotate and then translate, that’s how you should position your object.
The only thing you did not considered that OpenGL virtually executes the transforms in the opposite direction:
=> Rotate * Translate * Vertex
So actually in your case the translation was first applied, instead of the rotation.