Re: Timing
- Posted by Jiri Babor <J.Babor at GNS.CRI.NZ> Jan 11, 1999
- 524 views
My previous note on the subject was totally negative. Since today is just another pleasant ripper of a day in a long succession of beautiful summer days down here at the arse end of the world (sorry, not my words - a former Australian prime minister is credited with the expression), I suppose I can also afford to be a little bit more positive. First of all I'll show you what I usually do (warning: this is unlikely to benefit anybody who is not at least as stupid as I am): constant dt=0.04 -- desired time interval per frame (25 fps) atom t1,t2 tick_rate(100) while 1 do -- frame loop t1=time() ...code to generate a frame... t2=time() while t2-t1 < dt do t2=time() end while -- waste time end while -- end of frame loop Which is admittedly not terribly bright... The code below is how I *now* think it should be done: t1=time() while 1 do t2=t1+dt ...code to generate a frame... t1=time() while t1<t2 do t1=time() end while end while The whole point of it is, that only *one* time() call is made when the things are tight... jiri