glRotatef behaviour

Hello,

I am rendering text in gl using an interface to freetype.

When I attempt to rotate the text, the origin of the text moves. For example if I attempt to rotate text centered in the middle of my window by 45 degrees, the result is text rotated at the top left corner of my window.

Is there something obvious that I could be doing wrong?

Thanks.

Where is the origin of you text, openGL rotates around 0,0,0. You must translate the origin point in which you rotate to this point.

Let take a box, with the 0,0,0 origin at one corner. When we rotate the box it will be rotated around that corner. If we want the box to rotate round its center axis we must move it to 0,0,0.

Let say our box it 0,0,0 top left and 1,1,0 bottom right. the center will be 0.5, 0.5, 0.0 .
So we must translate the box’s center to 0,0,0. which would be glTranslatef(-0.5, -0.5, 0.0);

code looks something like this:

glRotatef( 45, 0, 0, 1);
glTranslatef(-0.5, -0.5, 0.0);
Draw_box();

Originally posted by MikeH77:
[b]Hello,

I am rendering text in gl using an interface to freetype.

When I attempt to rotate the text, the origin of the text moves. For example if I attempt to rotate text centered in the middle of my window by 45 degrees, the result is text rotated at the top left corner of my window.

Is there something obvious that I could be doing wrong?

Thanks.[/b]