diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index a035caf62..2fbae8fdf 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -1205,10 +1205,11 @@ pub const Inspector = struct { // Determine our delta time const now = try std.time.Instant.now(); io.DeltaTime = if (self.instant) |prev| delta: { - const since_ns = now.since(prev); - const since_s: f32 = @floatFromInt(since_ns / std.time.ns_per_s); + const since_ns: f64 = @floatFromInt(now.since(prev)); + const ns_per_s: f64 = @floatFromInt(std.time.ns_per_s); + const since_s: f32 = @floatCast(since_ns / ns_per_s); break :delta @max(0.00001, since_s); - } else (1 / 60); + } else (1.0 / 60.0); self.instant = now; } }; diff --git a/src/apprt/gtk/class/imgui_widget.zig b/src/apprt/gtk/class/imgui_widget.zig index 79e85fad2..8ad75f5d0 100644 --- a/src/apprt/gtk/class/imgui_widget.zig +++ b/src/apprt/gtk/class/imgui_widget.zig @@ -131,21 +131,17 @@ pub const ImguiWidget = extern struct { /// Initialize the frame. Expects that the context is already current. fn newFrame(self: *Self) void { - // If we can't determine the time since the last frame we default to - // 1/60th of a second. - const default_delta_time = 1 / 60; - const priv = self.private(); - const io: *cimgui.c.ImGuiIO = cimgui.c.ImGui_GetIO(); // Determine our delta time const now = std.time.Instant.now() catch unreachable; io.DeltaTime = if (priv.instant) |prev| delta: { - const since_ns = now.since(prev); - const since_s: f32 = @floatFromInt(since_ns / std.time.ns_per_s); + const since_ns: f64 = @floatFromInt(now.since(prev)); + const ns_per_s: f64 = @floatFromInt(std.time.ns_per_s); + const since_s: f32 = @floatCast(since_ns / ns_per_s); break :delta @max(0.00001, since_s); - } else default_delta_time; + } else (1.0 / 60.0); priv.instant = now; }