170 points · by brenocq · 1y ago · 42 comments
And just like integrating Dear ImGui itself, integrating a component is just dropping a couple of source files into your project.
MyCustomThing::MyWidget( "name", whatever_value );
And it gets the current rectangle from a global context, can allocate some of that rectangle space for itself, draw things, react to events, etc. It's more complicated when the widget needs to store state, but ImGui has pretty well established conventions for how to do that, which basically boils down to hashing the widget name or ID and storing your state there. And when you try, you find you need a lot less state than you might expect. Of course if you have custom data that already has state (e.g. an object passed into your widget), you can use and modify that directly which is great.
It's a very different way of thinking, and it does have some challenges but it usually ends up being a lot simpler and more robust than a "retained mode" gui.
I would be surprised if a typical ImGui app shows up there though (unless your renderer isn't vsync-throttled), on my laptop it's usually Chrome which is at the top of the list.
You can also write ImGui applications so that they only 'wake up' on user input.
> A common misunderstanding is to mistake immediate mode GUI for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the GUI functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely.
No.
https://www.forrestthewoods.com/blog/proving-immediate-mode-...
/opensource/implot3d/implot3d.cpp:2650:20: error: no member named 'sin' in namespace 'std'
2650 | float s = std::sin(half_angle);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2654:14: error: no member named 'cos' in namespace 'std'
2654 | w = std::cos(half_angle);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2670:14: error: no member named 'fabs' in namespace 'std'
2670 | if (std::fabs(normalized_dot - 1.0f) < epsilon) {
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2680:14: error: no member named 'fabs' in namespace 'std'
2680 | if (std::fabs(normalized_dot + 1.0f) < epsilon) {
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2682:45: error: no member named 'fabs' in namespace 'std'
2682 | ImPlot3DPoint arbitrary_axis = std::fabs(v0.x) > std::fabs(v0.z) ? ImPlot3DPoint(-v0.y, v0.x, 0.0f)
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2682:63: error: no member named 'fabs' in namespace 'std'
2682 | ImPlot3DPoint arbitrary_axis = std::fabs(v0.x) > std::fabs(v0.z) ? ImPlot3DPoint(-v0.y, v0.x, 0.0f)
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2695:24: error: no member named 'acos' in namespace 'std'
2695 | float angle = std::acos(normalized_dot);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2697:20: error: no member named 'sin' in namespace 'std'
2697 | float s = std::sin(half_angle);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2701:16: error: no member named 'cos' in namespace 'std'
2701 | q.w = std::cos(half_angle);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2707:17: error: no member named 'sqrt' in namespace 'std'
2707 | return std::sqrt(x * x + y * y + z * z + w * w);
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2786:26: error: no member named 'acos' in namespace 'std'
2786 | float theta_0 = std::acos(dot); // Angle between input quaternions
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2788:28: error: no member named 'sin' in namespace 'std'
2788 | float sin_theta = std::sin(theta); // Sine of interpolated angle
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2789:30: error: no member named 'sin' in namespace 'std'
2789 | float sin_theta_0 = std::sin(theta_0); // Sine of original angle
| ~~~~~^
/opensource/implot3d/implot3d.cpp:2791:21: error: no member named 'cos' in namespace 'std'
2791 | float s1 = std::cos(theta) - dot * sin_theta / sin_theta_0; GLFW Error 65543: NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above
...which is fixed by changing the GLFW window hints like this: glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
I'll see if I can create a pull-request...Edit: https://github.com/brenocq/implot3d/pull/7
PS: it looks like the code was tested only on Linux, since the Windows build seems to suffer from the same `std::` prefix problem: https://github.com/floooh/implot3d/actions/runs/12393862255
I’ve been having to look at some react code lately. My god how I wish I were writing DearImGui code instead.
https://github.com/BalazsJako/ImGuiColorTextEdit
'Rich' text editing might hit limitations with Dear ImGui's text rendering (e.g. not sure if things like italics, bold or strikethrough are supported out of the box).
Still, you can look through the gallery of software using ImGui [0] or in the "screenshot threads" [1] for many examples which do have nicer fonts and text rendering.
[0] https://github.com/ocornut/imgui/wiki/Software-using-Dear-Im...
[1] https://github.com/ocornut/imgui/issues?q=label%3Agallery
I wouldn't be so sure about that. Accessibility is difficult and very large, and would probably need major changes. Besides, I don't think Electron by itself cannot be performant. You can build pretty fast applications with it, if you know what you're doing. Most Electron developers don't focus on performance/resource usage though, but be able to ship fast. That's one of the major reasons web people chose Electron in the first place.
Consider adding screenshots to the readme.
In case you don't see them: https://imgur.com/a/ZYW0BsP
I've just opened an issue in case the author want to look into it. I got them to ~10MB total which is an improvement in any case.