mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Replaced NSDate time source with mach_absolute_time.
This commit is contained in:
parent
62e8d07f4f
commit
13a438c91e
|
@ -310,6 +310,7 @@ version of GLFW.</p>
|
|||
<li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li>
|
||||
<li>[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above</li>
|
||||
<li>[Cocoa] Added support for joysticks</li>
|
||||
<li>[Cocoa] Replaced <code>NSDate</code> time source with <code>mach_absolute_time</code></li>
|
||||
<li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li>
|
||||
<li>[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash</li>
|
||||
<li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li>
|
||||
|
|
|
@ -230,6 +230,8 @@ int _glfwPlatformInit(void)
|
|||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
||||
|
||||
_glfwInitTimer();
|
||||
|
||||
_glfwInitJoysticks();
|
||||
|
||||
return GL_TRUE;
|
||||
|
|
|
@ -85,7 +85,8 @@ typedef struct _GLFWwindowNS
|
|||
typedef struct _GLFWlibraryNS
|
||||
{
|
||||
struct {
|
||||
double t0;
|
||||
double base;
|
||||
double resolution;
|
||||
} timer;
|
||||
|
||||
// dlopen handle for dynamically loading OpenGL extension entry points
|
||||
|
@ -101,6 +102,9 @@ typedef struct _GLFWlibraryNS
|
|||
// Prototypes for platform specific internal functions
|
||||
//========================================================================
|
||||
|
||||
// Time
|
||||
void _glfwInitTimer(void);
|
||||
|
||||
// Joystick input
|
||||
void _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
|
|
|
@ -29,6 +29,36 @@
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Return raw time
|
||||
//========================================================================
|
||||
|
||||
static uint64_t getRawTime(void)
|
||||
{
|
||||
return mach_absolute_time();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Initialise timer
|
||||
//========================================================================
|
||||
|
||||
void _glfwInitTimer(void)
|
||||
{
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
|
||||
_glfwLibrary.NS.timer.resolution = (double) info.numer / (info.denom * 1.0e9);
|
||||
_glfwLibrary.NS.timer.base = getRawTime();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
|
@ -40,8 +70,8 @@
|
|||
|
||||
double _glfwPlatformGetTime(void)
|
||||
{
|
||||
return [NSDate timeIntervalSinceReferenceDate] -
|
||||
_glfwLibrary.NS.timer.t0;
|
||||
return (double) (getRawTime() - _glfwLibrary.NS.timer.base) *
|
||||
_glfwLibrary.NS.timer.resolution;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
|
@ -50,7 +80,7 @@ double _glfwPlatformGetTime(void)
|
|||
|
||||
void _glfwPlatformSetTime(double time)
|
||||
{
|
||||
_glfwLibrary.NS.timer.t0 =
|
||||
[NSDate timeIntervalSinceReferenceDate] - time;
|
||||
_glfwLibrary.NS.timer.base = getRawTime() -
|
||||
(uint64_t) (time / _glfwLibrary.NS.timer.resolution);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user