Overview
Platform backends handle the interface between Dear ImGui and the operating system. They are responsible for:- Creating and managing windows
- Processing mouse, keyboard, and gamepad input
- Managing clipboard operations
- Handling timing and frame synchronization
- Changing mouse cursor shapes
- Multi-viewport support (docking branch)
Platform backends must be paired with a Renderer Backend to display graphics.
Available Platform Backends
GLFW Backend
File:imgui_impl_glfw.cpp / imgui_impl_glfw.h
Best for cross-platform desktop applications
GLFW is a modern, lightweight library for window creation and input handling. It’s the recommended choice for most desktop applications.
Features
- ✅ Clipboard support
- ✅ Mouse support (can discriminate Mouse/TouchScreen/Pen on Windows)
- ✅ Keyboard support
- ✅ Gamepad support
- ✅ Mouse cursor shapes (requires GLFW 3.4+ for resizing cursors)
- ✅ Multiple Dear ImGui contexts
Supported Platforms
- Windows
- macOS
- Linux (X11 and Wayland)
Basic Usage
Initialization Functions
Callback Management
If you setinstall_callbacks=true, the backend automatically installs GLFW callbacks. If you need custom callbacks:
Helper Functions
SDL2 Backend
File:imgui_impl_sdl2.cpp / imgui_impl_sdl2.h
Excellent for cross-platform and mobile
SDL2 is a mature, battle-tested library with excellent mobile support and a large community.
Features
- ✅ Clipboard support
- ✅ Mouse support (can discriminate Mouse/TouchScreen)
- ✅ Keyboard support
- ✅ Gamepad support
- ✅ Mouse cursor shapes
- ✅ Basic IME support
Supported Platforms
- Windows
- macOS
- Linux
- iOS
- Android
Basic Usage
Initialization Functions
Event Processing
SDL3 Backend
File:imgui_impl_sdl3.cpp / imgui_impl_sdl3.h
Recommended for new projects
SDL3 is the latest version with improved API design and better performance. Use this for new projects.
Win32 Backend
File:imgui_impl_win32.cpp / imgui_impl_win32.h
Best for Windows-only applications
The Win32 backend provides the best Windows integration, including proper multi-viewport support.
Features
- ✅ Clipboard support (built into Dear ImGui core)
- ✅ Mouse support (can discriminate Mouse/TouchScreen/Pen)
- ✅ Keyboard support
- ✅ Gamepad support (via XInput)
- ✅ Mouse cursor shapes
- ✅ Excellent multi-viewport support
Basic Usage
Helper Functions
macOS Backend
File:imgui_impl_osx.mm / imgui_impl_osx.h
Native macOS integration
Provides native macOS Cocoa integration. Less feature-complete than GLFW/SDL backends.
For most macOS applications, using GLFW or SDL2/SDL3 backends is recommended as they offer better cross-platform compatibility and more features.
Android Backend
File:imgui_impl_android.cpp / imgui_impl_android.h
Provides integration with Android’s native app API. Typically used with OpenGL ES renderer backend.
Platform Backend Lifecycle
All platform backends follow this lifecycle:1
Initialization
Call The backend sets up:
ImGui_ImplXXX_Init() with platform-specific parameters:io.BackendPlatformNameio.BackendFlags- Input handlers
- Clipboard handlers
2
Per-Frame Updates
Call The backend updates:
ImGui_ImplXXX_NewFrame() at the start of each frame:io.DeltaTimeio.DisplaySize- Mouse cursor shape
- Input states
3
Event Processing
Some backends require explicit event forwarding:
4
Shutdown
Call
ImGui_ImplXXX_Shutdown() before destroying the context:Common Configuration
Enable Gamepad Support
Disable Mouse Cursor Changes
Enable DPI Awareness
Next Steps
Renderer Backends
Learn about renderer backends for graphics APIs
Custom Backend
Create your own platform backend