logoalt Hacker News

badsectoraculayesterday at 5:50 PM1 replyview on HN

> The difference is that for most games, throwing away the complete rendered graphics and re-rendering from the world model is often the right approach.

Well, that is what "retained mode" GUIs (i.e. those using control/widget trees and such) do too.

The immediate mode GUI to me always felt like an approach came up by people who do not really want to bother doing GUIs. In terms of games it is like mixing logic and presentation in a game like, e.g.

    int x, y;
    while (game_running) {
        draw_sprite(player, x, y);
        if (key_down(LEFT)) x -= 1;
        // etc
    }
basically like in a game that doesn't have a world model with entities etc, just draws sprites directly, handles input directly, etc. Which is very simple for simple stuff but doesn't scale as complexity increases.

Same with immediate mode GUIs and i don't think it is a coincidence that the more complex an imgui gets, the more it starts looking like a "retained mode" GUI and the gnarlier the code becomes.


Replies

mpweihertoday at 7:14 AM

> Well, [throwing away the complete rendered graphics] is what "retained mode" GUIs (i.e. those using control/widget trees and such) do too.

That turns out not to be the case.

The widget tree is retained.

When changes come in, the resulting damage from those changes is assessed and then the damaged parts are redrawn in an optimized fashion.

https://developer.apple.com/documentation/AppKit/NSView/draw...