# Is Dear ImGui Cross-Platform? Understanding Its Platform-Agnostic Architecture

> Discover if Dear ImGui is cross-platform. Learn how its platform-agnostic architecture and optional backend modules ensure pure C++11 code compiles anywhere for seamless integration.

- Repository: [omar/imgui](https://github.com/ocornut/imgui)
- Tags: deep-dive
- Published: 2026-07-28

---

**Dear ImGui is fully cross-platform and platform-agnostic by design, with OS-specific functionality isolated in optional backend modules while the core library remains pure C++11 code that compiles on any system.**

Dear ImGui (ocornut/imgui) is an immediate-mode GUI library engineered for universal compatibility. Unlike monolithic frameworks that embed platform assumptions, Dear ImGui separates abstract UI logic from system-level operations, enabling deployment across Windows, macOS, Linux, mobile devices, and web platforms. This article examines the architectural decisions in the source code that make Dear ImGui truly cross-platform.

## How Dear ImGui Achieves Cross-Platform Compatibility

### The Platform-Agnostic Core

The foundation of Dear ImGui's portability lies in its core implementation files: [`imgui.h`](https://github.com/ocornut/imgui/blob/main/imgui.h), [`imgui.cpp`](https://github.com/ocornut/imgui/blob/main/imgui.cpp), [`imgui_draw.cpp`](https://github.com/ocornut/imgui/blob/main/imgui_draw.cpp), and [`imgui_widgets.cpp`](https://github.com/ocornut/imgui/blob/main/imgui_widgets.cpp). These files contain **zero OS-specific code**—only abstract mathematics, data structures, and rendering primitives. According to the source analysis, the core library compiles under standard C++11 without making any system calls, ensuring it builds on any target architecture that supports modern C++.

### The Backend Architecture

All platform-specific functionality—window creation, input handling, clipboard access, mouse cursors, and gamepad support—resides in the `backends/` directory. This modular approach treats operating system APIs as **optional plug-ins** rather than dependencies. Each backend implements a uniform interface through functions like `ImGui_Impl*_*Init`, `ImGui_Impl*_*NewFrame`, and `ImGui_Impl*_*Render`, allowing you to swap implementations without modifying your UI code.

## Supported Platforms and Backend Options

The repository provides official backends for virtually every modern environment:

- **`imgui_impl_glfw.*`** – Cross-platform GLFW backend supporting Windows, macOS, Linux, BSD, Wayland, X11, and Emscripten. The header comment in [`backends/imgui_impl_glfw.cpp`](https://github.com/ocornut/imgui/blob/main/backends/imgui_impl_glfw.cpp) explicitly describes GLFW as "a cross-platform general purpose library" for windowing.
- **`imgui_impl_sdl2.*` / `imgui_impl_sdl3.*`** – SDL-based support covering Windows, macOS, Linux, Android, and iOS.
- **`imgui_impl_win32.*`** – Native Windows Win32 API implementation, including DirectX 9/10/11/12 variants.
- **`imgui_impl_opengl2.*` / `imgui_impl_opengl3.*`** – OpenGL renderers compatible with any platform providing an OpenGL context.
- **`imgui_impl_vulkan.*`** – Vulkan rendering backend for Windows, Linux, macOS (via MoltenVK), Android, and iOS.
- **`imgui_impl_wgpu.*`** – WebGPU support for web browsers and native applications.
- **`imgui_impl_null.*`** – Headless fallback for console applications requiring no OS services.

The `examples/` directory demonstrates these combinations in practice, with programs like `examples/example_glfw_opengl3` and `examples/example_win32_vulkan` showcasing identical UI code running on different stacks.

## Implementing Dear ImGui on Any Platform

To deploy Dear ImGui on a specific platform, you link the core library with your chosen backend. The following example uses the GLFW and OpenGL3 backends, but the UI code remains identical regardless of your selection:

```cpp
// Minimal Dear ImGui program – works on any platform with a backend
#include "imgui.h"
#include "imgui_impl_glfw.h"   // ← choose the backend you linked
#include "imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>

int main()
{
    // 1. Initialise windowing system (GLFW in this example)
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui Demo", nullptr, nullptr);
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1); // Enable vsync

    // 2. Initialise Dear ImGui core + backend
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO(); (void)io;
    ImGui::StyleColorsDark();

    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init("#version 130");

    // 3. Main loop
    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        ImGui_ImplGlfw_NewFrame();
        ImGui_ImplOpenGL3_NewFrame();
        ImGui::NewFrame();

        // UI code – same on every platform
        ImGui::Begin("Hello");
        ImGui::Text("This works on Windows, macOS, Linux, Android, iOS, Web…");
        ImGui::End();

        ImGui::Render();
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

        glfwSwapBuffers(window);
    }

    // 4. Cleanup
    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImGui::DestroyContext();
    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

```

Swapping the GLFW backend for SDL2 or Win32 requires only changing the include statements and initialization calls—the `ImGui::Begin()`, `ImGui::Text()`, and other UI calls remain unchanged across platforms.

## Summary

- **Dear ImGui is cross-platform by design**, with the core library ([`imgui.h`](https://github.com/ocornut/imgui/blob/main/imgui.h), [`imgui.cpp`](https://github.com/ocornut/imgui/blob/main/imgui.cpp)) containing no OS-specific dependencies.
- **Backend modules** in the `backends/` folder isolate platform quirks behind a consistent API, enabling support for Windows, macOS, Linux, BSD, Android, iOS, and web platforms.
- **Multiple backends can coexist**, allowing multi-viewport applications and mixed-API setups.
- The official documentation in [`docs/FAQ.md`](https://github.com/ocornut/imgui/blob/main/docs/FAQ.md) confirms Dear ImGui works on "any platform as long as you provide a backend."

## Frequently Asked Questions

### Does Dear ImGui work on mobile platforms like Android and iOS?

Yes. By using the `imgui_impl_sdl2.*` or `imgui_impl_sdl3.*` backends, or the Vulkan backend (`imgui_impl_vulkan.*`) with MoltenVK on iOS, Dear ImGui runs natively on mobile devices. The core library's platform-agnostic design ensures touch input and mobile-specific considerations are handled entirely within the backend layer.

### Can I use Dear ImGui with multiple rendering APIs simultaneously?

Yes. The architecture supports multiple active backends simultaneously, enabling advanced scenarios like multi-viewport applications where different windows use different graphics APIs. Each backend maintains its own state through the `ImGui_Impl*_*` function families, allowing Vulkan and OpenGL contexts to coexist in the same application.

### What is the minimum C++ standard required for Dear ImGui?

Dear ImGui requires **C++11** or later. The core source files use only standard C++ features available since C++11, ensuring broad compiler compatibility across GCC, Clang, MSVC, and embedded toolchains without requiring external dependencies.

### Is there a backend for web browsers using WebAssembly?

Yes. The `imgui_impl_glfw.*` backend supports Emscripten targets, allowing Dear ImGui to compile to WebAssembly and run in browsers via WebGL. Additionally, the `imgui_impl_wgpu.*` backend provides WebGPU support for modern web applications, demonstrating the library's versatility in web environments.