Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

What are the design decisions w.r.t. redrawing?

Open mavavilj opened this issue 2 years ago • 2 comments

What are the design decisions w.r.t. redrawing?

There was this earlier question:

https://github.com/Immediate-Mode-UI/Nuklear/issues/118

But I have been wondering about the usability of Nuklear for programs where one might have a lot of editable charts. Then one might e.g. edit one node, and possibly have to redraw the whole chart or even the whole GUI.

Some libraries may implement partial redrawing. I didn't find a mention of this in the Nuklear repo.

mavavilj avatar Mar 31 '22 13:03 mavavilj

Running the Nuklear GUI loop to generate the command queue and compare it to the last command queue has been standard behaviour since Forever. If the command queue is the same, the GPU does not redraw anything. If there is a change in a single nk_window, all nk_windows on the same queue get redrawn.

You are reffering to partial redrawing: if one nk_window changes, can't we skip redrawing all of them? This is unimplemented, as I understand it. Because you can't just update the window in focus, because the background ones may be changing.

Technically, all the ingridients are there. Nuklear produces clip_rect from the command queue, is issuing clipping as part of it's basic drawing anyways, so it seems doable. But when you factor in windows styled to have rounded corners, windows updating in the background, layouts which are created with just one nk_window, thus losing all benefits from a redraw based on nk_window etc. It's quite the rabbit hole, that AFAIK no one has implmeneted.

FrostKiwi avatar Apr 11 '22 05:04 FrostKiwi

Exactly as @FrostKiwi writes. There are certainly some use cases for partial window redrawing but they're mostly not motivated by high CPU usage as that seems not to be the bottleneck even on low-power devices.

But they are usually motivated by slow display technology used. E.g. the link to many small LCDs/OLEDs is just something like low-bandwidth SPI ("low" in the pixel transfer domain). So sending full frames is not viable.

Better foundation for partial window redrawing (read "closer to its implementation") is to be found in https://github.com/Immediate-Mode-UI/layout.c and https://github.com/Immediate-Mode-UI/Quarks .

dumblob avatar Apr 11 '22 08:04 dumblob