OpenGL glRotatef

What's the difference between

glRotatef(angle, 1.0f, 0.0f, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);

and

glRotatef(angle, 1.0f, 0.0f, 1.0f);

And why does nothing change when I change the second parameter 1.0f to 5.0f? Finally, how can I rotate an object around x = 5 and not around x = 0?

+5
source share
3 answers

If you want to rotate around x=5, you must do glTranslatebefore x=5and regardless of your y coordinate, then do glRotate, and then glTranslateback to the beginning.

So something like

glTranslate(5, 0, 0);
glRotatef(...);
glTranslate(-5, 0, 0);

For the first question, I include @genpfault's answer for completeness. This is due to the vector normalization performed glRotatef()on the vector you pass into.

+6
source

And why does nothing change when I change the second parameter 1.0f to 5.0f?

, glRotatef(), .

+3

, . , , , .

90 Y, 90 X. , . 90 X, 90 Y. , .

, , , .

, ( , ), .

+1

All Articles