diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index af0291421..ea5886cc8 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -46,7 +46,7 @@ #include #define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4) #define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4) -#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5) +#define SDL_HAS_WINDOW_ALPHA SDL_VERSION_ATLEAST(2,0,5) #define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5) #define SDL_HAS_USABLE_DISPLAY_BOUNDS SDL_VERSION_ATLEAST(2,0,5) #define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4) @@ -463,6 +463,14 @@ static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* t SDL_SetWindowTitle(data->Window, title); } +#if SDL_HAS_WINDOW_ALPHA +static void ImGui_ImplSDL2_SetWindowAlpha(ImGuiViewport* viewport, float alpha) +{ + ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData; + SDL_SetWindowOpacity(data->Window, alpha); +} +#endif + static void ImGui_ImplSDL2_SetWindowFocus(ImGuiViewport* viewport) { ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData; @@ -556,6 +564,9 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle; platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow; platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers; +#if SDL_HAS_WINDOW_ALPHA + platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL2_SetWindowAlpha; +#endif #if SDL_HAS_VULKAN platform_io.Platform_CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface; #endif