Add glfwGetTimerValue and glfwGetTimerFrequency

This adds raw timer access to the public API and builds the
floating-point time functions on top.  It also makes the GLFWuint64 type
public.
This commit is contained in:
Camilla Berglund
2016-03-06 11:38:55 +01:00
parent 8221aadea3
commit 31f67dd3cc
14 changed files with 148 additions and 96 deletions
+16 -2
View File
@@ -645,7 +645,8 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
GLFWAPI double glfwGetTime(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
return _glfwPlatformGetTime();
return (double) (_glfwPlatformGetTimerValue() - _glfw.timerOffset) /
_glfwPlatformGetTimerFrequency();
}
GLFWAPI void glfwSetTime(double time)
@@ -658,6 +659,19 @@ GLFWAPI void glfwSetTime(double time)
return;
}
_glfwPlatformSetTime(time);
_glfw.timerOffset = _glfwPlatformGetTimerValue() -
(GLFWuint64) (time * _glfwPlatformGetTimerFrequency());
}
GLFWAPI GLFWuint64 glfwGetTimerValue(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return _glfwPlatformGetTimerValue();
}
GLFWAPI GLFWuint64 glfwGetTimerFrequency(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return _glfwPlatformGetTimerFrequency();
}