diff --git a/libs/imgui/backends/imgui_impl_glfw.cpp b/libs/imgui/backends/imgui_impl_glfw.cpp index 796bad7..2782cb0 100644 --- a/libs/imgui/backends/imgui_impl_glfw.cpp +++ b/libs/imgui/backends/imgui_impl_glfw.cpp @@ -169,7 +169,7 @@ bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); void ImGui_ImplGlfw_Shutdown(); -void ImGui_ImplGlfw_NewFrame(); +void ImGui_ImplGlfw_NewFrame(float scale_x, float scale_y); // GLFW callbacks install // - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any. @@ -993,7 +993,7 @@ static void ImGui_ImplGlfw_UpdateMonitors() } } -void ImGui_ImplGlfw_NewFrame() +extern "C" void ImGui_ImplGlfw_NewFrame(float scale_x,float scale_y) { ImGuiIO& io = ImGui::GetIO(); ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); @@ -1009,8 +1009,8 @@ void ImGui_ImplGlfw_NewFrame() io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h); // fix(zig-gamedev) - bd->DpiScale.x = ceil(io.DisplayFramebufferScale.x); - bd->DpiScale.y = ceil(io.DisplayFramebufferScale.y); + bd->DpiScale.x = scale_x; + bd->DpiScale.y = scale_y; if (bd->WantUpdateMonitors) ImGui_ImplGlfw_UpdateMonitors(); diff --git a/libs/imgui/backends/imgui_impl_glfw.h b/libs/imgui/backends/imgui_impl_glfw.h index 16930d1..0dd4192 100644 --- a/libs/imgui/backends/imgui_impl_glfw.h +++ b/libs/imgui/backends/imgui_impl_glfw.h @@ -33,7 +33,7 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool in IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); +IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(float scale_x, float scale_y); // Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL) #ifdef __EMSCRIPTEN__ diff --git a/src/backend_glfw.zig b/src/backend_glfw.zig index 2f830c1..865395a 100644 --- a/src/backend_glfw.zig +++ b/src/backend_glfw.zig @@ -31,8 +31,8 @@ pub fn deinit() void { ImGui_ImplGlfw_Shutdown(); } -pub fn newFrame() void { - ImGui_ImplGlfw_NewFrame(); +pub fn newFrame(scale_x: f32, scale_y: f32) void { + ImGui_ImplGlfw_NewFrame(scale_x, scale_y); } // Those functions are defined in `imgui_impl_glfw.cpp` @@ -40,5 +40,5 @@ pub fn newFrame() void { extern fn ImGui_ImplGlfw_InitForOther(window: *const anyopaque, install_callbacks: bool) bool; extern fn ImGui_ImplGlfw_InitForOpenGL(window: *const anyopaque, install_callbacks: bool) bool; extern fn ImGui_ImplGlfw_InitForVulkan(window: *const anyopaque, install_callbacks: bool) bool; -extern fn ImGui_ImplGlfw_NewFrame() void; +extern fn ImGui_ImplGlfw_NewFrame(scale_x: f32, scale_y: f32) void; extern fn ImGui_ImplGlfw_Shutdown() void; diff --git a/src/backend_glfw_opengl.zig b/src/backend_glfw_opengl.zig index cb94dc3..6425ad5 100644 --- a/src/backend_glfw_opengl.zig +++ b/src/backend_glfw_opengl.zig @@ -21,12 +21,12 @@ pub fn deinit() void { backend_glfw.deinit(); } -pub fn newFrame(fb_width: u32, fb_height: u32) void { - backend_glfw.newFrame(); +pub fn newFrame(fb_width: u32, fb_height: u32, scale_x: f32, scale_y: f32) void { + backend_glfw.newFrame(scale_x, scale_y); ImGui_ImplOpenGL3_NewFrame(); gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); - gui.io.setDisplayFramebufferScale(1.0, 1.0); + gui.io.setDisplayFramebufferScale(1, 1); gui.newFrame(); }