Renderer backends translate Dear ImGui's platform-agnostic draw commands (ImDrawData) into graphics API-specific calls. Each backend implements the same interface pattern, allowing applications to pair any platform backend (Platform Backends) with any renderer backend.
For specific backend implementations, see Vulkan Backend, DirectX Backends, OpenGL Backends, Metal Backend, WebGPU Backend, and SDL Renderer. For implementing custom backends, see Custom Backend Development.
All renderer backends follow a standardized lifecycle with four primary functions:
Renderer Backend Lifecycle
| Function | Purpose | Typical Operations |
|---|---|---|
ImGui_ImplXXX_Init() | Initialize backend resources | Create shaders, pipelines, samplers; set backend flags |
ImGui_ImplXXX_NewFrame() | Prepare for new frame | Recreate device objects if needed |
ImGui_ImplXXX_RenderDrawData() | Translate and submit draw commands | Update textures, upload buffers, execute draw calls |
ImGui_ImplXXX_Shutdown() | Clean up resources | Destroy GPU objects, clear backend data |
Sources: backends/imgui_impl_vulkan.cpp1-100 backends/imgui_impl_opengl3.cpp314-456 backends/imgui_impl_dx12.cpp1-60
Each backend stores its state in a backend-specific data structure allocated in io.BackendRendererUserData. This enables multi-context support.
Common Backend Data Pattern
The Vulkan backend maintains extensive state for descriptor management, pipeline creation, and texture handling:
All backends implement a GetBackendData() helper to retrieve this structure:
Sources: backends/imgui_impl_vulkan.cpp265-293 backends/imgui_impl_opengl3.cpp232-257 backends/imgui_impl_dx12.cpp91-122 backends/imgui_impl_dx11.cpp70-90
Backends advertise their capabilities through ImGuiBackendFlags set during initialization:
| Flag | Capability | Backends Supporting |
|---|---|---|
ImGuiBackendFlags_RendererHasVtxOffset | Support for large meshes (64k+ vertices with 16-bit indices) | Vulkan, DX9/10/11/12, OpenGL3, Metal, WebGPU |
ImGuiBackendFlags_RendererHasTextures | Dynamic texture management (v1.92+) | All modern backends |
Capability Detection Example
Sources: backends/imgui_impl_opengl3.cpp375-379 backends/imgui_impl_vulkan.cpp1-8 backends/imgui_impl_dx12.cpp1-8
The core responsibility of renderer backends is translating ImDrawData into GPU commands. This occurs in ImGui_ImplXXX_RenderDrawData().
Draw Data Processing Flow
All modern backends check for texture updates at the start of RenderDrawData():
This enables dynamic font atlas rebuilding and texture streaming without requiring explicit API calls from the application.
Sources: backends/imgui_impl_vulkan.cpp522-594 backends/imgui_impl_opengl3.cpp535-630 backends/imgui_impl_dx12.cpp224-365
Backends dynamically resize vertex and index buffers when draw data exceeds current capacity:
Buffer Resize Strategy
All backends merge draw lists into single contiguous buffers to minimize state changes:
Sources: backends/imgui_impl_dx11.cpp179-222 backends/imgui_impl_vulkan.cpp556-591 backends/imgui_impl_opengl3.cpp556-630
Since v1.92, backends implement dynamic texture management through the ImTextureData system. Each backend provides an UpdateTexture() function handling three states:
Texture Lifecycle States
Backends store additional data alongside the generic ImTextureData:
| Backend | Structure | Contents |
|---|---|---|
| Vulkan | ImGui_ImplVulkan_Texture | VkDeviceMemory, VkImage, VkImageView, VkDescriptorSet |
| DirectX 12 | ImGui_ImplDX12_Texture | ID3D12Resource*, CPU/GPU descriptor handles |
| DirectX 11 | ImGui_ImplDX11_Texture | ID3D11Texture2D*, ID3D11ShaderResourceView* |
| OpenGL | None | Uses GLuint directly as TexID |
| Metal | MetalTexture | id<MTLTexture> |
| WebGPU | ImGui_ImplWGPU_Texture | WGPUTexture, WGPUTextureView |
Example: Vulkan Texture Creation
Sources: backends/imgui_impl_vulkan.cpp677-898 backends/imgui_impl_dx12.cpp386-623 backends/imgui_impl_opengl3.cpp821-913
Backends set up graphics state for ImGui rendering, including projection matrices, viewport, blend modes, and samplers.
Render State Setup Components
All backends use the same projection matrix to map ImGui's coordinate space to normalized device coordinates:
ImGui requires alpha blending with separate RGB/alpha blend functions to preserve alpha in the output buffer:
Sources: backends/imgui_impl_dx11.cpp105-160 backends/imgui_impl_vulkan.cpp478-520 backends/imgui_impl_opengl3.cpp458-530
Backends expose render state through ImGui_ImplXXXX_RenderState structures accessible during draw callbacks via ImGui::GetPlatformIO().Renderer_RenderState.
RenderState Structure Pattern
The special ImDrawCallback_ResetRenderState callback requests the backend to reset all render state:
Sources: backends/imgui_impl_vulkan.cpp596-650 backends/imgui_impl_dx12.cpp315-364 backends/imgui_impl_opengl3.cpp600-630
| Backend | API Support | VtxOffset | Textures | Custom Shaders | Notes |
|---|---|---|---|---|---|
| Vulkan | 1.0+ | ✓ | ✓ | ✓ (v1.91.6+) | Descriptor pool management, dynamic rendering support |
| DirectX 12 | D3D12 | ✓ | ✓ | ✗ | Command list reuse, tearing support |
| DirectX 11 | D3D11 | ✓ | ✓ | ✗ | State backup/restore |
| DirectX 10 | D3D10 | ✓ | ✓ | ✗ | Similar to DX11 |
| DirectX 9 | D3D9 | ✓ | ✓ | ✗ | Fixed-function pipeline, BGRA support |
| OpenGL 3 | 2.0+ / ES 2.0+ | ✓ (3.2+) | ✓ | ✗ | Embedded loader, GLSL version detection |
| OpenGL 2 | Legacy | ✗ | ✓ | ✗ | Fixed-function only, not recommended |
| Metal | macOS/iOS | ✓ | ✓ | ✗ | Pipeline state caching, buffer pooling |
| WebGPU | Dawn/Emscripten | ✓ | ✓ | ✗ | WGSL shaders, bind group management |
| SDL_Renderer | SDL 2/3 | ✓ | ✓ | ✗ | Software/hardware rendering |
| SDL_GPU | SDL 3 | ✓ | ✓ | ✗ | Modern SDL graphics API |
Default Texture Sampler Settings (since 2024-10-07):
Sources: backends/imgui_impl_vulkan.cpp1-9 backends/imgui_impl_opengl3.cpp1-9 backends/imgui_impl_dx12.cpp1-9 backends/imgui_impl_metal.mm1-8 backends/imgui_impl_wgpu.cpp1-10
Core Backend Implementations:
Supporting Files:
Sources: backends/imgui_impl_vulkan.cpp1-100 backends/imgui_impl_opengl3.cpp1-100 backends/imgui_impl_dx12.cpp1-60 backends/imgui_impl_metal.mm1-40 backends/imgui_impl_wgpu.cpp1-50
Refresh this wiki