[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Of time scaling and FPS

"Miguel A. Osorio" wrote:

>         Err, just one small caveat here: the "gettime" thing was just sort of
> an alias for an abstract "time fetching" routine. In my case, I'm using
> SDL's SDL_GetTicks function, which returns milliseconds in a portable
> way. BTW, are milliseconds precise enough?

No - not by a large measure.  At 60Hz, a frame lasts 16.67 milliseconds
so an error of one millisecond will cause your velocities to jitter
up and down by 8% or so - that's bad enough - but if your accellerations
are also jittering by that much, you'll be in deep trouble.

Use gettimeofday - it's good to *microseconds*.

>         Oh, and since you guys didn't actually say anything about the process
> of calculating the time delta, I suppose it's acceptable?

Well, I immediately convert gettimeofday into a double (don't use a float -
it's not precise enough when the numbers get large).  Then you can store
everything in nice units like 'seconds'.

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net