Immediate Mode GUI

from Wikipedia, the free encyclopedia
Schematic explanation of the Immediate mode of a graphics API

Immediate Mode GUI (literally translated: Immediate Mode GUI ) is a type of implementation of graphical user interfaces (GUIs) that uses the Immediate Mode design pattern for the design of the programming interface (API) in graphics libraries - where immediate means that

without using - i.e. immediately - extensive redirects to stored resources and where

  • the event processing is controlled directly by the client and implemented entirely by the client (as opposed to ready-to-use basic event processing by a GUI system / library using predefined events / callback functions or signals / slots) and
  • the lists of the graphic objects to be rendered are managed by the client and all drawing commands that are required to describe the entire GUI have to be passed to the graphics pipeline again every time a new image is required.
Schematic explanation of the mode with saved resources of a graphics API in difference

This implies that the client code in an immediate mode GUI manages its own graphical primitives and this API design also influences the implementation of the graphics pipeline.

There is another significant design pattern of the programming interface in graphics libraries - retained mode . In retained mode, the graphic primitives are managed by the GUI system / GUI library, often hidden from the client code.

GUI toolkit

Most GUI toolkits for Immediate Mode are further developments from the video game development and particularly suitable when

  • a GUI needs to be updated synchronously with the game scene or a complex graphic,
  • a GUI has to be superimposed on a game scene or a complex graphic (which is particularly simple in both cases if both the GUI and the game scene are controlled by the game loop), or
  • a GUI should have an unusual appearance or be pepped up with complex graphics.

Typical of a GUI toolkit for Immediate Mode is that it

  • more straightforward in the sense that the tree of controls (widgets) is often a tree of function calls that is wonderfully composable and flexible - but difficult to interact with,
  • is less complexly structured and easier to understand (in the sense of fewer implicit assumptions per GUI toolkit API call) - but this usually also leads to less functionality,
  • for more than a simple tree of controls including layout (absolute and / or relative positioning in relation to parents or siblings) is more complex to create and manage (typically requires more GUI toolkit API calls),
  • has less sophisticated hidden object removal ( Z-buffering ), hit checking , handling of state changes, scrolling and animation for the focus / active control - this also implies the need to maintain a logical / visual tree of controls yourself,
  • has to completely rebuild the vertex buffer for each new image , and consequently
  • creates a constant workload for the processor (CPU).

Therefore, immediate mode GUI toolkits are a great choice for anyone who wants a simple but easily modifiable and extensible GUI toolkit. They are typically generic, open source, and cross-platform. One way to have the flexibility and combinability of an immediate mode GUI without the disadvantages of managing the control tree only in function calls with the lack of direct control over how the graphical user interface is drawn in the render engine would be to use a virtual control Tree - just like React uses a virtual DOM .

Implementations

The original Immediate Mode GUI Toolkit is imgui by Adrien Herubel, which is based on OpenGL . The idea was spread by Casey Muratori. There are other toolkits such as

See also

Individual evidence

  1. Quinn Radich: Retained Mode Versus Immediate Mode . In: Win32 apps . Microsoft. May 30, 2018. Retrieved December 21, 2019.
  2. Adrien Herubel: AdrienHerubel / imgui: A small multiplatform immediate mode graphical user interface with OpenGL3.2 backend . 18th December 2019.
  3. Micha Mettke: vurtun / nuclear: A single-header ANSI C gui library . 22nd December 2019.
  4. Tarvo Korrovits: actsl / kiss_sdl: Simple generic GUI widget toolkit for SDL2 . 19th December 2019.
  5. Gio - immediate mode GUI in Go . Retrieved November 14, 2019.
  6. Omar Cornut: ocornut / imgui: Dear ImGui: Bloat-free Immediate Mode Graphical User interface for C ++ with minimal dependencies . 22nd December 2019.
  7. kotlin-graphics: kotlin-graphics / imgui: Bloat-free Immediate Mode Graphical User interface for JVM with minimal dependencies (rewrite of dear imgui) . 19th December 2019.