From 04f901b22427fbae03b1581a62e3acddcde04e65 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 15 Aug 2025 05:20:38 -0500 Subject: [PATCH] GUI: fix Wayland/macOS scaling do scaling in Furnace rather than in ImGui --- extern/imgui_patched/backends/imgui_impl_metal.mm | 6 +++--- .../imgui_patched/backends/imgui_impl_opengl3.cpp | 2 +- extern/imgui_patched/backends/imgui_impl_sdl2.cpp | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extern/imgui_patched/backends/imgui_impl_metal.mm b/extern/imgui_patched/backends/imgui_impl_metal.mm index 86c104b76..c63b7d1b6 100644 --- a/extern/imgui_patched/backends/imgui_impl_metal.mm +++ b/extern/imgui_patched/backends/imgui_impl_metal.mm @@ -109,9 +109,9 @@ bool ImGui_ImplMetal_Init(MTL::Device* device) return ImGui_ImplMetal_Init((__bridge id)(device)); } -bool ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor) +void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor) { - return ImGui_ImplMetal_NewFrame((__bridge MTLRenderPassDescriptor*)(renderPassDescriptor)); + ImGui_ImplMetal_NewFrame((__bridge MTLRenderPassDescriptor*)(renderPassDescriptor)); } void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, @@ -173,6 +173,7 @@ void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor) { ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); IM_ASSERT(bd != nil && "Context or backend not initialized! Did you call ImGui_ImplMetal_Init()?"); + // TODO: enable IMGUI_IMPL_METAL_CPP and get rid of this hack? IM_ASSERT(bd->SharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?"); if (bd->SharedMetalContext.framebufferDescriptor != nil) { [bd->SharedMetalContext.framebufferDescriptor release]; @@ -254,7 +255,6 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id id renderPipelineState = ctx.renderPipelineStateCache[ctx.framebufferDescriptor]; if (renderPipelineState == nil) { - printf("RPS NULL....\n"); // No luck; make a new render pipeline state renderPipelineState = [ctx renderPipelineStateForFramebufferDescriptor:ctx.framebufferDescriptor device:commandBuffer.device]; diff --git a/extern/imgui_patched/backends/imgui_impl_opengl3.cpp b/extern/imgui_patched/backends/imgui_impl_opengl3.cpp index cef19d7a2..f3665a110 100644 --- a/extern/imgui_patched/backends/imgui_impl_opengl3.cpp +++ b/extern/imgui_patched/backends/imgui_impl_opengl3.cpp @@ -138,7 +138,7 @@ #pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness #pragma clang diagnostic ignored "-Wunused-macros" // warning: macro is not used #pragma clang diagnostic ignored "-Wnonportable-system-include-path" -//#pragma clang diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader) +#pragma clang diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader) #endif #if defined(__GNUC__) #pragma GCC diagnostic push diff --git a/extern/imgui_patched/backends/imgui_impl_sdl2.cpp b/extern/imgui_patched/backends/imgui_impl_sdl2.cpp index 56962f93d..9ad5df9ea 100644 --- a/extern/imgui_patched/backends/imgui_impl_sdl2.cpp +++ b/extern/imgui_patched/backends/imgui_impl_sdl2.cpp @@ -1015,6 +1015,11 @@ static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window, // tildearrow: TODO: good idea? if (out_framebuffer_scale != nullptr && w > 0 && h > 0) *out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / w, (float)display_h / h) : ImVec2(1.0f, 1.0f); + + *out_w=w; + *out_h=h; + *out_display_w=display_w; + *out_display_h=display_h; } void ImGui_ImplSDL2_NewFrame() @@ -1030,7 +1035,6 @@ void ImGui_ImplSDL2_NewFrame() // Setup main viewport size (every frame to accommodate for window resizing) ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(bd->Window, bd->Renderer, &io.DisplaySize, &io.DisplayFramebufferScale, &w, &h, &display_w, &display_h); - // TODO: is this before, or after? // Update monitors #ifdef WIN32 @@ -1228,11 +1232,8 @@ static void ImGui_ImplSDL2_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) static ImVec2 ImGui_ImplSDL2_GetWindowFramebufferScale(ImGuiViewport* viewport) { - // FIXME: SDL_Renderer does not support multi-viewport. - ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData; - ImVec2 framebuffer_scale; - ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(vd->Window, nullptr, nullptr, &framebuffer_scale, NULL, NULL, NULL, NULL); - return framebuffer_scale; + // tildearrow: not here please. + return ImVec2(1.0f,1.0f); } static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* title)