GUI: fix Wayland/macOS scaling

do scaling in Furnace rather than in ImGui
This commit is contained in:
tildearrow 2025-08-15 05:20:38 -05:00
parent 4cd105c6b2
commit 04f901b224
3 changed files with 11 additions and 10 deletions

View file

@ -109,9 +109,9 @@ bool ImGui_ImplMetal_Init(MTL::Device* device)
return ImGui_ImplMetal_Init((__bridge id<MTLDevice>)(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<MTLCommandBuffer>
id<MTLRenderPipelineState> 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];

View file

@ -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

View file

@ -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)