Immediate mode GUI

Immediate mode GUI is a style of GUI implementation, that is using the immediate mode pattern of API design in graphics libraries, in which immediate means that

  • the client directly holds all widgets (visual tree/logical tree of widgets) and composes the graphics objects to render the widgets of the complete GUI, or
  • the client directly inserts the rendering primitives into a command list to render frame by frame
Schematic explanation of an immediate mode graphics API

without the use of extensive indirection to retained resources and where

  • the event processing is directly controlled and completely implemented by the client (in contrast to a ready to use basic event processing by a GUI system/library utilizing pre-defined events/callbacks or signals/slots), and
  • the lists of graphical objects to be rendered are kept by the client and all drawing commands required to describe the entire GUI must be re-issued to the graphics pipeline each time a new frame is required.
Schematic explanation of a retained mode graphics API in contrast

This implies that in an immediate mode GUI, the client code is holding on its own rendering primitives and the API design also affects graphics pipeline implementation.

There is another major pattern of API design in graphics libraries - the retained mode.[1] In the retained mode, the rendering primitives are managed by the GUI system/library, often hidden from the client code.

Widget toolkit

Most of the immediate mode GUI widget toolkit implementations are evolutions from game development and particularly suitable when

  • a GUI needs to be updated in sync with the game scene or complex graphic,
  • a GUI needs to be overlaid on an game scene or complex graphic (which is especially easy in both cases when both GUI and game scene are controlled by the game loop),
  • or a GUI should have an unusual appearance or be pepped with complex graphic.

Typically a immediate mode GUI widget toolkit

  • is more direct in the sense that the widget tree is often a function call tree, that is wonderful composable and flexible but hard to interact with,
  • is less complex structured and easier to understand (in terms of fewer implicit assumption per toolset API call) - this usually also results in less functionality,
  • is more elaborate (needs typically more toolset API calls) to create and manage if more than a simple widget tree including layout (absolute and relative positioning referring to parent or siblings),
  • has less sophisticated occlusion culling (Z-buffering), hit-testing, state change handling, scrolling and focus/hot control (widget) animations - this also implies the need to manage logical tree/visual tree itself,
  • has to rebuild the vertex buffers completely from scratch for each new frame, and thus
  • puts constantly work load on the CPU.

Therefore immediate mode GUI widget toolkits are a good choice for all those who want a simple but easily changeable and extendable GUI toolkit. They are usually generic, open source and cross-platform. A possibility to have the flexibility and composability of an immediate mode GUI without the disadvantages of keeping the widget tree only in function calls with the lack of direct control how the GUI is drawn in the rendering engine would be to use an virtual widget tree - just like React uses a virtual DOM.

The original Immediate Mode GUI toolkit was imgui by Adrien Herubel[2] which is based on OpenGL. The idea was popularized by Casey Muratori. There are others such as

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.