# Effective Time-Keeper

Hi dudes,
I am trying to create a simulation program, in that i need an effective time keeping using the glutTimerFunc for a 30fps.

can i call this timer function from my RenderScene function?

if possible try to explain me how it works? i mean for 30fps it take 33millisec to wait n return to the timerfunction to execute.

the objective of my program is to create a driving simulation with rain effect. here droplet is fed into the windowpane and it begin to flow down. i wrote the code for everything but the timer not function properly.

if any clever head like 2 gimme some idea?

thanx
regards

You should get time in miliseconds and compare (time==n*(1/33))?proceed:sleep; But I’m working with MSVC++ 6.0 and I havn’t found way how to get time in miliseconds & get sleep to work, it seems that computer simply hangs If you’ll find out about those functions, please let me know.

thanx dude… will let u know, if it works fine.

If guys ready to gimme suggestion regarding the timer function, pls do it so…

thanx.

I think that I’ve found solution -> www.gametutorials.com There was somthing about time based movement, unfortunately it uses additional lib.
Is there realy no way to record milisecond in MSVC. like time.ti_hund in Borland Builder (HATE THAT THNG)

GLFW - sub microsecond resolution. Check the source for how it’s done (lib/win32/time.c).

Almost all example programs that are included use time-based movement, and some (which use differential equations to propagate movement) also have special handling for low frame rates (which can lead to unstable simulations).

It’s quite simple, basically:

``````#define MAX_DELTA_T 1.0e-3   // Maximum propagation = 1 ms

double t, t_old, dt_total, dt;

t = glfwGetTime();
dt_total = t - t_old;
t_old = t;
while( dt_total > 0.0 )
{
dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;
dt_total -= dt;
}
``````