Overview
Integrating Dear ImGui into an existing application typically involves:- Adding the core Dear ImGui files to your project
- Choosing and integrating platform and renderer backends
- Initializing Dear ImGui in your application startup
- Calling Dear ImGui functions in your main loop
- Rendering the Dear ImGui draw data
Most integrations take less than an hour when using existing backends. Custom backends require more time but are straightforward to implement.
Core files
The core Dear ImGui library is self-contained in these files (from the repository root):No build process required - just add these files to your existing project and compile them.
Choosing backends
Dear ImGui needs two types of backends:Platform backends
Handle windowing, input (mouse/keyboard/gamepad), and OS features:- imgui_impl_glfw.cpp - GLFW (cross-platform, recommended)
- imgui_impl_sdl2.cpp / imgui_impl_sdl3.cpp - SDL2/SDL3 (cross-platform)
- imgui_impl_win32.cpp - Win32 native API (Windows only)
- imgui_impl_osx.mm - macOS native API
- imgui_impl_android.cpp - Android native
- imgui_impl_glut.cpp - GLUT/FreeGLUT (legacy, not recommended)
Renderer backends
Handle texture creation and rendering Dear ImGui draw commands:- imgui_impl_opengl3.cpp - OpenGL 3/4, OpenGL ES 2/3, WebGL
- imgui_impl_opengl2.cpp - OpenGL 2 (legacy fixed pipeline)
- imgui_impl_dx11.cpp - DirectX 11
- imgui_impl_dx12.cpp - DirectX 12
- imgui_impl_dx9.cpp - DirectX 9
- imgui_impl_vulkan.cpp - Vulkan
- imgui_impl_metal.mm - Metal (macOS/iOS)
- imgui_impl_wgpu.cpp - WebGPU
- imgui_impl_sdlrenderer3.cpp - SDL_Renderer
- Recommended combos
- All backends
Integration steps
1
Add files to your project
Copy the core files and your chosen backends:Add these files to your build system (CMake, Make, Visual Studio project, etc.).
2
Include headers
In your application code:
3
Initialize at startup
After creating your window and graphics context:
4
Per-frame updates
At the start of your frame, before UI code:
5
Submit UI code
Anywhere in your main loop after
NewFrame():6
Render Dear ImGui
At the end of your frame, after your rendering:
7
Cleanup at shutdown
Before destroying your window:
Platform-specific examples
- GLFW + OpenGL3
- SDL2 + OpenGL3
- Win32 + DirectX11
- Win32 + DirectX12
Handling input
Dear ImGui needs to know when to capture input. Use these flags:Configuration options
Set these flags onImGuiIO after creating the context:
Loading fonts
Dear ImGui embeds a default font, but you can load custom fonts:Load fonts before the first frame. After adding fonts, they’re automatically uploaded to the GPU by the renderer backend.
Integration with game engines
Unreal Engine
Use the ImGui for Unreal Engine plugin.Unity
Use Dear ImGui for Unity package.Custom engines
For custom engines with their own abstraction layers:1
Start with standard backends
Use
imgui_impl_glfw.cpp + your graphics API backend to get running quickly.2
Evaluate if custom backend needed
In most cases, standard backends work fine even with engine abstractions.
3
Write custom backend if necessary
See the Backends documentation for implementation details.
Build system integration
- CMake
- Makefile
- Visual Studio
Common issues
Nothing renders / blank screen
Nothing renders / blank screen
- Verify you’re calling
ImGui_ImplXXX_NewFrame()for both backends - Verify you’re calling
ImGui::NewFrame()before UI code - Verify you’re calling
ImGui::Render()beforeRenderDrawData() - Check that your viewport/scissor state is correct
- Try calling
ImGui::ShowDemoWindow()to test
Widgets show squares instead of text
Widgets show squares instead of text
Font atlas texture wasn’t uploaded to GPU. The renderer backend should handle this automatically after the first frame.
Clipping issues / disappearing elements
Clipping issues / disappearing elements
Your renderer may not be handling scissor rectangles correctly. Check that you’re applying the scissor rect from
ImDrawCmd.Input not working
Input not working
- Verify platform backend
NewFrame()is called beforeImGui::NewFrame() - For SDL, ensure you’re calling
ImGui_ImplSDL2_ProcessEvent(&event) - For Win32, ensure your WndProc calls
ImGui_ImplWin32_WndProcHandler()
Crashes or asserts
Crashes or asserts
- Run
IMGUI_CHECKVERSION()at startup - Ensure you’re not mixing Debug/Release builds
- Check that all required backends are initialized
- Verify you’re not calling UI code before
NewFrame()
Next steps
API reference
Explore all available widgets and functions
Examples
See complete example applications
Custom backends
Learn to write your own platform/renderer backend
FAQ
Find answers to common questions