|
@@ -720,6 +720,7 @@ float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
|
|
return dpi / 96.0f;
|
|
|
#endif
|
|
|
#endif
|
|
|
+ IM_UNUSED(display_index);
|
|
|
return 1.0f;
|
|
|
}
|
|
|
|
|
@@ -825,29 +826,35 @@ static void ImGui_ImplSDL2_UpdateGamepads()
|
|
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
|
|
}
|
|
|
|
|
|
-void ImGui_ImplSDL2_NewFrame()
|
|
|
+static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window, SDL_Renderer* renderer, ImVec2* out_size, ImVec2* out_framebuffer_scale)
|
|
|
{
|
|
|
- ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
|
- IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
|
|
|
- ImGuiIO& io = ImGui::GetIO();
|
|
|
-
|
|
|
- // Setup display size (every frame to accommodate for window resizing)
|
|
|
int w, h;
|
|
|
int display_w, display_h;
|
|
|
- SDL_GetWindowSize(bd->Window, &w, &h);
|
|
|
- if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_MINIMIZED)
|
|
|
+ SDL_GetWindowSize(window, &w, &h);
|
|
|
+ if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
|
|
w = h = 0;
|
|
|
- if (bd->Renderer != nullptr)
|
|
|
- SDL_GetRendererOutputSize(bd->Renderer, &display_w, &display_h);
|
|
|
+ if (renderer != nullptr)
|
|
|
+ SDL_GetRendererOutputSize(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);
|
|
|
+ else if (SDL_GetWindowFlags(window) & SDL_WINDOW_VULKAN)
|
|
|
+ SDL_Vulkan_GetDrawableSize(window, &display_w, &display_h);
|
|
|
#endif
|
|
|
else
|
|
|
- SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
|
|
|
- io.DisplaySize = ImVec2((float)w, (float)h);
|
|
|
- if (w > 0 && h > 0)
|
|
|
- io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
|
|
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
|
|
+ if (out_size != nullptr)
|
|
|
+ *out_size = ImVec2((float)w, (float)h);
|
|
|
+ if (out_framebuffer_scale != nullptr)
|
|
|
+ *out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / w, (float)display_h / h) : ImVec2(1.0f, 1.0f);
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui_ImplSDL2_NewFrame()
|
|
|
+{
|
|
|
+ ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
|
+ IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
|
|
|
+ ImGuiIO& io = ImGui::GetIO();
|
|
|
+
|
|
|
+ // Setup main viewport size (every frame to accommodate for window resizing)
|
|
|
+ ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(bd->Window, bd->Renderer, &io.DisplaySize, &io.DisplayFramebufferScale);
|
|
|
|
|
|
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
|
|
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|