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

Re: Of time scaling and FPS



Dmitry Samoyloff wrote:
> 
> 9 May 2002 18:23, Miguel A. Osorio wrote:
> > Katie Lauren Lucas wrote:
> > > Quoting "Miguel A. Osorio" <maos@gbl.com.br>:
> > > >       Anyway, on to the FPS problem. Using the method
> > > > described above, I use
> > > > delta to scale my time-dependent variables, in order to
> > > > get some smooth
> > > > animation. Thing is, I don't. The whole animation looks
> > > > all jagged up, without using time scaling it goes on fine;
> > > > do note that, however, I don't know why, the FPS mark
> > > > keeps jumping about *all the time*, it never settles on
> > > > some average. Does anyone know a reason for this? Or am
> > > > I doing the whole time scaling calculation the wrong way?
> > >
> > > Yes. Gettime(2) returns the current time in SECONDS. You'd
> > > be wanting to retrieve it by calling gettimeofday(2) which
> > > fills in a structure which contains seconds and microseconds
> > > since 00:00 Jan 1 1970.
> >
> >       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?
> 
> AFAIK milliseconds is a maximum precision for a portable apps.

I don't know of a machine that doesn't have microsecond precision
timers *somewhere* - but you may need to write a handy wrapper
function to use whatever mechanism works best for a given OS.

For Linux, gettimeofday is by far the best mechanism.

----------------------------- 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