imgui README

The project's README from github.com/ocornut/imgui. As one markdown file: README.md.

Dear ImGui

"Give someone state and they'll have a bug one day, but teach them how to represent state in two separate locations that have to be kept in sync and they'll have bugs for a lifetime." -ryg

Build Status Static Analysis Status Tests Status

(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)

Businesses: support continued development and maintenance via invoiced sponsoring/support contracts:
  E-mail: contact @ dearimgui dot com
Individuals: support continued development and maintenance here. Also see Funding page.

The Pitch - Usage - How it works - Releases & Changelogs - Demo - Getting Started & Integration
Gallery - Support, FAQ - How to help - Funding & Sponsors - Credits - License
Wiki - Extensions - Language bindings & framework backends - Software using Dear ImGui - User quotes

The Pitch

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline-enabled application. It is fast, portable, renderer agnostic, and self-contained (no external dependencies).

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal and lacks certain features commonly found in more high-level libraries. Among other things, full internationalization (right-to-left text, bidirectional text, text shaping etc.) and accessibility features are not supported.

Dear ImGui is particularly suited to integration in game engines (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on console platforms where operating system features are non-standard.

Usage

The core of Dear ImGui is self-contained within a few platform-agnostic files which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui*.cpp, imgui*.h). No specific build process is required: you can add all files into your existing project.

Backends for a variety of graphics API and rendering platforms are provided in the backends/ folder, along with example applications in the examples/ folder. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.

C++20 users wishing to use a module may use the stripe2933/imgui-module third-party extension.

See the Getting Started & Integration section of this document for more details.

After Dear ImGui is set up in your application, you can use it from _anywhere_ in your program loop:

ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save"))
    MySaveFunction();
ImGui::InputText("string", buf, IM_COUNTOF(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
sample code output (dark) sample code output (light)
// Create a window called "My First Tool", with a menu bar.
ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
if (ImGui::BeginMenuBar())
{
    if (ImGui::BeginMenu("File"))
    {
        if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
        if (ImGui::MenuItem("Save", "Ctrl+S"))   { /* Do stuff */ }
        if (ImGui::MenuItem("Close", "Ctrl+W"))  { my_tool_active = false; }
        ImGui::EndMenu();
    }
    ImGui::EndMenuBar();
}

// Edit a color stored as 4 floats
ImGui::ColorEdit4("Color", my_color);

// Generate samples and plot them
float samples[100];
for (int n = 0; n < 100; n++)
    samples[n] = sinf(n * 0.2f + ImGui::GetTime() * 1.5f);
ImGui::PlotLines("Samples", samples, 100);

// Display contents in a scrolling region
ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
ImGui::BeginChild("Scrolling");
for (int n = 0; n < 50; n++)
    ImGui::Text("%04d: Some text", n);
ImGui::EndChild();
ImGui::End();

my_first_tool_v192 6

Dear ImGui allows you to create elaborate tools as well as very short-lived ones. On the extreme side of short-livedness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweak variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game-making editor/framework, etc.

How it works

The IMGUI paradigm through its API tries to minimize superfluous state duplication, state synchronization, and state retention from the user's point of view. It is less error-prone (less code and fewer bugs) than traditional retained-mode interfaces, and lends itself to creating dynamic user interfaces. Check out the Wiki's About the IMGUI paradigm section for more details.

Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.

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.

Releases & Changelogs

See Releases page for decorated Changelogs. Reading the changelogs is a good way to keep up to date with the things Dear ImGui has to offer, and maybe will give you ideas of some features that you've been ignoring until now!

Demo

Calling the ImGui::ShowDemoWindow() function will create a demo window showcasing a variety of features and examples. The code is always available for reference in imgui_demo.cpp.

You should be able to build the examples from sources. If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:

Examples projects using Dear ImGui: Tracy (profiler), ImHex (hex editor/data analysis), RemedyBG (debugger) and hundreds of others.

For more user-submitted screenshots of projects using Dear ImGui, check out the Gallery Threads!

For a list of third-party widgets and extensions, check out the Useful Extensions/Widgets wiki page.

Custom engine erhe (docking branch)
erhe
Custom engine for Wonder Boy: The Dragon's Trap (2017)
the dragon's trap
Custom engine (untitled)
editor white
Tracy Profiler (github)
tracy profiler

Getting Started & Integration

See the Getting Started guide for details.

On most platforms and when using C++, you should be able to use a combination of the imgui_impl_xxxx backends without modification (e.g. imgui_impl_win32.cpp + imgui_impl_dx11.cpp). If your engine supports multiple platforms, consider using more imgui_impl_xxxx files instead of rewriting them: this will be less work for you, and you can get Dear ImGui running immediately. You can later decide to rewrite a custom backend using your custom engine functions if you wish so.

Integrating Dear ImGui within your custom engine is a matter of mainly 1) wiring mouse/keyboard/gamepad inputs 2) uploading a texture to your GPU/render engine 3) providing a render function that can create/update textures and render textured triangles. This is exactly what backends are doing.

