mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 22:32:50 +00:00
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:
+16
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user