mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-15 09:34:18 +02:00
Use mach_absolute_time for time retrieval
The Microseconds function is a leftover from the days of Carbon and deprecated since 10.8.
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
|
||||||
bool isQuit = false;
|
bool isQuit = false;
|
||||||
WindowRef window;
|
WindowRef window;
|
||||||
AGLContext context;
|
AGLContext context;
|
||||||
@@ -139,9 +142,14 @@ OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getTime() {
|
int getTime() {
|
||||||
UInt64 t;
|
static mach_timebase_info_data_t timebaseInfo;
|
||||||
Microseconds((UnsignedWide*)&t);
|
if (timebaseInfo.denom == 0) {
|
||||||
return int(t / 1000);
|
mach_timebase_info(&timebaseInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t absolute = mach_absolute_time();
|
||||||
|
uint64_t milliseconds = absolute * timebaseInfo.numer / (timebaseInfo.denom * 1000000ULL);
|
||||||
|
return int(milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *contentPath;
|
char *contentPath;
|
||||||
|
Reference in New Issue
Block a user