Understanding glRotate and glTranslate

Hi guys,

I am here because I hve a problem to understand the glRotate and glTranlate function of opengl.

I have following problem:

There is an object in the world space. The object will be translatet by glTranslate. After the translation I am rotating the object with glRotate around the world coordinate space.




glRotate( angle, 0.0, 1.0, 0.0 );
glTranslate( posx, posy, posz );



In the next programm loop, if I am translating the object, it will move along the local axis and not along the world axis.

What I am doing wrong??? I mean evry loop my modelview matrix will be cleared by using glLoadIdentity(). Then I am moving the object along the world axis and rotate the object.

Here is an Image which shows my problem I get the result 2 but I want do get result 3.

Best regards and thanks alot for the help.

This question is a very frequent one on this forum. Try to find previous answers.

In short: If you “think” in the global coordinate system then transformations appears in the code in opposite direction (the first transformation that affects the object is the nearest to the drawing object in the code). If you “think” in the local coordinate system then transformations appear in “normal” order, but they transform local coordinate system, not the object, and all parameters are define in a local system. Be aware that in both cases the code looks just the same.

For more information read OpenGL Programming Guide Chapter 3