Difference between Fl_Window and Fl_Double_Window.

25 views
Skip to first unread message

Jefferson Costa

unread,
May 31, 2023, 7:54:31 PM5/31/23
to FLTK
Hi all ! :)

I'm studying all the codes I can taste 😋 and I noticed many codes have Fl_Window or Fl_Double_Window. Why the difference ? Whenshould I use one or other ?

Regards,
Jeffah

Gonzalo Garramuño

unread,
May 31, 2023, 8:14:12 PM5/31/23
to fltkg...@googlegroups.com

El 31/5/23 a las 20:46, Jefferson Costa escribió:
Hi!

Fl_Double_Window uses double buffering on platforms that allow it. 
Fl_Window doesn't.  However, some OSes like macOS will always use double
buffering regardless.  Double buffering uses more memory in principle,
but these days, it does not matter that much anymore.

So, to make things easier and consistent across platforms, you should
use Fl_Double_Window's for all code.

--
Gonzalo Garramuño
ggar...@gmail.com

Greg Ercolano

unread,
May 31, 2023, 8:45:37 PM5/31/23
to fltkg...@googlegroups.com

On 5/31/23 16:46, Jefferson Costa wrote:

Hi all ! :)

I'm studying all the codes I can taste 😋 and I noticed many codes have Fl_Window
or Fl_Double_Window. Why the difference ? When should I use one or other ?

    Before I describe the difference, lemme just say:
    these days it's best to just always use Fl_Double_Window.
   
It provides flicker free double buffering which is almost always
    what you want, and pretty much standard on all graphics hardware.
    (See that link for a description of what double buffering is)

    Fl_Double_Window creates a window that uses double buffering for all
    drawing inside it, whereas an Fl_Window only uses single buffer drawing.

    Double buffering uses a bit more resources -- two screen memory buffers
    instead of just one.

    Back in the mid-1990s when FLTK was first developed, memory of any kind
    was expensive, and not all computer's graphics cards provided double
    buffering. So if you wanted a simple program to work on machines that
    didn't provide double buffering, you'd use Fl_Window.

    But these days double buffering is so common and screen memory is
    so cheap, double buffering is pretty much standard now, and has been
    so since the early 2000's.

    Single buffering is sort of like a white board; your audience sees
    the board as you draw on it.

    Double buffering is like a two sided white board, where you can show
    a completed drawing to your audience, while your assistant is at the back,
    making a new drawing the audience can't see while he draws it.

    When the assitant's drawing is done, the white board can be quickly
    flipped over to show the new drawing. The audience never sees the
    slow drawing process. The assitant, still at the back, now sees the old
    image and can erase it and replace it while the audience is looking at
    the new image.

Bill Spitzak

unread,
May 31, 2023, 8:49:18 PM5/31/23
to fltkg...@googlegroups.com
In addition in many systems, like Wayland, all windows are double buffered anyway. In fact some care should be taken so that FL_Double_Window works the same as FL_Window on these platforms, and does not produce an unnecessary third buffer.


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/54fabd57-0d2f-2acd-9061-17a9cc52aabc%40seriss.com.

Jefferson Costa

unread,
May 31, 2023, 11:02:28 PM5/31/23
to FLTK
Reply all
Reply to author
Forward
0 new messages