Basic Animation

Hi,

I’m using Glut and…

I’m trying to do some basic animation:
I have a cube and I would like it to
move smoothly upwards,
then once there move right;
then move back down to the original height;
finally it should move back to it’s starting position.

X----------X
| |
| |
X----------X

I must be really thick as I cannot see how to use the idlefunction to do
this, all I manage is to get it to move upwards slowly to a certain point
then I cannot get to to come down again, as I’m fighting against the
idlefunction…

ideas??

thanks

Greg

The idea that immediately comes to mind is a case statement:

switch(direction){
case up: translate up some more; break;
case left: translate left some more; break;
case down: translate down some more; break;
case right: translate right some more; break;
}

Put it in your idle function, and have a counter that switches your direction at the correct points.

Chris

… and after that, in the idle-function, you place glutPostRedisplay() to tell GLUT that you want to redraw the screen.