Re: [gtkmm] Re: How to do call a function once every 'frame'? And some documentation feedback.



On Sat, 2002-11-09 at 17:20, Dirk Gerrits wrote:

> But if I understand correctly, with Glib::signal_timeout() the whole 
> DoFrame function becomes unnecessary:
> 
> Glib::signal_timeout().connect(SigC::slot(&DoComputation), ms_per_tick);
> 
> That's just plain cool! :) Thanks.
> 
> Dirk

Hello Dirk,
unfortunately that is not the case! Gtkmm (and most non-Hard-RT
operating systems) only guarantee that the time interval is *at least*
as much as what you specified, never less (e.g. your slot will never be
called earlier, but possibly later).

That means that you will need to both calculate how much time has passed
since the last call and to calculate the remaining time after your
computation has finished[1].

HTH,
Tassos
[1] consider: your computation takes 10 ms, and then you wait for
    another 20: sum total 33 ms or 30 frames per second, much less than
    20ms or 50 frames per second.

-- 
Tassos Bassoukos

UNIX does not prevent you from doing stupid things because
that would also prevent you from doing clever things
gs

Attachment: signature.asc
Description: This is a digitally signed message part



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