C++23 module package for Dear ImGui on mcpp.
This package uses compat.imgui for upstream Dear ImGui sources and provides
module interfaces for the core API plus GLFW/OpenGL3 backend entry points.
Three tiers of consumer UX:
-
Tier-0
imgui.app— the convenience facade. Owns the whole window/context lifecycle; you supply only a per-frame UI callback. -
Tier-1 automatic via the
imgui.backendcontract — write backend-agnostic code against theBackendApiconcept and shared types. -
Tier-2 explicit
imgui.backend.<impl>— import a concrete backend module and alias it (using Backend = ...;); swap backend with one import + alias. -
imgui.app- Tier-0 facade.
ImGui::App::run(opts, ui)/ImGui::App::run(ui)drive the full GLFW/OpenGL3 lifecycle using the default backend.export importsimgui.coreso a consumer gets theImGui::*surface for free.
- Tier-0 facade.
-
imgui.core- Core Dear ImGui context, frame, widget, and draw-data APIs.
-
imgui.backend- Generic backend abstraction layer: shared value types (
GlConfig,Error,FbSize),RecommendedGlConfig()cross-platform defaults, and the compile-timeBackendApicontract every backend satisfies. No platform code.
- Generic backend abstraction layer: shared value types (
-
imgui.backend.platform.glfw- GLFW platform piece: window/event management +
ImGui_ImplGlfw_*binding.
- GLFW platform piece: window/event management +
-
imgui.backend.renderer.opengl3- OpenGL3 renderer piece: GL framebuffer ops +
ImGui_ImplOpenGL3_*binding.
- OpenGL3 renderer piece: GL framebuffer ops +
-
imgui.backend.glfw_opengl3- Concrete backend: assembles the GLFW platform and OpenGL3 renderer pieces
into a single
ImGui::Backend::GlfwOpenGL3type satisfyingBackendApi. Re-exportsimgui.backend(shared types) but notimgui.core.
- Concrete backend: assembles the GLFW platform and OpenGL3 renderer pieces
into a single
Backends expose one Backend type with a uniform static API, so swapping
backend is just a different import plus a one-line using Backend = ...;
alias — the rest of the consumer code is identical. Cross-platform GL/GLSL
configuration (incl. macOS forward-compat) is handled by RecommendedGlConfig(),
which CreateWindow/Init use by default.
The root package depends on:
compat.imgui = "1.92.8"compat.glfw = "3.4"compat.opengl = "2026.05.31"
The repository does not vendor Dear ImGui sources. Source and header files come from compat packages through mcpp dependency metadata.
The package does not pin a toolchain; mcpp resolves the environment/default
toolchain. The GL runtime is closed by mcpp/mcpp-index (compat.glx-runtime,
pulled in transitively by compat.glfw on Linux), not bundled by this package.
mcpp build
mcpp test
cd examples/basic
mcpp runExpected headless example output:
Dear ImGui 1.92.8 module frame ok
The minimal GLFW/OpenGL3 window example uses the combined backend module and
does not use #include in consumer code:
cd examples/minimal_window
mcpp build
mcpp runIt requires an OpenGL runtime that is visible to the mcpp/xlings runtime. If
GLFW cannot create the window, the example prints the GLFW error text. The
compat.opengl package supplies OpenGL registry/header content; it does not
bundle a platform libGL/GLX runtime.
The larger GLFW/OpenGL3 example builds on CI but should be run only in an environment with a working display and OpenGL context:
cd examples/glfw_opengl3
mcpp build
mcpp run[dependencies]
imgui = "0.0.1"Then import the modules you need.
Tier-0 (imgui.app facade — least code):
import imgui.core;
import imgui.app;
int main() {
return ImGui::App::run([] {
ImGui::Begin("hi");
ImGui::TextUnformatted("imgui.app facade");
ImGui::End();
});
}Tier-2 (explicit backend module + alias — full control):
import imgui.core;
import imgui.backend.glfw_opengl3;
using Backend = ImGui::Backend::GlfwOpenGL3; // swap import + alias to switch backends
int main() {
Backend::InitGlfw();
auto* window = Backend::CreateWindow(960, 540, "demo"); // cross-platform GL hints
Backend::MakeContextCurrent(window);
ImGuiContext* context = ImGui::CreateContext();
ImGui::SetCurrentContext(context);
Backend::Init(window); // RecommendedGlConfig() default
// ... frame loop: Backend::NewFrame / ImGui::* / Backend::RenderDrawData ...
Backend::Shutdown();
ImGui::DestroyContext(context);
Backend::DestroyWindow(window);
Backend::TerminateGlfw();
}src/core.cppm wraps imgui.h through a global module fragment and exports a
tested core API surface:
- Types:
ImGuiContext,ImFontAtlas,ImGuiIO,ImDrawData,ImVec2,ImVec4. - Functions: context lifecycle,
GetIO,NewFrame,Begin,Button,TextUnformatted,End,Render, andGetDrawData.
imgui.core exports a curated core subset; for rarely used APIs not yet
exported, a consumer translation unit can still #include <imgui.h> directly
alongside the module imports.
Backend modules adapt the official Dear ImGui backend headers internally and
expose a single Backend type per backend (uniform static API constrained by
ImGui::Backend::BackendApi). Consumer code only needs module imports for the
surfaces exposed by this package.
The 0.0.1 release state is verified with mcpp 0.0.44:
mcpp buildmcpp testcd examples/basic && mcpp runcd examples/app_minimal && mcpp buildcd examples/minimal_window && mcpp buildcd examples/glfw_opengl3 && mcpp build
The wrapper code in this repository is MIT licensed. Dear ImGui is MIT licensed
and provided by the compat.imgui package.