Where to Find Dear ImGui Backends for Different Platforms and APIs
All Dear ImGui backends for platforms and graphics APIs are located in the backends/ directory of the ocornut/imgui repository, following the naming convention imgui_impl_<name>.h and imgui_impl_<name>.cpp.
Dear ImGui is an immediate-mode graphical user interface library designed for integration with game engines and visual applications. The core library intentionally separates UI logic from platform-specific code, providing thin adapter backends that handle windowing, input, and rendering. This architecture allows developers to mix any windowing backend with any graphics API backend to target specific operating systems and hardware.
Locating the Official Backends in the Repository
All platform and graphics API integrations reside in the backends/ directory at the root of the repository. Each backend pair follows a strict naming convention:
- Platform backends:
imgui_impl_<platform>.h/imgui_impl_<platform>.cpp(or.mmfor Objective-C++) - Renderer backends:
imgui_impl_<api>.h/imgui_impl_<api>.cpp
For example, the Win32 platform implementation lives in backends/imgui_impl_win32.h and backends/imgui_impl_win32.cpp, while the OpenGL 3 renderer resides in backends/imgui_impl_opengl3.h and backends/imgui_impl_opengl3.cpp.
Understanding Backend Architecture
Dear ImGui backends function as translation layers that convert native window events into ImGui's IO structure and translate ImGui's draw lists into API-specific draw calls. Every backend implements four essential functions:
| Function | Purpose |
|---|---|
ImGui_ImplXXX_Init() |
Creates rendering contexts and initializes platform handles |
ImGui_ImplXXX_NewFrame() |
Gathers input events and prepares ImGui state for the new frame |
ImGui_ImplXXX_RenderDrawData() |
Translates ImGui draw commands into the target graphics API |
ImGui_ImplXXX_Shutdown() |
Releases allocated resources and cleans up |
Because backends contain no core ImGui logic, you can combine any platform backend (windowing) with any renderer backend (graphics API). This mix-and-match capability enables combinations like GLFW with DirectX or Win32 with OpenGL.
Available Platform Backends (Windowing)
The repository provides official platform integrations for major operating systems and windowing libraries:
-
Win32 –
backends/imgui_impl_win32.h/backends/imgui_impl_win32.cpp
Handles Windows messages, cursor management, clipboard operations, and high-DPI scaling. -
GLFW –
backends/imgui_impl_glfw.h/backends/imgui_impl_glfw.cpp
Wraps GLFW window and input callbacks for cross-platform desktop applications. -
SDL 2 –
backends/imgui_impl_sdl2.h/backends/imgui_impl_sdl2.cpp
Processes SDL2 events and window management. -
Android –
backends/imgui_impl_android.h/backends/imgui_impl_android.cpp
Integrates with the Android activity lifecycle and native app events.
Available Renderer Backends (Graphics APIs)
The graphics backend collection covers all major modern and legacy rendering APIs:
- OpenGL 2 –
backends/imgui_impl_opengl2.h/backends/imgui_impl_opengl2.cpp - OpenGL 3 –
backends/imgui_impl_opengl3.h/backends/imgui_impl_opengl3.cpp(supports GLSL 130+) - DirectX 9 –
backends/imgui_impl_dx9.h/backends/imgui_impl_dx9.cpp - DirectX 10 –
backends/imgui_impl_dx10.h/backends/imgui_impl_dx10.cpp - DirectX 11 –
backends/imgui_impl_dx11.h/backends/imgui_impl_dx11.cpp - DirectX 12 –
backends/imgui_impl_dx12.h/backends/imgui_impl_dx12.cpp - Vulkan –
backends/imgui_impl_vulkan.h/backends/imgui_impl_vulkan.cpp - Metal –
backends/imgui_impl_metal.h/backends/imgui_impl_metal.mm(Objective-C++)
For headless testing or data structure validation without rendering, use the Null backend (backends/imgui_impl_null.h / backends/imgui_impl_null.cpp).
Common Backend Combinations
Typical production configurations pair one platform file with one renderer file:
- Desktop Windows (Win32 + DirectX 11):
imgui_impl_win32.*+imgui_impl_dx11.* - Cross-Platform Desktop (GLFW + OpenGL 3):
imgui_impl_glfw.*+imgui_impl_opengl3.* - macOS/iOS (SDL2 + Metal):
imgui_impl_sdl2.*+imgui_impl_metal.* - Mobile Android (Android + OpenGL ES):
imgui_impl_android.*+imgui_impl_opengl3.*
Implementation Examples
GLFW and OpenGL 3 Integration
This example demonstrates a complete setup using the GLFW platform backend with the OpenGL 3 renderer:
#include "imgui.h"
#include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>
int main()
{
// Initialize window
glfwInit();
GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui Demo", nullptr, nullptr);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui::StyleColorsDark();
// Initialize backends
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 130");
// Main loop
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
// Start frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// UI code
ImGui::Begin("Hello");
ImGui::Text("Welcome to Dear ImGui!");
ImGui::End();
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
// Cleanup
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
Win32 and DirectX 11 Integration
For native Windows applications using DirectX 11, initialize both the Win32 platform backend and the DX11 renderer:
#include "imgui.h"
#include "backends/imgui_impl_win32.h"
#include "backends/imgui_impl_dx11.h"
#include <d3d11.h>
#include <tchar.h>
extern LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Create Win32 window and Direct3D 11 device (omitted for brevity)
HWND hWnd = /* ... */;
ID3D11Device* g_pd3dDevice = /* ... */;
ID3D11DeviceContext* g_pd3dDeviceContext = /* ... */;
IDXGISwapChain* g_pSwapChain = /* ... */;
ID3D11RenderTargetView* g_mainRenderTargetView = /* ... */;
// Setup ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui::StyleColorsDark();
// Initialize backends
ImGui_ImplWin32_Init(hWnd);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
// Main loop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
continue;
}
// New frame
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
// UI
ImGui::Begin("DX11 Demo");
ImGui::Text("Hello from DirectX 11!");
ImGui::End();
// Rendering
ImGui::Render();
const float clear_color[4] = { 0.45f, 0.55f, 0.60f, 1.00f };
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, nullptr);
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
g_pSwapChain->Present(1, 0);
}
// Cleanup
ImGui_ImplDX11_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
return 0;
}
// Forward declare message handler
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
return true;
return DefWindowProc(hWnd, msg, wParam, lParam);
}
Android and OpenGL ES Setup
For mobile Android applications, combine the Android platform backend with the OpenGL 3 backend configured for ES:
#include "imgui.h"
#include "backends/imgui_impl_android.h"
#include "backends/imgui_impl_opengl3.h"
#include <android/native_activity.h>
#include <GLES3/gl3.h>
void android_main(struct android_app* app)
{
// Setup EGL context (implementation omitted)
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui::StyleColorsDark();
// Initialize backends
ImGui_ImplAndroid_Init(app);
ImGui_ImplOpenGL3_Init("#version 300 es");
while (!app->destroyRequested)
{
// Poll Android events
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplAndroid_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Android Demo");
ImGui::Text("Running on Android!");
ImGui::End();
ImGui::Render();
glViewport(0, 0, display_w, display_h);
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
eglSwapBuffers(display, surface);
}
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplAndroid_Shutdown();
ImGui::DestroyContext();
}
Summary
- All Dear ImGui backends reside in the
backends/directory of the repository - Files follow the naming pattern
imgui_impl_<platform/api>.{h,cpp} - Platform backends handle windowing and input (Win32, GLFW, SDL2, Android)
- Renderer backends handle graphics API translation (OpenGL, DirectX, Vulkan, Metal)
- You can mix any platform backend with any renderer backend to create custom combinations
- Each backend implements
Init,NewFrame,RenderDrawData, andShutdownfunctions - The Null backend provides a no-op implementation for headless testing scenarios
Frequently Asked Questions
What is the difference between a platform backend and a renderer backend?
A platform backend manages operating system windowing, input events, and clipboard operations, while a renderer backend translates ImGui's draw lists into graphics API commands like OpenGL draw calls or DirectX rendering. Platform backends update the ImGuiIO structure with input data, whereas renderer backends consume ImGui's ImDrawData to output pixels.
Can I mix different platform and renderer backends?
Yes. Dear ImGui's architecture explicitly supports mixing any platform backend with any renderer backend. For example, you can use the GLFW platform backend (for cross-platform windowing) with the DirectX 11 renderer backend, or the Win32 platform backend with the OpenGL 3 renderer. This flexibility allows integration with existing engine architectures regardless of their windowing or graphics choices.
How do I create a custom backend for a new platform?
Create a new file pair following the naming convention imgui_impl_<yourplatform>.h/cpp and implement the four standard functions: ImGui_ImplXXX_Init, ImGui_ImplXXX_NewFrame, ImGui_ImplXXX_RenderDrawData, and ImGui_ImplXXX_Shutdown. Reference existing implementations like imgui_impl_glfw.cpp or imgui_impl_win32.cpp to understand how to populate the ImGuiIO structure with input data and how to iterate through ImDrawCmd lists for rendering.
Are there backends for web platforms like WASM or Emscripten?
While the official repository does not provide dedicated Emscripten backends in the backends/ folder, the existing GLFW and SDL2 backends work with Emscripten when compiled with -s USE_GLFW=3 or -s USE_SDL=2. The OpenGL 3 backend functions correctly with WebGL 2.0 contexts in browser environments, making these combinations the standard approach for Dear ImGui web deployments.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →