Skip to content

Commit

Permalink
Backends: SDL2: use SDL_Vulkan_GetDrawableSize with Vulkan instead of…
Browse files Browse the repository at this point in the history
… SDL_GL_GetDrawableSize. (#7967, #3190)
  • Loading branch information
scribam authored and ocornut committed Sep 9, 2024
1 parent 15cb7d6 commit 4236bc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-09-09: use SDL_Vulkan_GetDrawableSize() when available. (#7967, #3190)
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
Expand Down Expand Up @@ -112,6 +113,9 @@
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
#endif
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
#if SDL_HAS_VULKAN
extern "C" { extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window* window, int* w, int* h); }
#endif

// SDL Data
struct ImGui_ImplSDL2_Data
Expand Down Expand Up @@ -760,6 +764,10 @@ void ImGui_ImplSDL2_NewFrame()
w = h = 0;
if (bd->Renderer != nullptr)
SDL_GetRendererOutputSize(bd->Renderer, &display_w, &display_h);
#if SDL_HAS_VULKAN
else if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_VULKAN)
SDL_Vulkan_GetDrawableSize(bd->Window, &display_w, &display_h);
#endif
else
SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
io.DisplaySize = ImVec2((float)w, (float)h);
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Other changes:
- Nav: pressing any keyboard key while holding Alt disable toggling nav layer on Alt release. (#4439)
- InputText: added CJK double-width punctuation to list of separators considered for CTRL+Arrow.
- TextLinkOpenURL(): modified tooltip to display a verb "Open 'xxxx'". (#7885, #7660)
- Backends: SDL2: use SDL_Vulkan_GetDrawableSize() when available. (#7967, #3190) [@scribam]

-----------------------------------------------------------------------
VERSION 1.91.1 (Released 2024-09-04)
Expand Down

1 comment on commit 4236bc0

@digitall
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scribam @ocornut : Line 117 i.e. the C linkage extern declaration of SDL_Vulkan_GetDrawableSize() causes a redundant redeclaration GCC compiler warning in our project, though removing it caused a link failure. This was fixed by including the SDL2_vulkan header instead. Please see scummvm/scummvm@3cbd38b and applying the same patch if you think this is acceptable. Thanks for the work on ImGUI.

Please sign in to comment.