From faa7dad537b81044fedd4691c6806d943913da58 Mon Sep 17 00:00:00 2001 From: Marcel Smit Date: Mon, 30 Jul 2018 14:15:24 +0200 Subject: [PATCH] Examples: imgui_impl_osx: Fix for incorrect DeltaTime calculation on mac OS. (#1978) --- examples/imgui_impl_osx.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index cd242149..07494d6d 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -15,7 +15,7 @@ // 2018-07-07: Initial version. // Data -static clock_t g_Time = 0; +static CFAbsoluteTime g_Time = 0.0; // Functions bool ImGui_ImplOSX_Init() @@ -94,10 +94,10 @@ void ImGui_ImplOSX_NewFrame(NSView* view) io.DisplayFramebufferScale = ImVec2(dpi, dpi); // Setup time step - if (g_Time == 0) - g_Time = clock(); - clock_t current_time = clock(); - io.DeltaTime = (double)(current_time - g_Time) / CLOCKS_PER_SEC; + if (g_Time == 0.0) + g_Time = CFAbsoluteTimeGetCurrent(); + CFAbsoluteTime current_time = CFAbsoluteTimeGetCurrent(); + io.DeltaTime = current_time - g_Time; g_Time = current_time; }