From b3c5626b1ff0b64b6c09e798087bf3d445b15104 Mon Sep 17 00:00:00 2001 From: moonpower Date: Fri, 26 Dec 2025 02:48:40 +0100 Subject: [PATCH] Backends: Initialize and shutdown renderer backend for SDL_Surface --- backends/imgui_impl_sdlsurface2.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backends/imgui_impl_sdlsurface2.cpp b/backends/imgui_impl_sdlsurface2.cpp index 75092fe4b..5ee9ead66 100644 --- a/backends/imgui_impl_sdlsurface2.cpp +++ b/backends/imgui_impl_sdlsurface2.cpp @@ -119,6 +119,12 @@ SDL_Surface* ImGui_ImplSDLSurface2_CreateFontAtlasSurface() bool ImGui_ImplSDLSurface2_Init(SDL_Surface* surface) { if (!surface) return false; + + ImGuiIO& io = ImGui::GetIO(); + IM_ASSERT(io.BackendRendererName == nullptr && "Already initialized a renderer backend!"); + io.BackendRendererName = "imgui_impl_sdlsurface2"; + io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; + g_TargetSurface = surface; g_FontSurface = ImGui_ImplSDLSurface2_CreateFontAtlasSurface(); if (g_FontSurface) @@ -139,6 +145,10 @@ bool ImGui_ImplSDLSurface2_Init(SDL_Surface* surface) void ImGui_ImplSDLSurface2_Shutdown() { + ImGuiIO& io = ImGui::GetIO(); + io.BackendRendererName = nullptr; + io.BackendFlags &= ~ImGuiBackendFlags_RendererHasTextures; + ImGui::GetIO().Fonts->TexID = nullptr; if (g_FontSurface) {