I'm having a hard time to understand what is ImGUI (and what is the opposite RmGUI)... any could help me with ELI5? It sounds like ImGUI is reactive while RmGUI is not?
Games (normally) re-render the whole scene every frame.
ImGUI exposes that to their API users: you have to re-render and check for clicks on every frame. The code looks like React, (but not as optimized, it re-renders every frame!), and normally you have to keep state by yourself. Code example: [1].
Retained Mode is closer to the DOM, Cocoa or WPF: you create objects and there's an abstraction between the API and the renderer: they get re-rendered every frame for you. Componentes normally have events and state by themselves. Sometimes there's a visual editor too.
The main difference is the API. One is lower level than the other. In practice, the APIs aren't that different, except when it comes to event handling.
> Games (normally) re-render the whole scene every frame
They don't re-upload the whole scene to the GPU every frame, they don't recreate objects all the time. Immediate mode was only used in, like, the GL 1.x times.
A retained mode GUI is defined by writing initialization code that sets up a model of the UI elements in memory, attaching data and linking callbacks to interactive elements like buttons. The UI library uses the model in memory to draw the UI and handle user interactions.
An immediate mode GUI is defined by writing an update function that draws the UI, passing in data and conditionally running callbacks for interactive elements like buttons. There is no model saved in memory, rather the structure of the UI is implied through the code path taken by the update function. The UI library uses this function to both draw the UI and handle user interactions.
It comes from 3D gaming and hardware acceleration.
In 3D you use hardware acceleration that is 100-200 times more energy efficient than drawing in the CPU. But you loose flexibility.
It is actually way cheaper to actually clear the screen and redraw it again each 1/60 of a second than to complicate the design of the drawing.
If you make it complex, the GPU could not draw it, because the GPU is not flexible, so only the CPU could draw it.
With GPUs, those tricks do not make sense at all.
In the past, there was a lot of optimization for things like drawing windows on the screen, things like circular buffers, "happy ideas" everywhere that made it efficient in the CPU at the expense of complexity, that the CPU could handle.
Imagine solving a mathematical equation. With matrices we fill a table with zeros that represents the elements of the table that do not exist. This is inefficient, but with a matrix a machine can solve it automatically without "thinking".
Immediate Gui uses the same concept, it draws without caring for last frames or states, making it way simpler.
Yeah I'd appreciate an ELI5 source for this also. The article mostly assumes that you already understand the concept and the linked video is incredibly dry. Some visuals alongside the code would be nice.