Am 29.05.2009 23:08 Uhr schrieb "Loic" unter <[email protected]>:

> Ouch...
> Is there anyway to use a function in a while instead of Fl::run();
> For my application it will be more suited, because I have to make other
> computation, absolutely not related to FLTK.  And I don't want to make this
> computation periodically but all the time.  And only refresh FLTK from time to
> time and when needed.

Yes, you can do 

For(;;) {
  Fl::wait(0.0); // not Fl::check()!
  do_stuff();
}

But that has a bunch of issues.

You can also do Fl::add_idle() which calls you other calculation every time
when there is nothing else to do for FLTK. This will eat up 100% of your CPU
though! 

Without know what exacty you calculate, creating an entirely seperte thread
for your calculations seems to be the way to go.

>> If your intention is a continuous redraw (animation, for example), you
>> should still use Fl::run() and prepend a call to Fl::add_timeout(). In the
>> timout, you call redraw(), and Fl::repeat_timeout()
> 
> But the redraw() should be called only to the main window, right?

No, redraw() can be called anywhere and any time fro any widget (assuming
the widget exists, of course). It can be called quite often without much
impact on performance. You can even call redraw() from another thread. All
it does is tell FLTK to refresh the widget as soon as it hits the next
Fl::run() or Fl::flush(). 


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to