← Back to context

Comment by SigmundA

3 days ago

Is Win16 / Win32 GDI which goes back to 1985 an immediate mode GUI?

Win32 GUI common controls are a pretty thin layer over GDI and you can always take over WM_PAINT and do whatever you like.

If you make your own control you musts handle WM_PAINT which seems pretty immediate to me.

https://learn.microsoft.com/en-us/windows/win32/learnwin32/y...

Difference between game engine and say GDI is just the window buffer invalidation, WM_PAINT is not called for every frame, only when windows thinks the windows rectangle has changed and needs to be redrawn independently of screen refresh rate.

I guess I think of retained vs immediate in the graphic library / driver because that allows for the GPU to take over more and store the objects in VRAM and redraw them. At the GUI level thats just user space abstractions over the rendering engine, but the line is blurry.

No, that is event based programming, and also the basis of retained rendering, because you already have the controls that you compose, or subclass.

Handling WM_PAINT is no different from something like OnPaint() on a base class.

This was actually one of mindset shifts when moving from MS-DOS into Windows graphics programming.

  • Event based or loop based is separate from retained or immediate.

    The canvas api in the browser is immediate mode driven by events such as requestAnimationFrame

    If you do not draw in WM_PAINT it will not redraw any state on its own within your control.

    GDI is most certainly an immediate mode API and if you have been around long enough for DOS you would remember how to use WM_PAINT to write a game loop renderer before Direct2D in windows. Remember BitBlt for off screen rendering with GDI in WM_PAINT?

    https://learn.microsoft.com/en-us/windows/win32/direct2d/com...

    • I even remember WinG, Win32s and co.

      You are forgeting most folks did not use bare bones C with WM_PAINT and nothing else.

      Most sane devs were quick to adopt C++, even Petzold books moved into C++ still during Windows 3.1 days, although the code samples stayed pretty much the C subset common to both languages, see the preface on his book.

      As such many games had their own retained frameworks built on top of Win32 controls, wrapped into C++ classes, or if they were casual games, they would build upon OWL, VCL (Borland TP, C++, Delphi), MFC (VC++), VB.

      The kind of games where you would get a bootload of shovelware CDs when buying a Media PC with MS-DOS/Windows 3.1.

      1 reply →