Jump to content

Immediate mode GUI: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
MapleX15 (talk | contribs)
copy edits
m Added punctuation
Line 5: Line 5:
'''Immediate mode GUI''' is a style of [[Graphical user interface|GUI]] implementation that uses the [[Immediate mode (computer graphics)|immediate mode]] pattern of [[Application programming interface|API]] design in [[graphics library|graphics libraries]], in which ''immediate'' means that:
'''Immediate mode GUI''' is a style of [[Graphical user interface|GUI]] implementation that uses the [[Immediate mode (computer graphics)|immediate mode]] pattern of [[Application programming interface|API]] design in [[graphics library|graphics libraries]], in which ''immediate'' means that:
*the [[Client (computing)|client]] directly holds all [[Graphical widget|widget]]s (visual tree/logical tree of widgets) and composes the graphics objects to [[Rendering (computer graphics)|render]] the [[Graphical widget|widget]]s of the complete [[Graphical user interface|GUI]], or
*the [[Client (computing)|client]] directly holds all [[Graphical widget|widget]]s (visual tree/logical tree of widgets) and composes the graphics objects to [[Rendering (computer graphics)|render]] the [[Graphical widget|widget]]s of the complete [[Graphical user interface|GUI]], or
*the [[Client (computing)|client]] directly inserts the [[rendering primitive]]s into a [[command list]] to [[Rendering (computer graphics)|render]] frame-by-frame
*the [[Client (computing)|client]] directly inserts the [[rendering primitive]]s into a [[command list]] to [[Rendering (computer graphics)|render]] frame-by-frame.
without the use of extensive indirection to retained resources and where
Without the use of extensive indirection to retained resources and where:
*the [[Event (computing)|event processing]] is directly controlled and completely implemented by the [[Client (computing)|client]] (in contrast to a ready to use basic event processing by a [[Graphical user interface|GUI]] system/library utilizing pre-defined [[Event (computing)|event]]s/[[Callback (computer programming)|callback]]s or signals/slots), and
*the [[Event (computing)|event processing]] is directly controlled and completely implemented by the [[Client (computing)|client]] (in contrast to a ready to use basic event processing by a [[Graphical user interface|GUI]] system/library utilizing pre-defined [[Event (computing)|event]]s/[[Callback (computer programming)|callback]]s or signals/slots), and
*the lists of graphical objects to be [[Rendering (computer graphics)|render]]ed are kept by the [[Client (computing)|client]] and all drawing commands required to describe the entire [[Graphical user interface|GUI]] must be re-issued to the [[graphics pipeline]] each time a new [[Film frame|frame]] is required.
*the lists of graphical objects to be [[Rendering (computer graphics)|render]]ed are kept by the [[Client (computing)|client]] and all drawing commands required to describe the entire [[Graphical user interface|GUI]] must be re-issued to the [[graphics pipeline]] each time a new [[Film frame|frame]] is required.
Line 27: Line 27:
== Widget toolkit ==
== Widget toolkit ==


Most of the [[Immediate mode (computer graphics)|immediate mode]] GUI [[Widget toolkit|widget toolkit]] implementations are evolutions from [[Video game development|game development]] and particularly suitable when
Most of the [[Immediate mode (computer graphics)|immediate mode]] GUI [[Widget toolkit|widget toolkit]] implementations are evolutions from [[Video game development|game development]] and particularly suitable when:
* a [[Graphical user interface|GUI]] needs to be updated in sync with the game scene or complex graphic,
* a [[Graphical user interface|GUI]] needs to be updated in sync with the game scene or complex graphic,
* a [[Graphical user interface|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),
* a [[Graphical user interface|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),

Revision as of 18:51, 7 July 2020

Schematic explanation of an immediate mode graphics API

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

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. One way 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:

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