Hi,
I have a problem regarding the glutTimerFunc().
I have two different object a sphere and a cube. All I want is to animate those two objects in different scale.
I am moving Sphere from top-left of the screen to bottom-right of the screen and spinning it’s coordinates too. Now there is another object that is cube which only spins on the center of the coordinate in the origin of the window.
I want to spin that cube at an interval of 500ms., and move the sphere every 1 sec for 4 times from top to bottom and bottom to top.
My question is: How do i implement this with two glutTimerFunc()? I am using glutTimerFunc(500, SpinCube, 1) and glutTimerFunc(250, MoveSphere, 1). Is it valid to use to different Timer Function? If not how to implement it?
More over I want to generate 2 random number of the coordinates to display another sphere at a random location with every 2000ms. I am calling this function too and i guess i need another timer function to generate random number and displaying the sphere.
My code is something like:
void main(void)
{
…
…
glutTimerFunc(10, SpinCube, 1);
glutTimerFunc(10, MoveSphere, 1);
glutTimerFunc(10, RandomSphere, 1);
…
…
…
}
SpinCube(int value)
{
…Manipulation
…
…
glutPostRedisplay();
glutTimerFunc(500, SpinCube, 1);
}
MoveSphere(int value)
{
…Manipulation
…
…
glutPostRedisplay();
glutTimerFunc(250, MoveSphere, 1);
}
RandomSphere(int value)
{
…Manipulation
…
…
glutPostRedisplay();
glutTimerFunc(2000, RandomSphere, 1);
}
void Display(void)
{
…
…
glutSwapBuffers();
}
So how to call each and every timer in different point of time? more over what is the value of the 3 argument in glutTimerFunc() implies?
Please help me out, I am doing a small project and I need to implement that.
thanx
regards