Advertisement

OpenGL Text Rotation

Started by May 24, 2003 08:31 AM
7 comments, last by zaNeXuS 21 years, 9 months ago
Hi all. I was wondering if it is possible to take the text in Lesson 14 and make it spin with the spinning axis being in the middle. I''ve tried: glTranslate, then a glRotate, then calling the list, but then the rotation is around the start of the first object of the list Any help... Thx in advance Nexus --------------- Gaming is Life ---------------
---------------Gaming is Life---------------
Maybe this will help:

glPushMatrix();
glRotatef(x,0,1,0);

// draw the object you want to rotate around its axis

glPopMatrix();
_________"Maybe this world is another planet''s hell." -- Aldous Huxley
Advertisement
thx for reply.

I got my push and pop, for Matrices and Attribs
---------------Gaming is Life---------------
First of all, i''ll need to know how to rotate an object around it own middlle? How
---------------Gaming is Life---------------
You have to rotate then translate.

static float Angle = 0.0f;
Angle += 0.3f;
CLAMP(Angle, 0.0f, 360.0f);

glPushMatrix();
glRotatef(Angle, 0, 1, 0);
glTranslate(Position.X, Position.Y, Position.Z);
RenderText();
glPopMatrix();

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"
OK thx Ultima.

So I just have to tranlsate to the middle of the object after rotation?
---------------Gaming is Life---------------
Advertisement
I just downloaded lesson 14 and it rotates in the middle? Whats your look like? Is it going in a big circle and not staying center? Let me know, post your rotate/translate code, and I''ll be able to help you better.


-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"
LOL, yeah I know, I thought it didn''t. The problem I now have, is, how do I know how far to translate on the axisses to get the middle, the z axis is obviuios ( half of the width), but... on the X and Y, how would I know the middles, especially if u want to change the text dynamically. My guess is using the GLYPHMETRICSFLOAT struct u send with it when u cr8 the outlines, but it''s an array of values, and how does it work anyway? :|

---------------Gaming is Life---------------
I had this working but for some unrelated problems that were screwing it up and I ended up junking the rotation code.

I can''t recall right now exactly how I did it but I think I remember using the sine of the rotation angle...

If I redo that code I will post it here.

Tim

This topic is closed to new replies.

Advertisement