This issue recommends a zero-dependency C++ graphical user interface library – ImGui.
Dear ImGui is a zero-dependency graphical user interface library based on C++. It is particularly suitable for integration into game engines (for tools), real-time 3D applications, full-screen applications, embedded applications, or any application on a console platform with non-standard operating system features.
Features
-
- The core of ImGui is contained independently in several platform-independent files, and you can easily compile all the files in the repository root folder (imgui*.cpp, imgui*.h) in your application or engine.
- ImGui does not require a specific build process, and you can add.cpp files to existing projects.
- ImGui can render various Settings such as mouse, keyboard, gamepad input passed from the back end.
The
- /backends folder provides backends for various graphics apis and rendering platforms, as well as sample applications in the /examples folder.
Example code
Code ① : Settings: Dark style (left), light style (right)
ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save"))
MySaveFunction();
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
Result:
Code 2: Create a window called “My First Tool” with a menu bar.
// 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);
// Plot some values
const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values));
// 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();
Result:
Demo: Calling the ImGui::ShowDemoWindow() function creates a demo window with various features and examples. This code can always refer to imgui_demo.cpp.
Project presentation
Game console
Game editor
3D software
Debugging interface
Data monitoring
—END—
Open Source protocol: Apache2.0