From c66d9a8190eb5bd0e1cfeff9ebdb0b01747c9175 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 29 Jun 2026 11:49:06 +0200 Subject: [PATCH] Examples, SDL2/SDL3: use SDL_GetWindowSizeInPixels() to create framebuffers. (#8761, #9124) + cc #7433 --- docs/CHANGELOG.txt | 4 +++- examples/example_sdl2_vulkan/main.cpp | 4 ++-- examples/example_sdl3_vulkan/main.cpp | 4 ++-- examples/example_sdl3_wgpu/main.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index c90713b14..12c359693 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -127,7 +127,9 @@ Other Changes: - Uses `SetProcessDpiAwarenessContext()` instead of `SetThreadDpiAwarenessContext()` when available, fixing OpenGL DPI scaling issues as e.g. NVIDIA drivers tends to spawn multiple-thread to manage OpenGL. (#9403) - +- Examples: + - SDL2/SDL3: use `SDL_GetWindowSizeInPixels()` to create frame-buffers. Fixes issues + with non-fractional framebuffer size on Wayland. (#8761, #9124) [@billtran1632001] ----------------------------------------------------------------------- VERSION 1.92.8 (Released 2026-05-12) diff --git a/examples/example_sdl2_vulkan/main.cpp b/examples/example_sdl2_vulkan/main.cpp index 131712927..45a5a6de5 100644 --- a/examples/example_sdl2_vulkan/main.cpp +++ b/examples/example_sdl2_vulkan/main.cpp @@ -386,7 +386,7 @@ int main(int, char**) // Create Framebuffers int w, h; - SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowSizeInPixels(window, &w, &h); ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; SetupVulkanWindow(wd, surface, w, h); @@ -475,7 +475,7 @@ int main(int, char**) // Resize swap chain? int fb_width, fb_height; - SDL_GetWindowSize(window, &fb_width, &fb_height); + SDL_GetWindowSizeInPixels(window, &fb_width, &fb_height); if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height)) { ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); diff --git a/examples/example_sdl3_vulkan/main.cpp b/examples/example_sdl3_vulkan/main.cpp index 04d17ba70..0073b37c5 100644 --- a/examples/example_sdl3_vulkan/main.cpp +++ b/examples/example_sdl3_vulkan/main.cpp @@ -383,7 +383,7 @@ int main(int, char**) // Create Framebuffers int w, h; - SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowSizeInPixels(window, &w, &h); ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; SetupVulkanWindow(wd, surface, w, h); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); @@ -477,7 +477,7 @@ int main(int, char**) // Resize swap chain? int fb_width, fb_height; - SDL_GetWindowSize(window, &fb_width, &fb_height); + SDL_GetWindowSizeInPixels(window, &fb_width, &fb_height); if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height)) { ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); diff --git a/examples/example_sdl3_wgpu/main.cpp b/examples/example_sdl3_wgpu/main.cpp index 4aee4ef6a..bc1787829 100644 --- a/examples/example_sdl3_wgpu/main.cpp +++ b/examples/example_sdl3_wgpu/main.cpp @@ -155,7 +155,7 @@ int main(int, char**) // [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppIterate() function] // React to changes in screen size int width, height; - SDL_GetWindowSize(window, &width, &height); + SDL_GetWindowSizeInPixels(window, &width, &height); if (width != wgpu_surface_width || height != wgpu_surface_height) ResizeSurface(width, height);