Live data from Hacker News

Dear ImGui – Bloat-free graphical user interface library for C++

github.com

151–160 of 186 posts

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#151

Earlier quoted context omitted.

There are a lot of hidden traps when rendering anything on modern operating systems that add small latencies and those small latencies add up quickly (it was much easier on old 8- and 16-bit computers). For instance rendering something that "sticks" to the system mouse pointer and doesn't lag a few pixels behind when moving the mouse is surprisingly hard if you're rendering through a 3D API (compared to going through…

I think if it as Casey Muratori's "brain fart" that made sense in his context but that other developers have latched on to because of his influence in indie game circles. I have massive respect for him, and followed everything he did back in the late '90s and early aughts, but he's quite opinionated and has some peculiar code aesthetics / trade-offs.

    I think if it as Casey Muratori's "brain fart" that made sense in his context [...]
    I have massive respect for him, [...]
Sure doesn't sound like it. You're so dismissive of others' ideas that I don't even feel like you're looking for a constructive discussion.

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#152
post #61

Earlier quoted context omitted.

Well, maybe. We use it user-facing for suite of niche vr/tele-op applications and it works wonderfully. We have support for Korean, Japanese, Hebrew (serious issues with right-to-left in our implementation though). The thing about ImGui is it puts devs on steroids - adding gui is just sooo fast. And fun. And easy to tweak. And easy to debug. 10X, maybe? I get that for a game maybe the user facing gui is less of an is…

i am so curious about your use of colon to pluralize initialisms (which i've always found awkward to pluralize, especially in lower case). is that cultural? an intentional choice?

Profile mentions .se. Swedish keyboard layout, meant to press apostrophe, still had shift held from writing R, then by accident pressed key to right of apostrophe to obtain colon?

On further thought this works similarly for US layout.

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#153

Earlier quoted context omitted.

If you really want to go barebones, just mmap /dev/fb0 and do a memset 0 on the region of screen that you want black. Key/pointer events are a matter of reading files from /dev/input.

Ha! But I want to open a window , if possible portably between linux and windows (just like glut was). It seems to me that we are adding a lot of complexity and going backwards feature-wise.

GLUT (in the form of freeglut [1]) still exists (last commit is from February) and works on all major (desktop) operating systems. GLFW [2] is however much more wildly used these days and pretty much the spiritual successor of GLUT. ImGUI can run on top off all of them and doesn't provide the features (window/context creation, event handling) they do.

[1] http://freeglut.sourceforge.net/ [2] https://www.glfw.org/

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#154
post #153

Earlier quoted context omitted.

Ha! But I want to open a window , if possible portably between linux and windows (just like glut was). It seems to me that we are adding a lot of complexity and going backwards feature-wise.

GLUT (in the form of freeglut [1]) still exists (last commit is from February) and works on all major (desktop) operating systems. GLFW [2] is however much more wildly used these days and pretty much the spiritual successor of GLUT. ImGUI can run on top off all of them and doesn't provide the features (window/context creation, event handling) they do. [1] http://freeglut.sourceforge.net/ [2] https://www.glfw.org/

I still use freeglut and am mostly happy with it. Yet, I'm often mocked by my colleagues for that reason. I tried GLFW but I don't see the point of this library whose main raison d'être seems to be "not be freeglut" while having nearly identical features. Besides, the fact that it works with keycodes and not with letters is a bit annoying. The X server sends the key symbols but GLFW choses to ignore them, forcing the user to find them according to the current, difficult to find, keyboard configuration.

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#155
post #75

Earlier quoted context omitted.

> Wouldn't it be possible to separate the public API from the internal implementation so much that the library appears "immediate mode" on the outside, but is completely "retained mode" on the inside? It is possible but you would need some severe API changes... you could either ask the users to use unique names for each widget, or something similar like storing references between frames. Alternatively you'd have to f…

Dear ImGui already uses such "implicit" widget ids, by default it hashes the widget's label string, window title or name, with a convention to add an invisible 'identifier string' to the label string separated by a "##" (e.g. "Label##id") - for the case that the visible label string needs to change or isn't unique within the current scope. There are also separate PushID/PopID functions to manage such widget ids in "m…

This also has been one of my biggest gripes with "imgui" style of libraries - as the end of the day something needs to keep state somewhere, and implementations/hack can be very language/runtime oriented to avoid hacks like above, or use the hack above.

It also caught me by surprise, and would catch many others where seemingly normal controls, that just happen to have the same text would be identified with the same state, as the text (contents) are initially used to point to this state.

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#156
post #62

Earlier quoted context omitted.

You will always get page tearing with ImGui (this library and any others). There are mitigations and workarounds but the issue is fundamental to the paradigm. Consider this trivial counterexample: int counter = 0; label("count: %d\n", counter); if(button("increase")) { counter += 1; } label("count: %d\n", counter); This is, of course, a silly little example but the same issue will arise in many practical use cases an…

That looks more like coupling the state with the UI. You could try refactoring your code in an MVC/MVVM style like react such that the state isn't being modified during a UI draw. That sort of out-of-sync issue can happen even with retained mode UIs. I wouldn't say it's fundamental to the paradigm that you intersperse your business logic into your UI. Granted at large scales basically any UI framework falls apart.

That's how normally you write "imgui" style of app - that's the whole idea - you on purposes couple state+behavior+ui in one piece - e.g. if(checkEvent()) drawSomething(); else drawSomethingElse();

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#157

This is neat, but the problem I always had in these type of libraries is that they only work enough for the examples to be usable. As soon as I wanted to do something that was not in examples, that would either won't work at all or needed a horrible hack to work. I can't give a real example from the top of my head, but I am thinking like the examples would not show how to do a modal popup window and then you learn wh…

I agree. They work fine for simplistic interfaces with a few buttons, but what about more complex widgets, like plain/rich/code text editors, that have a lot of different callbacks and fire many different asynchronous events? Sure, a button function that returns a boolean can be used as a simple parameter to an if statement, but you would would need a switch statement to test for all the different events that a text…

You ask a lot of questions, but none of them are sincere.. Especially since you finish it off with a dogmatic "Use them!". How about keeping an open mind, asking real questions, and give others the chance to prove you wrong (which would be beneficial to you if they succeed)?

IMO you're so stuck in the OOP mindset, that you cannot see the very simple solutions to your questions. To just pick a single example out of the many, since you don't seem to want to be proven wrong anyway..

Where do you store and how do you access all the hidden state, like keyboard focus, cursor position, editing modes, etc, that object oriented user interfaces simply expose as properties, getters or setters?

In OOP each single widget would store whether it is focused using some boolean member. In IM GUIs one just stores the ID of the widget that is focused once in some library-local data structure:

    // ui.h
    bool has_keyboard_focus(uint64_t widget_id);


    // ui.cpp
    struct UIData {
        uint64_t focused_widget_id;
        int16_t cursor_x, cursor_y;
    } ui_data;

    bool has_keyboard_focus(uint64_t widget_id) { return ui_data.focused_widget_id == widget_id; }

    // my_widget.h
    EditMode my_widget_get_edit_mode(uint64_t widget_id);

    // my_widget.cpp
    map widget_id_to_edit_mode;
    option my_widget_get_edit_mode(uint64_t widget_id) {
        auto itr = widget_id_to_edit_mode.find(widget_id);
        return itr != widget_id_to_edit_mode.end() ? itr->second : std::nullopt;
    }

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#158
post #62

Earlier quoted context omitted.

You will always get page tearing with ImGui (this library and any others). There are mitigations and workarounds but the issue is fundamental to the paradigm. Consider this trivial counterexample: int counter = 0; label("count: %d\n", counter); if(button("increase")) { counter += 1; } label("count: %d\n", counter); This is, of course, a silly little example but the same issue will arise in many practical use cases an…

Two label that should have the same value are normally one too many, but if they are needed it is often possible to order them properly... //initialization int counter=0; //each frame label("count: %d\n", counter); label("count again, in case you missed the other label: %d\n", counter); if(button("increase")) { counter += 1; } or, if the order of widgets is constrained, to buffer values: //initialization int counter_…

So this is complexity you normally don't need with other UI approaches. And now would become a "pattern" that needs to be followed.

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#159
post #39

As much as I like Dear ImGui, the immediate mode paradigm doesn't work everywhere. The problem of "page tearing" (not to be confused with vsync) means you either need to render frames continuously, or at least 2 frames for every time you get input or need to implement some kind of "retained mode state tracking" on top of Imgui. It's good for games, but for applications where you're not rendering new frames constantly…

> As much as I like Dear ImGui, the immediate mode paradigm doesn't work everywhere. The problem of "page tearing" (not to be confused with vsync) means you either need to render frames continuously, or at least 2 frames for every time you get input or need to implement some kind of "retained mode state tracking" on top of Imgui. It's good for games, but for applications where you're not rendering new frames constant…

It's exactly these cases, where I'm not really comfortable moving away to imgui, say from Qt (not that I like it a lot), but there has been pressure at work to do so...

Re: Dear ImGui – Bloat-free graphical user interface library for C++

#160

Every couple months I browse the screenshot threads https://github.com/ocornut/imgui/issues/3488 Looking at them makes me really happy for some reason.

Agreed. These look fantastic, and has been the driving force for folks around here to want to change to that. I just don't know what to expect once we go that route (certainly intrigued, also occurnut is one of the nicest and most responsive people around). We have large 3d level editor, and there has been talks about us trying imgui with it. Slowly moving it out of Qt maybe? There is lot to like now in imgui - especially now that there is proper docking :)
Post reply on HN