Multiple timer funcs

Can i have multiple timer funcs.

Here is the problem, my main window i have set the timer to 200ms and it works ok, i.e. animates slowly but when using the camera it also waits 200ms between each rotation and zoom.

I’d like to have a way to set the camera timer so it is instant but keep the animation slow.

Any ideas???

If I understand correctly you are updating your display 5 times per second. That is not the corect way to do an animation. You should update the display as fast as you can, and use the time difference to update the movement of your objects.

Here is an example: suppose you display a rotating cube and you want the cube to rotate 90/sec.

try something like this:

#include <windows.h>

LARGE_INTEGER startTime;

static bool first = true;
if (first)
{

QueryPerformanceCounter(&startTime);
first = false;

}

LARGE_INTEGER currentTime;
LARGE_INTEGER frequency;

QueryPerformanceFrequency(&frequency);

QueryPerformanceCounter(&currentTime);

double time = (double)(currentTime.QuadPart - startTime.QuadPart) / (double)frequency.QuadPart;

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//this rotates the cube with 90 degrees every second
glRotatef(time * 90. , 0., 1., 0.);

draw the cube

That is basically it. This way you can update the display 10000 times per second and still have the cube rotate with only 90 degrees per second. You should adapt this code to your situation, of course…

I hope this helps.

ok, so let me try and understand what you are saying, i should set my animation to not be based on the timerfunc but on actual time, so if i want the object to grow, as that is what it does, to grow every second i should compare the times of now and before and then update the object???

is that roughtly what you are saying???

since you want your object to grow you’re performing a scale.

let’s say, for example, that you want your cube to double in size every second.

here’s what you would want to do:

render as fast as possible but before each render get a tick count since the first render.

tickcount = CurrentTickcount-firstTickCount;

use the passing time to come up with an interpolated value of how much the object scaled.

ex: 250ms since first render = .25sec.
glScalef(1.0+.25,1.0+.25,1.0+.25);