FLTK logo

Re: [fltk.general] Best way to update the FLTK window in real-time ?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Best way to update the FLTK window in real-time ? Albrecht Schlosser Jan 08, 2014  
 
On 08.01.2014 02:11, Furqan Ullah wrote:
Thanks Arthur,

I just wonder that, why everything is working fine then with all of the
above three variants?
I even created two threads, and updating 6 fltk windows in a MainWindow.
I didn't even had one time crash not even any delay in updating.
Updating is fast and nice.

I fully agree with Ian that your functions were the wrong way. Fl::awake() is the correct way to do it. However, this is really platform-dependent, so you can get seemingly correct results on one platform, whereas the program crashes or doesn't work as expected on other platform.

On which platform (OS + version) did it work for you ?

If this is not a proper way, then I think there should be a restriction
in FLTK to use Fl::flush inside of a child thread.

How would FLTK know that Fl::flush() was called inside a child thread?

Anyways, I have changed my code, and now updating the child window using
Fl::awake(). Its working perfectly fine.

That's good.

Still any suggestion please?

Yes. It depends on what your "real-time" expectations and data feed properties are like. Whenever you call Fl::awake() from a child thread, you will ask (force) FLTK to draw the entire window. This can be very time-consuming and cost much cpu time. The more frequently you do it, the more cpu time will be used for drawing the window.

If your data feed is fast (let's say more than ~20 data sets per second), then that's wasted time, since an observer can't recognize more than about that data rate. In this case it would be better to store the data somewhere in memory and update the display (window) by a timer in a fix data rate of about 20fps. Use Fl::add_timeout() with a delay of 0.05 (seconds) and call redraw() in the timeout callback.

However, if your data feed is slow (less than 20 fps) then it may be better to go for an immediate redraw with Fl::awake() whenever new data arrives. This will have the smalles delay possible at the cost that it will consume more cpu time when a data burst happens.

YMMV. There have been long discussions about a very similar problem in the thread "How to do realtime data display in FLTK" in May/June 2013 or so.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.