From 4a2e3cce69b2ef087949ae297d1a36a5f98a1058 Mon Sep 17 00:00:00 2001 From: Yan Pujante Date: Fri, 13 Mar 2026 08:58:12 -0700 Subject: [PATCH] Examples: SDL2+WebGPU: fixes hi-dpi handling. (#9300) --- docs/CHANGELOG.txt | 1 + examples/example_sdl2_wgpu/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 255d809b4..44c6175a1 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -136,6 +136,7 @@ Other Changes: to allocate one. (#8677) [@micb25] - WebGPU: fixed undefined behaviors in example code for requesting adapter and device. (#9246, #9256) [@r-lyeh] + - SDL2+WebGPU: fixed hi-dpi handling. (#9300) [@ypujante] - GLFW/SDL2/SDL3+WebGPU: removed suport for Emscripten <4.0.10. (#9281) [@ypujante] diff --git a/examples/example_sdl2_wgpu/main.cpp b/examples/example_sdl2_wgpu/main.cpp index b4c1be965..8d7c5a107 100644 --- a/examples/example_sdl2_wgpu/main.cpp +++ b/examples/example_sdl2_wgpu/main.cpp @@ -53,7 +53,7 @@ int main(int, char**) // Create window with graphics context float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0); - SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE; + SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+WebGPU example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, wgpu_surface_width, wgpu_surface_height, window_flags); if (window == nullptr) { @@ -143,7 +143,7 @@ int main(int, char**) // 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);