7 hours ago, tamlam said:
I try to use the below function
glutTimerFunc(0, Timer, 0);
but it only happens for one rotation action.
The first parameter defines the interval the call will be made. You've specified in no time. (so it may only fire once, not sure on that)
Moving on...
Here is an example of one way, you could do it.
// global access
float rotation = 0.f;
float step = -2;
// inside an update or timer function
{
rotation -= elapsedTime * 40.f;
if (rotation < -90)
{
rotation = 0.f;
step += 1.f;
}
}
// inside your draw callback
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(step, 0, 0);
glRotatef(rotation, 0, 0, 1);
glTranslatef(0, 0, -5); // so I can see it
glBegin(GL_QUADS);
glColor3f(1.f, 1.f, 1.f);
glVertex3f(-1, 0, 0);
glVertex3f(0, 0, 0); // pivot point is already on the side(right bottom)
glVertex3f(0, 1, 0);
glVertex3f(-1, 1, 0);
glEnd();
}
I've cheated here perhaps with the arrangement of the vertices. A normal rotation will appear correct the first 90°. What I've chosen to do is only use that range of 0° to 90° and when I reach my rotation, I reset to zero and advance the translation variable I'm tracking. In computer graphics, the goal is to create the illusion with the least amount of background work.
Have you considered a modern openGL environment?