3 ms·
That’s pretty awesome. Admittedly, all I know about immediate mode and retained modes GUIs, I learned from this post, but I wonder why there’s no library that
by Hnrobert42 6y ago
That’s pretty awesome.
Admittedly, all I know about immediate mode and retained modes GUIs, I learned from this post, but I wonder why there’s no library that uses both. Could a library:
1. Use immediate mode to calculate the display.
2. Use retained mode as long as the amount of change is below a certain threshold.
3. Switch to immediate mode above the threshold.
And so on.
- LASR 6y agoThe difference is in the programming model. The library itself is probably quite easy to support both models. If you have some UI in retained mode, chances are that rendering it live every frame will lead to unacceptable performance. But if you have UI in immediate mode, you can probably switch to retained - essentially lazy rendering until something else happens. But you'll have to be very careful that your render calls are indeed pure functions, and cannot produce different outputs unless some input has indeed changed.
- anderspitman 6y agoIn practice they do tend to be mixed, if not in exactly the way you describe. Immediate mode systems often retain/cache a lot of state under the hood for performance reasons, and determine exactly what needs to be redrawn on each iteration. Virtual doms (React, Vue, etc) are a great example of this.
- c-smile 6y ago> but I wonder why there’s no library that uses both Sciter (https://sciter.com https://sciter.com) uses both, as internally as on user's level. For example you may want to define this: var bodyElement = document.body; bodyElement.paintForeground = function(graphics) { ... draw something ... on top of <body> content ... using the graphics } This allows to benefit from both: retained mode (HTML DOM, layout cached) and immediate mode rendering - paint handlers on DOM elements.
- megameter 6y agoThey meet in the middle when we talk about layout computation. Layout often flips between needing a globally-optimized solution of some kind(how to pack many boxes given some parameters of box size), and needing a fast, simple dynamic adjustment(same drawing algorithm with different numbers passed in). And what happens is that when the layout gets complex, the simple dynamic adjustment impacts the overall solution. Parts of the layout may also contain their own state, like window positioning. So even in immediate GUI there is retained elements, and vice versa. It's a complex tangle, all in all.