Need help in animating(scale)

Hi all,
I have a problem again(think should change my nick to problem_kid!!!)

Im trying to produce a animation of a object(cube) and tried to scale it to double the size and back to the normal size and back and forth. I have used a glutTimerFunc to animate it. The problem is that my object will continue to get bigger til it disappear out of my viewing area. Why doesn’t it go back to the normal size.

my code :

void timer(int value)
{
glScalef(1.0,1.0,1.0);

x-= 0.1;

if (x < 0.5 )
{
x= 1.0;
}

glutPostRedisplay();
glutTimerFunc(20, timer,value);   

}

//there is a glutTImerFunc in the main function.

can anyone help please?

Is this your exact code? Cause your scale doesn’t change?

For a nifty effect, why don’t you assign the scale to sign curve. That way it’s groth pulses instead of just doing a 180.

[This message has been edited by poo (edited 09-17-2003).]

Hi !

You cannot put the glScale call in the timer function, you should only update a variable to keep track of the current scale and call glutPostReDisplay(), in your display callback function you should put the glScale before you render the object and then it will work fine.

Mikael

All,
Thanks… i have solve the problem. Thank you all for your advise and help.

Really appreciate it.