Skip to main content

What are Backends?

Dear ImGui is highly portable and only requires a few things to run and render. The backend system separates platform-specific code from the core library, making it easy to integrate Dear ImGui into any application.

Core Requirements

Dear ImGui backends handle these essential tasks:
  • Input handling: Mouse, keyboard, gamepad, and touch events
  • Texture management: Creating, updating, and destroying textures
  • Rendering: Drawing indexed textured triangles with clipping rectangles

Optional Features

Backends can also support advanced features:
  • Custom texture binding
  • Clipboard support
  • Gamepad support
  • Mouse cursor shapes
  • IME (Input Method Editor) support
  • Multi-viewport support

Backend Architecture

Dear ImGui uses a two-backend system that separates concerns:

Platform Backend

Handles windowing, input events, timing, and OS integration

Renderer Backend

Handles graphics API calls, texture management, and drawing

Why Two Backends?

This separation provides flexibility:
  • Mix and match platforms with renderers (e.g., GLFW + OpenGL, SDL2 + Vulkan, Win32 + DirectX11)
  • Reuse platform code across different graphics APIs
  • Easier to maintain and debug
  • Better portability across systems
An application typically combines one Platform backend + one Renderer backend + the main Dear ImGui library.

Available Backends

Platform Backends

These handle windowing and input:
BackendPlatformFeatures
imgui_impl_glfw.cppWindows, macOS, LinuxCross-platform, modern, recommended
imgui_impl_sdl2.cppWindows, macOS, Linux, iOS, AndroidCross-platform, stable
imgui_impl_sdl3.cppWindows, macOS, Linux, iOS, AndroidLatest SDL, recommended for new projects
imgui_impl_win32.cppWindowsNative Windows API, best for Windows-only apps
imgui_impl_osx.mmmacOSNative macOS API
imgui_impl_android.cppAndroidAndroid native app API
imgui_impl_glut.cppCross-platformLegacy, not recommended

Renderer Backends

These handle graphics API calls:
BackendGraphics APIFeatures
imgui_impl_opengl3.cppOpenGL 3/4, OpenGL ES 2/3, WebGLModern OpenGL with shaders
imgui_impl_opengl2.cppOpenGL 2Legacy fixed pipeline, not recommended
imgui_impl_vulkan.cppVulkanModern, explicit graphics API
imgui_impl_dx9.cppDirectX 9Legacy DirectX
imgui_impl_dx10.cppDirectX 10DirectX 10
imgui_impl_dx11.cppDirectX 11Modern DirectX, widely used
imgui_impl_dx12.cppDirectX 12Modern, explicit DirectX API
imgui_impl_metal.mmMetalApple’s modern graphics API
imgui_impl_wgpu.cppWebGPUWeb + desktop, next-gen graphics API
imgui_impl_sdlgpu3.cppSDL_GPUSDL3’s portable 3D graphics API
imgui_impl_sdlrenderer2.cppSDL_RendererSDL2’s 2D renderer
imgui_impl_sdlrenderer3.cppSDL_RendererSDL3’s 2D renderer

High-Level Framework Backends

Some backends combine platform and renderer:
  • imgui_impl_allegro5.cpp - Allegro 5 game library
  • imgui_impl_null.cpp - Null backend for testing
For new cross-platform projects:

SDL3 + OpenGL3

Best for most projectsModern, stable, cross-platform
ImGui_ImplSDL3_InitForOpenGL(window);
ImGui_ImplOpenGL3_Init(glsl_version);

GLFW + Vulkan

Best for high-performance appsModern, explicit control
ImGui_ImplGlfw_InitForVulkan(window, true);
ImGui_ImplVulkan_Init(&init_info);
For Windows-only applications:

Win32 + DirectX11

The Win32 backend handles Windows-specific features better than cross-platform alternatives, including multi-viewport support.
ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(device, device_context);

Basic Integration Pattern

Here’s the typical flow for integrating Dear ImGui:
1

Initialize Platform Backend

Create your window and initialize the platform backend:
// Create window (platform-specific)
GLFWwindow* window = glfwCreateWindow(1280, 720, "App", NULL, NULL);

// Initialize Dear ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();

// Initialize platform backend
ImGui_ImplGlfw_InitForOpenGL(window, true);
2

Initialize Renderer Backend

Initialize the renderer backend with graphics API context:
// Initialize renderer backend
ImGui_ImplOpenGL3_Init("#version 330");
3

Main Loop

In your render loop, call NewFrame for both backends:
while (!glfwWindowShouldClose(window)) {
    glfwPollEvents();
    
    // Start Dear ImGui frame
    ImGui_ImplOpenGL3_NewFrame();
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();
    
    // Your Dear ImGui code here
    ImGui::ShowDemoWindow();
    
    // Rendering
    ImGui::Render();
    glClear(GL_COLOR_BUFFER_BIT);
    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
    glfwSwapBuffers(window);
}
4

Cleanup

Shutdown backends in reverse order:
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();

Backend Flags

Backends advertise their capabilities through ImGuiBackendFlags:
struct ImGuiIO {
    ImGuiBackendFlags BackendFlags; // Set by backend
    // ...
};

Platform Backend Flags

FlagDescription
ImGuiBackendFlags_HasGamepadSupports gamepad input
ImGuiBackendFlags_HasMouseCursorsCan change OS cursor shape
ImGuiBackendFlags_HasSetMousePosCan reposition OS mouse
ImGuiBackendFlags_PlatformHasViewportsSupports multi-viewports
ImGuiBackendFlags_HasMouseHoveredViewportCan detect viewport under mouse

Renderer Backend Flags

FlagDescription
ImGuiBackendFlags_RendererHasVtxOffsetSupports large meshes (64k+ vertices)
ImGuiBackendFlags_RendererHasTexturesSupports dynamic texture updates
Starting with Dear ImGui 1.92.0 (June 2025), support for ImGuiBackendFlags_RendererHasTextures is required for all backends to enable dynamic font scaling and other new features.

Emscripten / WebAssembly Support

Several backends support compiling to WebAssembly:
  • SDL2/SDL3 + OpenGL3
  • GLFW + OpenGL3
  • GLFW + WebGPU
These examples are ready to build and run with Emscripten.

Next Steps

Platform Backends

Learn about platform backends for windowing and input

Renderer Backends

Learn about renderer backends for graphics APIs

Custom Backend

Create your own custom backend

Examples

See complete integration examples

Build docs developers (and LLMs) love