TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

284 pointsby dragonshover 4 years ago

28 comments

exDM69over 4 years ago
As much as I like Dear ImGui, the immediate mode paradigm doesn&#x27;t work everywhere. The problem of &quot;page tearing&quot; (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 &quot;retained mode state tracking&quot; on top of Imgui. It&#x27;s good for games, but for applications where you&#x27;re not rendering new frames constantly, the paradigm doesn&#x27;t seem a very good fit.<p>I wish there was a retained mode GUI library that would be as easy to integrate in your game and graphics apps as ImGui (or nuklear) is.<p>On my spare time, I&#x27;ve been working on a retained mode GUI layout and rendering framework (not a complete GUI toolkit) that uses a DOM-like tree, CSS style flexbox layouts and produces a vertex buffer for rendering like ImGui does.<p>Unfortunately life gets in the way, and all I have to show for my project is a small prototype in C and another one in Rust (can&#x27;t decide which I like more) that draws some text and rectangles with a fancy layout. Code is not public at the moment but I&#x27;m willing to share it with anyone (on GitHub) who responds with a thoughtful comment or a good question.<p>I have been following Raph Levien&#x27;s fantastic work on Druid and Rust GUIs which has been very inspirational, this video in particular [0].<p>Where Raph is focused on native GUI rendering and high fidelity text output, I&#x27;ve only focused on rendering in a GPU application using shaders and only very basic text layout with simple kerning (like Dear ImGui).<p>As Raph points out in his later talks on the topic, layout and rendering are only half of the GUI puzzle. The other half is maintaining the state of the application, usually through some kind of widget tree.<p>Leave a comment if you&#x27;re interested, I&#x27;d be happy to chat even though it doesn&#x27;t seem like my projects are going anywhere anytime soon.<p>[0] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=4YTfxresvS8" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=4YTfxresvS8</a> Data Oriented GUI in Rust by Raph Levien
评论 #24989478 未加载
评论 #24987982 未加载
评论 #24988095 未加载
评论 #24989435 未加载
评论 #24987985 未加载
评论 #24988392 未加载
评论 #24988158 未加载
评论 #24993845 未加载
评论 #24989422 未加载
评论 #24990443 未加载
评论 #24988397 未加载
评论 #24990610 未加载
roytriesover 4 years ago
Not sure why this is showing up on HN today. But Dear ImGui is absolutely amazing. And its not just for C++. I use it myself in my C# game engine. (There&#x27;s a C# port that uses System.Numerics: <a href="https:&#x2F;&#x2F;github.com&#x2F;mellinoe&#x2F;ImGui.NET" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mellinoe&#x2F;ImGui.NET</a>) which I&#x27;ve ported to MonoGame <a href="https:&#x2F;&#x2F;github.com&#x2F;roy-t&#x2F;ImGui.NET" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;roy-t&#x2F;ImGui.NET</a>)<p>I&#x27;ve used a lot of different UI frameworks (winforms, WPF, Html&#x2F;CSS based frameworks, custom game engine frameworks). But for prototyping Dear ImGui and the whole immediate GUI idea is amazing. It even looks quite decent and the new docking support is great :).
评论 #24987660 未加载
评论 #24988052 未加载
评论 #24988094 未加载
ahaferburgover 4 years ago
Every couple months I browse the screenshot threads <a href="https:&#x2F;&#x2F;github.com&#x2F;ocornut&#x2F;imgui&#x2F;issues&#x2F;3488" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ocornut&#x2F;imgui&#x2F;issues&#x2F;3488</a><p>Looking at them makes me really happy for some reason.
评论 #24993062 未加载
JabavuAdamsover 4 years ago
IMGUI is good on many levels, but also has some serious drawbacks. Specifically: latency in figuring out exactly how big a control or layout will be. This also translates into at least 1-frame latency when drawing to a widget based on user input. Imagine a scrubber line on a video timeline or graph, for instance.<p>Non-immediate mode GUI (retained-mode?) means that you can query a layout for exactly how big it will be before it gets drawn. So, if the user clicks at say (100, 200), I know exactly where to draw something in response to that click on top of my widget, without waiting a frame for the GUI to layout.<p>Maybe developers who have come up in the web world don&#x27;t care, but I find reflow issues to be one of the worst features of browser apps. If you&#x27;re going for a tight native experience, then this is a huge no-no.<p>The &quot;immediate-mode&quot; GUI idea was something that Casey Muratori, a very influential indie game developer, came up with. Part of his rationale was that it was annoying to store all the state for your widgets in a parallel data structure to the widgets themselves. So why not just draw the widgets, as needed, where you have the local variables and data to draw them?<p>Various developers and frameworks seem to get smitten with this idea, jump on the bandwagon, and then run into the flaws. For a long time the Unity game engine followed this model. I found the GUI easy to get started with, but ultimately limiting. Unity eventually abandoned this approach.<p>Really, this is good for developer-quality in-game debugging UI, but it&#x27;s not a great approach for creating polished end-user UI.<p>I adopted IMGUI, used it briefly, was impressed by its speed, but ran into massive problems customizing controls to get exactly the right look and feel.<p>My take -- this is an ideologically-driven kind of neat but ultimately dead end. Use it to quickly get a dev GUI going, but it won&#x27;t see you through to a polished consumer-ready GUI.
评论 #24989063 未加载
评论 #24988893 未加载
评论 #24991062 未加载
prvcover 4 years ago
&gt;This library is called Dear ImGui. Please refer to it as Dear ImGui (not ImGui, not IMGUI).<p>&gt;(The library misleadingly started its life in 2014 as &quot;ImGui&quot; due to the fact that I didn&#x27;t give it a proper name when when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations e.g. Unity uses it own implementation of the IMGUI paradigm. To reduce the ambiguity without affecting existing code bases, I have decided in December 2015 a fully qualified name &quot;Dear ImGui&quot; for this library.<p>Yes, but why &quot;Dear&quot;? Makes it read in an odd way wrt to idiomatic English.
评论 #24987826 未加载
评论 #24987679 未加载
评论 #24993200 未加载
评论 #24987667 未加载
modelessover 4 years ago
One of the most valuable parts of Dear Imgui is the example applications, which are great as a reference and starting point for your own projects. Many different platforms and rendering APIs are covered.<p>Also be sure to check out the &#x27;docking&#x27; branch, which implements docking panels and tearaway windows in the style of Visual Studio. There are many low quality versions of this concept in other GUI libraries but I think Dear Imgui&#x27;s version is the best I&#x27;ve seen outside of Visual Studio itself.
Torkelover 4 years ago
Happy to see ImGui trend here on HN!<p>It is an amazing tool that is used in a lot of game engines for making internal&#x2F;dev gui:s. The principle of drawing gui &quot;as you go&quot;, interleaved with control flow makes it easier+faster to make gui:s.<p>In our company&#x27;s main app we use ImGui (with customizations) for all gui work (from C++ and Rust).
评论 #24987501 未加载
varispeedover 4 years ago
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&#x27;t work at all or needed a horrible hack to work. I can&#x27;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 when you try to instatiate such window then the other window goes crazy or if you close the modal window everything closes and there would be no way to fix it other than digging into library code. I hope this one is not like that.
评论 #24989375 未加载
评论 #24989360 未加载
评论 #24990829 未加载
hartmelover 4 years ago
- the developer is the creator of MEKA, a (1998!) Sega Master System emulator, which had the reputation to be the best during a long time (and still may be, I don&#x27;t know anymore)<p>- WonderBoy Dragon&#x27;s Trap remake and Street Of Rage 4 for PC&#x2F;consoles, it&#x27;s him too<p>I may be wrong, but following the screenshots, the Dragon&#x27;s Trap development was like : we need tools to write a game ! let&#x27;s write it ! Wait we need libraries to write tools ! let&#x27;s write them !<p>The quality of the game and all the details reflect impressive skills and amount of work.
perfunctoryover 4 years ago
I like ideas behind immediate mode gui. It&#x27;s a bit like React.js only without DOM in between. It&#x27;s not ideal, it has its own issues, but it could develop further into something more robust, I hope.<p>GUI is hard.
srikzover 4 years ago
Dear ImGui is excellent and is very handy to make GUI version of a CLI app especially if we want to interactively set values and see results.<p>It is fairly low level (deliberately) and that’s great to keep it simple. I wish there is a standalone GUI ‘framework’ which builds on these primitives and leans on standard library to make the experience a bit more nicer when building standalone applications.<p>I understand this is not the goal of Dear ImGui. I may give it a shot in a few months time if I don’t come across any such project.
andybakover 4 years ago
I haven&#x27;t properly thought this through but is here a sense in which the React &quot;one way data flow&quot; paradigm is a case of rediscovering immediate mode GUIs on the web?
评论 #24988025 未加载
评论 #24988053 未加载
enriqutoover 4 years ago
Widgets are bloat.<p>Is there a similar library but without widgets? Something really, really simple. I just want a canvas to draw, and a handler to receive mouse and keyboard events. No windows, no text, just a framebuffer.<p>Back in the day I was really happy with glut and opengl. You just took the three-line hello world and started drawing stuff without fuss. ImGui seems too unnecessarily complicated for me.
评论 #24988198 未加载
评论 #24988771 未加载
dgr582systemsover 4 years ago
Dear ImGui is so easy to get working compared to other similar C++ libraries. For small dev teams using C++ that alone makes it super valuable.<p>I hate losing a day to figure out how to link in some crazy, clashing dependencies. Never had that problem with this library.
评论 #24996101 未加载
grligaover 4 years ago
&quot;Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization &#x2F; debug tools (as opposed to UI for the average end-user).&quot;
MaxBarracloughover 4 years ago
I&#x27;m reminded a little of the FOX Toolkit, [0] but ImGui has more of an emphasis on accelerated graphics.<p>[0] <a href="http:&#x2F;&#x2F;fox-toolkit.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;fox-toolkit.org&#x2F;</a>
评论 #24989566 未加载
phkahlerover 4 years ago
&gt;&gt; You will need a backend to integrate Dear ImGui in your app. The backend passes mouse&#x2F;keyboard&#x2F;gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices<p>Some people say this thing is platform agnostic, which is sort of true. But in no way does it give you a multiplatform GUI. You must provide this &quot;backend&quot; for every OS you want to run on. If you decide to handle that with QT, GTK, or WX, then what use is this?
评论 #24989816 未加载
评论 #24992299 未加载
database_lostover 4 years ago
I don&#x27;t work that much with GUI applications, but Dear ImGui was perfect for a past project and I just wanted to chime in on the positive feedback :) Take care everyone!
aquovaover 4 years ago
I&#x27;m curious on what opinions are on Dear ImGui&#x27;s bindings in other languages, namely Rust. imgui-rs seems to be one of the only mature-ish GUI libraries, but I found myself struggling with it. The multiple window &quot;debug view&quot; looks great, but for something like an OpenGL window with a simple menu bar, I found it difficult to create. There is also apparently no file picker widget, which I found to be a big downside.
pansa2over 4 years ago
Qt seems to be the most popular library for cross-platform GUI apps written in C++. Is Dear ImGui a credible alternative?<p>How does Dear ImGui compare to Qt?
评论 #24987689 未加载
评论 #24987688 未加载
评论 #24987697 未加载
评论 #24987659 未加载
评论 #24988791 未加载
评论 #24987677 未加载
anderspitmanover 4 years ago
For those who may be unfamiliar with the &quot;immediate mode&quot; vs &quot;retained mode&quot; terminology here, an aha moment for me was realizing frameworks like React are essentially immediate mode APIs (such as declarative JSX) abstracting an underlying retained-mode system (the DOM).<p>It may not be a perfect analogy, but seems to be basically true.
kevingaddover 4 years ago
Dear ImGui is amazing software with great ideas, but at this point I feel like the &quot;immediate&quot; is a problematic lie much like how &quot;immediate mode&quot; graphics rendering hasn&#x27;t been immediate in years. I think the most appropriate way to describe these libraries is &quot;imperative&quot;, because you&#x27;re constructing retained state by running imperative code and the library is responsible for figuring out how to do what you want it to do.<p>Any properly functioning UI with the features needed by more than a handful of users ends up having to retain a considerable amount of state. This doesn&#x27;t mean that you need to construct a huge graph of interconnected object goo, but a bunch of C&#x2F;C++ calling functions every frame with no retained state won&#x27;t cut it. Libraries like Dear ImGui and Nuklear largely solve this with a combination of wasted energy (by running your code repeatedly) and magical hidden state (managing retained state in the background for you automatically).<p>The fact that retained state does end up existing but behind the curtain means that annoying problems manifest themselves due to it being out of your control. For example, a textbox needs to maintain the current selection along with a scroll offset in its viewport, along with an undo&#x2F;redo history. You might decide to drop some of that but some of it has to stick. In Nuklear&#x27;s case, it relies on stb_textedit to do a lot of the heavy lifting (great library!) and retains state for you behind the scenes. Because the state management is automatic based on the small amount of information Nuklear has, doing something like collapsing a hideable panel makes the textbox &quot;disappear&quot; at which point the scroll offset, selection and undo&#x2F;redo history vanish. The user may have accidentally collapsed the panel (or the program did it for them), and you&#x27;ve now responded to that input by throwing away something very important. You certainly <i>could</i> retain all this state inside your application (whether or not there&#x27;s an API for it in the library is another question), but now you have to come up with a solution for tracking and storing all that state.<p>Other comments have already mentioned the &quot;page tearing&quot; problem (needing an extra frame to respond to state changes, etc) which is one manifestation of this fundamental issue - that retained state is in fact necessary and hiding it creates new problems - but there are other challenges that are easier to ignore. Accessibility is a major one, and current IMGUI libraries are entirely ill-prepared to address it. Another issue is internationalization - not only is RTL text an issue, but complex character sets require shaping (an expensive operation) which also requires caching and additional infrastructure that is going to clash painfully with the very simple &quot;just draw some text&quot; model used by most of these libraries. International text input is also very stateful and you&#x27;ll find that interacting with IMEs is quite difficult if you aren&#x27;t careful about things. (This is especially bad because SDL2 itself has a botched IME implementation, so users of non-western character sets are screwed right out of the gate.)<p>I&#x27;ve been using Nuklear over the past couple years for some development tools and the experience soured me on IMGUI libraries in general because I kept running into these problems that, in retrospect, should not have been a surprise. The UI had lots of rough edges you&#x27;d feel when using it, it was ugly (until I aggressively patched it to address this), it was slow, etc. Dear ImGui is likely higher quality than Nuklear (not that I can say for sure, because I never got it to work due to integration problems) but the fundamental design principles are largely the same and it has its own set of limitations. I&#x27;m hopeful that as time passes these libraries will continue to improve, but I&#x27;ve personally moved on to accepting that a good UI needs retained state and I&#x27;m focusing on ways to make constructing that state as easy as possible without leaving users who need accessibility or foreign character sets out in the cold.<p>Some less relevant footnotes:<p>* The performance obsession demonstrated in some of these libraries is an active hindrance and in some cases actually sabotages performance. Text rendering in Nuklear is &quot;simple&quot; but for remotely adequate performance you end up having to build your own layout cache and take other steps to compensate for the fact that text is not &quot;simple&quot; at all. To avoid running out of memory, you need to come up with a GC for your layout cache. Solving various problems like page tearing will require you to run the whole layout&#x2F;rasterization process for your UI multiple times, so now your fast &quot;immediate mode&quot; code is actually doing all its work repeatedly, burning CPU. So far tearing out Nuklear and replacing it with my own retained mode framework has improved performance and reduced code size.<p>* The degree to which Dear ImGui and Nuklear value convenience is, in my opinion, counter-productive - for example the ability to just drop it in and get a vertex buffer + texture pair with text is great but it turns out to mean that the library is doing a bunch of stuff (like font management) itself and replacing that with something modern is actually... very hard. I think the correct approach here is to take steps to make integration easy instead of going for full &#x27;just clone the repo and run make&#x27; convenience. I had to aggressively modify Nuklear to have any hope of integrating proper text support at all (and then I couldn&#x27;t upstream my changes because it turns out that the &quot;single-header&quot; Nuklear library is not actually single-header. another convenience-oriented lie... we&#x27;re programmers, we can handle extra header files, can&#x27;t we?)<p>* Accessibility is really, really hard. More people need it than you&#x27;d expect. You need to plan for it in advance, and if you didn&#x27;t it will be very hard to fix after the fact. I can&#x27;t say for certain whether Dear ImGui will be able to transition smoothly into an accessible world, but Nuklear&#x27;s design is woefully unprepared. Every element ideally has a human-readable description (for screen readers) and role (button, etc), and your UI needs to have a coherent structure that can be explored by a screen reader. For users with diminished vision you need robust support for adjustable sizes and theming (so you can improve readability and contrast). You also need to consider alternate input methods - full keyboard, game controller, touch - while these libraries are mostly designed for keyboard+mouse.
sime2009over 4 years ago
Visually it doesn&#x27;t look so good out of the box. Are there some extra styles or libraries etc out there which implement good looking styles on top of Dear ImGui? Or are dev expected to put their own style on top of it?
评论 #24988752 未加载
评论 #24988764 未加载
fizixerover 4 years ago
&gt; Dear ImGui – Bloat-free graphical user interface library for a bloated programming lanugage<p>FTFY
app4softover 4 years ago
Is there usable <i>Dear ImGui</i> fork&#x2F;sample for <i>OpenGL 1.x</i>?
评论 #24987996 未加载
评论 #24987877 未加载
评论 #24987825 未加载
ameliusover 4 years ago
Does it support GPUs and Wayland directly?
评论 #24987713 未加载
ZenPsychoover 4 years ago
until accessibility is implemented, don’t use this please
评论 #24987881 未加载
评论 #24987848 未加载
dasloopover 4 years ago
The widget should keep its state private.<p>ImGui::InputText(&quot;string&quot;, buf, IM_ARRAYSIZE(buf));<p>ImGui::SliderFloat(&quot;float&quot;, &amp;f, 0.0f, 1.0f);<p>And maybe is a C++ lib but the interface is C with namespaces. Odd.
评论 #24987420 未加载
评论 #24987403 未加载
评论 #24996570 未加载