Simple Rotation Problem

I would like to rotate a polygon (drawn by glutSolidCube) in a 3D enviroment. Suppose the white dot is the front view of X axis, my question is, I want to rotate it in this way:

instead of in this way:

just like the hour hand spinning around the clock center.

Maybe it is a simple question but I cannot figure it out. Hope you guys can help me. Thanks a lot:)

You need to translate before you rotate, probably by half the width of the polygon.

Thanks Pziko:) Would you please specify more? Since i am a newbie I don’t understand this concept.

i doubt
this problem is about scalef.

Thanks Pziko:) Would you please specify more? Since i am a newbie I don’t understand this concept. [/QUOTE]

Actually you need to first rotate and then traslate your objects if you want to rotate around the world coordinate system.
You need to think about local coordinate system and move from top to bottom. For example:
R1
T1
rotates the coordinate system first and then translates it.However the following order:
T1
R1
translates the local coordinate and then rotates it around itself, so you don’t get that desired effect.

Thanks for your kind help :slight_smile: I will keep trying with the method you guys provided.

I have another problem. That is, when I rotate my polygon (drawn by glutSolidCube), the shape of the polygon has changed to parallelogram shape. How do I maintain the shape during rotation?
Please be reminded that it is a 3D world.

you need to specify the Projection Transform using gluPerspective() and pass correct aspect ratio to it.For example you can use:
gluPerspective( 45.f, double( m_width ) / double( m_height ), 1., 10000. );
m_width and m_height are the width and height of the window respectively.