Skip to content

stripe2933/imgui-module

Repository files navigation

C++20 Module Binding for ImGui

License: MIT

Use ImGui with import imgui;. This binding is generated with cimgui and regularly updated and tested with GitHub Actions.

Usage

Using with Latest ImGui (v1.92.3)

This repository already contains the generated bindings for the latest ImGui version.

And following backends are also available:

Using with Older ImGui Versions / Features / Backends

If you want to use ImGui with an older version, different feature configuration or a custom backend, you can generate the bindings yourself. The following steps will guide you through the process:

  1. Cone the repository with recursive submodules:
git clone --recurse-submodules https://github.com/stripe2933/imgui-module.git
cd imgui-module
  1. Checkout the ImGui version you want to use: in cimgui/imgui submodule folder, checkout the desired version tag or commit.
  2. Manipulate the cimgui configuration, explained in cimgui - Using Generator. This will generate definitions.json, structs_and_enums.json and impl_definitions.json files in cimgui/generator/output folder.
  3. Run the Python generator script:
python3 generate.py
  1. The generated bindings will be in the generated folder. You can use them as described in the previous section.

Examples

Example Screenshot

This repository contains several examples for how to integrate these generated module bindings with different backends. These examples are also used for build testing with GitHub Actions.

Currently, following examples are available:

Contributions for more examples are welcome!

Using Installed Libraries

To build these examples, you need:

  • CMake ≥ 3.30 for MSVC or Clang, ≥ 4.0 for GCC.
  • Ninja ≥ 1.11
  • A C++23 compliant compiler
    • GCC 15 or later
    • Clang 18 or later
    • Microsoft Visual Studio 2022 or later

Configure CMake with the following command:

cd examples
cmake --preset=default

then, by the library installation status on your system, the available targets will be configured. For example, if your system has GLFW installed and unless you're using macOS without Vulkan SDK, glfw_vulkan target will be available. You can build the example with:

cmake --build build --target glfw_vulkan

And the executable will be in examples/build folder.

Using vcpkg

If you want to build all examples regardless of the installed libraries, you can use vcpkg to install the used libraries. Configuring CMake with the following command:

cmake --preset=default -DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake

will install all required libraries and enable the examples.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

C++20 module binding for ImGui.

Resources

License

Stars

Watchers

Forks

Packages

No packages published