Overview
Theexamples/ folder contains standalone, ready-to-build example applications for a variety of platforms and graphics APIs. These examples demonstrate how to integrate Dear ImGui with different backends and serve as starting points for your own projects.
Integration in a typical existing application takes fewer than 20 lines when using standard backends.
Getting Started
All examples use standard backends from thebackends/ folder. Here’s the basic integration pattern:
Demo Window
Available Examples
Desktop - OpenGL
GLFW + OpenGL3
Platform: Windows, macOS, LinuxFiles:
main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cppModern programmable pipeline with shader support. Supports Emscripten/WebGL compilation.Recommended for: Modern OpenGL applicationsGLFW + OpenGL2
Platform: Windows, macOS, LinuxFiles:
main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cppLegacy fixed pipeline.⚠️ Not recommended for modern GL or WebGL applicationsSDL2 + OpenGL3
Platform: Windows, macOS, Linux, etc.Files:
main.cpp + imgui_impl_sdl2.cpp + imgui_impl_opengl3.cppModern programmable pipeline. Supports Emscripten/WebGL.SDL3 + OpenGL3
Platform: Windows, macOS, Linux, etc.Files:
main.cpp + imgui_impl_sdl3.cpp + imgui_impl_opengl3.cppLatest SDL3 with modern OpenGL.Desktop - DirectX (Windows)
Win32 + DirectX11
Platform: Windows onlyFiles:
main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cppDirectX 11 renderer with native Win32 window.Win32 + DirectX12
Platform: Windows onlyFiles:
main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cppDirectX 12 renderer (long and tedious because: DirectX12).SDL2 + DirectX11
Platform: Windows onlyFiles:
main.cpp + imgui_impl_sdl2.cpp + imgui_impl_dx11.cppDemonstrates DirectX usage with SDL2.Win32 + DirectX9
Platform: Windows onlyFiles:
main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cppLegacy DirectX 9 support.Desktop - Vulkan
GLFW + Vulkan
Platform: Windows, macOS, LinuxFiles:
main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cppVulkan API example (quite long because: Vulkan). Uses helper functions from imgui_impl_vulkan.SDL2 + Vulkan
Platform: Windows, macOS, LinuxFiles:
main.cpp + imgui_impl_sdl2.cpp + imgui_impl_vulkan.cppSDL2 with Vulkan renderer.Win32 + Vulkan
Platform: WindowsFiles:
main.cpp + imgui_impl_win32.cpp + imgui_impl_vulkan.cppNative Win32 window with Vulkan.SDL3 + Vulkan
Platform: Windows, macOS, LinuxFiles:
main.cpp + imgui_impl_sdl3.cpp + imgui_impl_vulkan.cppLatest SDL3 with Vulkan renderer.Desktop - Metal (Apple)
Apple Metal
Platform: macOS, iOSFiles:
main.m + imgui_impl_osx.mm + imgui_impl_metal.mmBased on Xcode 9+ “cross-platform” game template.GLFW + Metal
Platform: macOSFiles:
main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mmGLFW with Metal renderer for macOS.SDL2 + Metal
Platform: macOSFiles:
main.mm + imgui_impl_sdl2.cpp + imgui_impl_metal.mmSDL2 with Metal renderer for macOS.SDL3 + Metal
Platform: macOSFiles:
main.cpp + imgui_impl_sdl3.cpp + imgui_impl_metal.mmLatest SDL3 with Metal renderer.Desktop - WebGPU
GLFW + WebGPU
Platform: Emscripten (web), Dawn (native), WGPU (native)Files:
main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cppModern WebGPU API support.SDL2 + WebGPU
Platform: Emscripten (web), Dawn (native), WGPU (native)Files:
main.cpp + imgui_impl_sdl2.cpp + imgui_impl_wgpu.cppSDL2 with WebGPU support.Desktop - Other
GLUT + OpenGL2
GLUT + OpenGL2
Platform: Linux/Windows (FreeGLUT), macOS (GLUT framework)Files:
main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cppAllegro 5
Allegro 5
Platform: Cross-platformFiles:
main.cpp + imgui_impl_allegro5.cppAllegro 5 game programming library.Null Backend
Null Backend
Platform: AnyFiles:
main.cpp + imgui_impl_null.cppHeadless example with no graphics output. Used for testing compilation. The null backend is intentionally minimal.Mobile
Android + OpenGL3
Android + OpenGL3
Platform: AndroidFiles:
main.cpp + imgui_impl_android.cpp + imgui_impl_opengl3.cppAndroid application with OpenGL ES support.SDL Renderer
SDL2 + SDL_Renderer
Files:
main.cpp + imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cppUses SDL’s built-in 2D renderer. Requires SDL 2.0.18+ (November 2021).SDL3 + SDL_Renderer
Files:
main.cpp + imgui_impl_sdl3.cpp + imgui_impl_sdlrenderer3.cppLatest SDL3 with built-in renderer.SDL3 + SDL_GPU
Files:
main.cpp + imgui_impl_sdl3.cpp + imgui_impl_sdlgpu3.cppSDL3 with new GPU API.Building Examples
Most examples provide:- Makefiles for Linux/macOS
- Batch files for Visual Studio 2008+
- Solution files (.sln) for Visual Studio 2012+
- Xcode projects for Apple platforms
You can also import
imgui_impl_xxx.cpp/.h files directly into your codebase or compile them with command-line tools.CMake Support
While official examples don’t use CMake, community CMake support is available:Binary Downloads
Windows binaries for some examples are available at:Integration Resources
- Read the Getting Started guide on the Wiki
- Read
docs/BACKENDS.mdor online at https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md - Read
PROGRAMMER GUIDEsection inimgui.cpp - Read the comments at the top of each backend file
- Study the example code that matches your target platform
Mouse Cursor Latency
Dear ImGui doesn’t introduce significant extra lag for most behaviors. At 60 FPS, your experience should be pleasant.About Hardware vs Software Cursors
About Hardware vs Software Cursors
OS mouse cursors are typically rendered through hardware-accelerated paths, making them feel smoother than content rendered via regular graphics APIs. This disconnect may be noticeable to sensitive users.You can experiment with
io.MouseDrawCursor = true to request Dear ImGui draw a cursor using the graphics API. However, rendering at 60 FPS will feel sluggish.Consider switching to a software cursor only during interactive drags.Learning from Examples
Example Structure
Most examples follow this pattern:Tips for Choosing an Example
For Modern Applications
Choose OpenGL3, DirectX11/12, Vulkan, or Metal examples. These use modern programmable pipelines.
For Web Applications
Use GLFW + OpenGL3 or SDL2 + OpenGL3 examples with Emscripten compilation.
For Quick Prototyping
Start with GLFW + OpenGL3 or SDL2 + OpenGL3. They’re well-documented and widely supported.
For Game Engines
Choose the example matching your engine’s rendering API (DirectX, Vulkan, Metal, etc.).
Next Steps
- Choose an example matching your platform and graphics API
- Build and run the example to see Dear ImGui in action
- Study the code to understand the integration pattern
- Modify the example to experiment with Dear ImGui features
- Integrate into your project using the example as a template
See Also
- Troubleshooting - Common issues and solutions
- Best Practices - Recommended patterns and practices
- Fonts - Loading and using custom fonts
- BACKENDS.md - Backend implementation details