Officially maintained backends (in repository):

Third-party backends/bindings wiki page:

Useful Extensions/Widgets wiki page:

Useful extensions thumbnails

Also see Wiki for more links and ideas.

Support, Frequently Asked Questions (FAQ)

See: Frequently Asked Questions (FAQ) where common questions are answered.

See: Getting Started and Wiki for many links, references, articles.

See: Articles about the IMGUI paradigm to read/learn about the Immediate Mode GUI paradigm.

See: Upcoming Changes.

See: Dear ImGui Test Engine + Test Suite for Automation & Testing.

For the purposes of getting search engines to crawl the wiki, here's a link to the Crawlable Wiki (not for humans, here's why).

Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use GitHub Discussions. For ANY other questions, bug reports, requests, feedback, please post on GitHub Issues. Please read and fill the New Issue template carefully.

Private support is available for paying business customers (E-mail: contact @ dearimgui dot com).

Which version should I get?

We occasionally tag Releases (with nice releases notes) but it is generally safe and recommended to sync to latest master or docking branch. The library is fairly stable and regressions tend to be fixed fast when reported. Advanced users may want to use the docking branch with Multi-Viewport and Docking features. This branch is kept in sync with master regularly.

Who uses Dear ImGui?

See the Quotes, Funding & Sponsors, and Software using Dear ImGui Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the Gallery Threads!

How to help

How can I help?

Sponsors

Ongoing Dear ImGui development is and has been financially supported by users and private sponsors.
Please see the detailed list of current and past Dear ImGui funding supporters and sponsors for details.
From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations.

THANK YOU to all past and present supporters for helping to keep this project alive and thriving!

Dear ImGui is using software and services provided free of charge for open source projects:

Credits

Developed by Omar Cornut and every direct or indirect contributors to th

imgui (ocornut/imgui)

Searching Database…

76.7K ·GitHub
这是什么?Dear ImGui 是一个轻量级的 C++ 图形用户界面库,它输出经过优化的顶点缓冲区,由你在自己支持 3D 渲染管线的应用程序中进行绘制。它面向工具类、调试界面和可视化场景,而不是面向终端用户的应用界面。
它是框架还是库?它自己管理窗口和渲染吗?它是一个独立的库,而不是完整的框架:核心部分(imgui.cpp、imgui.h)与平台无关,只生成绘制数据;实际的窗口和渲染则由单独的后端文件处理,例如 DirectX、OpenGL、Vulkan、Metal 等。
我怎么在项目里把它跑起来?将根目录下的 .cpp/.h 文件直接放入你的项目中(无需构建系统),然后从 backends/ 文件夹中选择一个渲染器后端和一个平台后端,例如 imgui_impl_win32.cpp + imgui_impl_dx11.cpp,并按照 Getting Started 指南进行配置。
使用它需要额外的外部库吗?不需要。核心库是独立的,没有任何外部依赖;你只需要一个图形 API 或平台后端(如 GLFW、SDL、Win32、DirectX、Vulkan、OpenGL)来渲染它。
它有意不支持哪些界面功能?它缺乏完整的国际化支持(如从右到左的文本、双向文本和文字塑形)以及无障碍功能,因为它更注重简洁,而不是做成通用的终端用户界面工具包。
这是为谁设计的?它面向为游戏引擎、实时 3D 应用、嵌入式和主机软件以及调试、性能分析工具开发工具的程序员,而不是面向设计消费者界面的设计师。
官方支持哪些平台和渲染器?官方维护的后端涵盖以下渲染器:DirectX 9/10/11/12、Metal、OpenGL/ES、SDL_GPU、SDLRenderer、Vulkan、WebGPU;平台包括 GLFW、SDL2/SDL3、Win32、Glut、OSX、Android;框架包括 Allegro5 和 Emscripten。
它采用的即时模式 GUI 范式是什么?它不需要创建带有同步状态的保留式控件对象,而是在代码的任何位置每帧调用 UI 函数。与传统的保留模式界面相比,该库尽量减少了状态的重复与同步。
我能不先自己集成就试用它吗?可以。调用 ImGui::ShowDemoWindow() 即可显示一个涵盖大部分功能的内置演示,此外还提供可下载的预编译 Windows 演示程序。
除了 C++ 还有其他语言的绑定吗?有。第三方提供了自动生成或手写的绑定,支持 C、C#、Python、Rust、Go、Java、Lua、Swift、Zig 等众多语言,还有适用于 Godot、Unreal、Unity 和 Blender 等引擎的集成。
用它开发过哪些知名工具?例如 Tracy 性能分析器、ImHex 十六进制编辑器和 RemedyBG 调试器,此外还有数百种其他工具和游戏引擎编辑器。
What are similar projects?egui, bgfx, DearPyGui, assimp, raylib, godot, WoWee, sokol
Creator
ocornut
Size
129 MB
Stars
76.7K
Age
12y
Commits · 90 Days