瀏覽代碼

Support GetCurrentTime() on macOS

pull/407/head
Ray San 7 年之前
父節點
當前提交
c9722161d1
共有 1 個檔案被更改,包括 21 行新增0 行删除
  1. +21
    -0
      src/gestures.h

+ 21
- 0
src/gestures.h 查看文件

@ -156,6 +156,11 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
#include <stdint.h> // Required for: uint64_t
#endif
#if defined(__APPLE__) // macOS also defines __MACH__
#include <mach/clock.h> // Required for: clock_get_time()
#include <mach/mach.h> // Required for: mach_timespec_t
#endif
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@ -532,6 +537,22 @@ static double GetCurrentTime(void)
time = ((double)nowTime/1000000.0); // Time in miliseconds
#endif
#if defined(__APPLE__)
//#define CLOCK_REALTIME CALENDAR_CLOCK
//#define CLOCK_MONOTONIC SYSTEM_CLOCK
clock_serv_t cclock;
mach_timespec_t now;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
// NOTE: OS X does not have clock_gettime(), using clock_get_time()
clock_get_time(cclock, &now);
mach_port_deallocate(mach_task_self(), cclock);
uint64_t nowTime = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec; // Time in nanoseconds
time = ((double)nowTime/1000000.0); // Time in miliseconds
#endif
return time;
}

Loading…
取消
儲存