From 1393193a731c2efbaa23695fb4ca84281473375c Mon Sep 17 00:00:00 2001 From: cochrane Date: Fri, 18 Nov 2016 18:44:37 +0100 Subject: [PATCH] Use mach_absolute_time for time retrieval The Microseconds function is a leftover from the days of Carbon and deprecated since 10.8. --- src/platform/osx/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/platform/osx/main.cpp b/src/platform/osx/main.cpp index eb6bd33..128fdce 100644 --- a/src/platform/osx/main.cpp +++ b/src/platform/osx/main.cpp @@ -1,5 +1,8 @@ #include "game.h" +#include +#include + bool isQuit = false; WindowRef window; AGLContext context; @@ -139,9 +142,14 @@ OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userDat } int getTime() { - UInt64 t; - Microseconds((UnsignedWide*)&t); - return int(t / 1000); + static mach_timebase_info_data_t timebaseInfo; + if (timebaseInfo.denom == 0) { + mach_timebase_info(&timebaseInfo); + } + + uint64_t absolute = mach_absolute_time(); + uint64_t milliseconds = absolute * timebaseInfo.numer / (timebaseInfo.denom * 1000000ULL); + return int(milliseconds); } char *contentPath;