From dde31030e9fea67a848180f328986f2db79464f7 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Oct 2021 15:07:43 +0200 Subject: [PATCH] Backends: SDL_Renderer: use SDL_RenderIsClipEnabled() to pass NULL to SDL_RenderSetClipRect (#3926, #4582, #4633) --- backends/imgui_impl_sdlrenderer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_sdlrenderer.cpp b/backends/imgui_impl_sdlrenderer.cpp index ff163113..bfc2b676 100644 --- a/backends/imgui_impl_sdlrenderer.cpp +++ b/backends/imgui_impl_sdlrenderer.cpp @@ -120,9 +120,11 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data) struct BackupSDLRendererState { SDL_Rect Viewport; + bool ClipEnabled; SDL_Rect ClipRect; }; BackupSDLRendererState old = {}; + old.ClipEnabled = SDL_RenderIsClipEnabled(bd->SDLRenderer); SDL_RenderGetViewport(bd->SDLRenderer, &old.Viewport); SDL_RenderGetClipRect(bd->SDLRenderer, &old.ClipRect); @@ -183,7 +185,7 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data) // Restore modified SDL_Renderer state SDL_RenderSetViewport(bd->SDLRenderer, &old.Viewport); - SDL_RenderSetClipRect(bd->SDLRenderer, &old.ClipRect); + SDL_RenderSetClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : NULL); } // Called by Init/NewFrame/Shutdown