Hacker News new | ask | show | jobs
by pro14 551 days ago
I was working on an app using ImGui. Eventually, I noticed that my MacBook battery was draining whenever my app was running. Is this because immediate mode GUI rendering is inefficient?
4 comments

You probably had your render loop set to poll rather than wait for events. If you don't configure wait events you'd be re-rendering your UI as fast as your monitor refreshes.
When you click the battery icon in the macOS menu bar you can see which apps are using significant energy, and in the 'Activity Monitor' tool you can also sort by energy usage.

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.

Immediate mode here is relevant in terms of the api style, not the rendering strategy. From the README:

> 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.

> Is this because immediate mode GUI rendering is inefficient?

No.

https://www.forrestthewoods.com/blog/proving-immediate-mode-...