Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Get started

Starter template

With this starter template, you do not need to clone HelloImGui, as it (optionally) can be downloaded and built automatically during CMake configure time.

See this extract from the CMakelists.txt file of the template:

CMake utility: hello_imgui_add_app

CMakeLists.txt
# hello_imgui_add_app is a helper function, similar to cmake's "add_executable"
#
# Usage:
#     hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
# Or:
#     hello_imgui_add_app(app_name file1.cpp file2.cpp ... ASSETS_LOCATION "path/to/assets")
# (By default, ASSETS_LOCATION is "assets", which means that the assets will be searched in the "assets" folder,
# relative to the location of the CMakeLists.txt file)
#
# Features:
#     * It will automatically link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
#     * It will embed the assets (for desktop, mobile, and emscripten apps)
#     * It will perform additional customization (app icon and name on mobile platforms, etc)
#     * On desktop platforms, it will perform a "portable install" (i.e. assets and executable are in the same folder)
#
# If you want to control the install of your app, you can set HELLOIMGUI_ADD_APP_WITH_INSTALL to OFF
# See an example in https://github.com/pthom/hello_imgui_template/blob/main/CMakeLists.txt
#

Assets and app customization

Immediate GUI mode

Hello ImGui is based on Dear ImGui, which is a library for immediate mode GUI programming.

With an Immediate mode GUI you can for example display a button and handle the click event in one line of code:

hello_globe.main.cpp
#include "hello_imgui/hello_imgui.h"

int main(int , char *[])
{
    auto guiFunction = []() {
        ImGui::Text("Hello, ");                    // Display a simple label
        HelloImGui::ImageFromAsset("world.png");   // Display a static image
        if (ImGui::Button("Bye!"))                 // Display a button
            // and immediately handle its action if it is clicked!
            HelloImGui::GetRunnerParams()->appShallExit = true;
     };
    HelloImGui::Run(guiFunction, "Hello, globe", true);
    return 0;
}

ImGui Manual is a great resource to learn interactively about all the widgets provided by Dear ImGui.