This mostly comes under the category of "Well don't do that, then!" but
here goes anyway...

Imagine that I have some fltk GL code, partly written using glut, and
for various reasons I have a couple of idle functions trundling away in
the background.

Now, glut only really supports 1 idle function, so I've used
Fl::add_idle() to attach my various background functions.

So far, all well and good.

Now... Elsewhere in the (legacy) code, which is more or less regular
glut code, there's a "visible()" function, called by
glutVisibilityFunc().

Now, the visible() func, when run, checks to see if its window is
visible or not, then calls glutIdleFunc(...) depending on the result.
Pretty standard stuff... 
In particular, if the window is not visible, then it will call 

  glutIdleFunc(NULL);

Which maps to the fltk call Fl::set_idle(NULL);

Hmmm, this has the effect of hosing *all* the fltk idle functions in one
fell swoop if the window is minimised, on a fairly permanent basis -
subsequent calls to Fl::add_idle() will not work either...

So, the correct thing for me to do is replace all the calls to
glutIdleFunc(); with calls to either Fl::add_idle() or Fl::remove_idle()
- whichever is appropriate based on the current visibility state. Ok,
that works...

So, I have a couple of observations about this:

1. Others porting glut code to fltk might trip over the same problem, or
a variant of it (for example, if you replace the glutIdleFunc(my_idle);
call in your initialisation with a call to Fl::add_idle(my_idle);  but
forget to fix the one in visible();)

2. Fl::set_idle() is marked as deprecated, so we perhaps should not be
using it internally.

3. I can't see how to make glutIdleFunc() work more like
add/remove_timeout, so I don't think we can really fix this...

I guess I just have to be careful not to mix'n'match my idle function
coding styles!
-- 
Ian





SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to