# Dear ImGui — Bloat-Free Immediate Mode GUI for C++ That Powers Every Game Tool > Dear ImGui is the immediate-mode GUI library used by virtually every game engine for in-game editors, debug overlays, and tooling. Minimal dependencies, minimal state, maximum productivity. ## Install Save as a script file and run: # Dear ImGui — Immediate Mode GUI ## Quick Use ```cpp // Minimal per-frame code ImGui::Begin("Debug"); ImGui::Text("FPS: %.1f", ImGui::GetIO().Framerate); if (ImGui::Button("Reset")) reset(); ImGui::SliderFloat("volume", &volume, 0.0f, 1.0f); ImGui::End(); ``` ## Introduction Dear ImGui, by Omar Cornut, is the industry-standard immediate-mode GUI library for C++. Instead of retaining widget state in the framework, ImGui recreates the entire UI every frame — which turns out to be perfect for game development, debug tools, engine editors, and data-driven inspectors. With over 72,000 GitHub stars, Dear ImGui is used by Unreal Engine, Unity plugins, Godot, Blender dev tools, Tracy Profiler, RenderDoc, Minecraft dev builds, every major VFX studio, and thousands of custom engines. If you've seen a game editor, you've probably seen Dear ImGui. ## What Dear ImGui Does Each frame, you call functions like `ImGui::Button("Press me")` that immediately return whether the button was pressed that frame. ImGui tracks IDs, focus, and widget state internally. Backends (DirectX, OpenGL, Vulkan, SDL, GLFW) handle input and rendering. The whole lib is <25 files; drop it in, wire up backend, done. ## Architecture Overview ``` Your render loop (per frame) | Backend::NewFrame() (gather input, start frame) | ImGui::NewFrame() (ImGui tracks time + state) | Your code: ImGui::* calls build the UI tree | ImGui::Render() (produce vertex/index buffers + draw commands) | Backend::RenderDrawData(ImGui::GetDrawData()) | Your renderer executes the draw commands Backends supplied: DirectX 9/10/11/12, OpenGL 2/3, Vulkan, Metal, WebGPU GLFW, SDL, Win32, Cocoa, SDL_Renderer, allegro, EMScripten ``` ## Self-Hosting & Configuration ```cpp // Setup (once) IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // docking branch io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // multi-viewport ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 150"); // Main loop (per frame) ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); ImGui::Begin("Scene"); static float position[3] = {0,0,0}; ImGui::DragFloat3("position", position, 0.1f); ImGui::ColorEdit3("background", bg_color); if (ImGui::Button("Reload shaders")) reload_shaders(); ImGui::End(); // Custom window with dockable panels ImGui::DockSpaceOverViewport(); ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ``` ## Key Features - **Immediate mode** — widgets are function calls, no retained state - **Minimal deps** — drop 15-20 .cpp/.h files into any project - **Multi-backend** — DX 9-12, OpenGL 2+, Vulkan, Metal, WebGPU, SDL_Renderer - **Docking + multi-viewport** — float panels out to OS windows - **Tables + trees + plots** — rich widget set + ImPlot addon for charts - **Drag-and-drop** — typed payloads across windows - **Fonts + Unicode** — FreeType + truetype, emoji + CJK support - **Tiny runtime** — no DOM, no virtual widget tree, <1ms per frame ## Comparison with Similar Tools | Feature | Dear ImGui | egui (Rust) | Nuklear | CEGUI | Qt / wxWidgets | |---|---|---|---|---|---| | Paradigm | Immediate mode | Immediate mode | Immediate mode | Retained | Retained | | Language | C++ | Rust | C | C++ | C++ | | Minimal deps | Very few | Few | Single header | Many (CEGUI libs) | Large | | Game engine uptake | Dominant | Growing | Moderate | Limited | Uncommon | | Best For | Game tools, debug UIs, engine editors | Rust apps + game tools | C embedded | Traditional GUI apps | Desktop apps | ## FAQ **Q: Can I use ImGui for a regular desktop app?** A: You can, but it's not ideal. Retained-mode toolkits (Qt, wxWidgets) are better for typical business apps (accessibility, native look). ImGui shines where UI changes every frame (game tools, debug overlays, data inspectors). **Q: How is multi-viewport different from docking?** A: Docking lets panels dock/undock within the app window. Multi-viewport lets them dock OUTSIDE the app window as separate OS windows (true multi-monitor editors). **Q: What about accessibility / i18n?** A: Limited. Dear ImGui is primarily for developer-facing tools, not accessibility-critical end-user UIs. Unicode fonts + CJK work well; screen reader support is minimal. **Q: Performance concerns?** A: Very fast — rebuilding UIs every frame is counterintuitively efficient because nothing is allocated that wasn't going to be drawn anyway. Typical frame cost: <1ms for 1000s of widgets. ## Sources - GitHub: https://github.com/ocornut/imgui - Author: Omar Cornut - Docking branch: docking feature is in the `docking` branch - License: MIT --- Source: https://tokrepo.com/en/workflows/a81f7c61-3862-11f1-9bc6-00163e2b0d79 Author: Script Depot