glfw: add glfw.getTimerFrequency
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
faa0ee07db
commit
8fde27306a
1 changed files with 27 additions and 21 deletions
|
@ -20,8 +20,6 @@ const getError = @import("errors.zig").getError;
|
||||||
/// @return The current time, in seconds, or zero if an
|
/// @return The current time, in seconds, or zero if an
|
||||||
/// error occurred.
|
/// error occurred.
|
||||||
///
|
///
|
||||||
/// Possible errors include glfw.Error.NotInitialized.
|
|
||||||
///
|
|
||||||
/// @thread_safety This function may be called from any thread. Reading and
|
/// @thread_safety This function may be called from any thread. Reading and
|
||||||
/// writing of the internal base time is not atomic, so it needs to be
|
/// writing of the internal base time is not atomic, so it needs to be
|
||||||
/// externally synchronized with calls to @ref glfwSetTime.
|
/// externally synchronized with calls to @ref glfwSetTime.
|
||||||
|
@ -69,8 +67,6 @@ pub inline fn setTime(time: f64) Error!void {
|
||||||
///
|
///
|
||||||
/// @return The value of the timer, or zero if an error occurred.
|
/// @return The value of the timer, or zero if an error occurred.
|
||||||
///
|
///
|
||||||
/// Possible errors include glfw.Error.NotInitialized.
|
|
||||||
///
|
|
||||||
/// @thread_safety This function may be called from any thread.
|
/// @thread_safety This function may be called from any thread.
|
||||||
///
|
///
|
||||||
/// see also: time, glfw.getTimerFrequency
|
/// see also: time, glfw.getTimerFrequency
|
||||||
|
@ -85,23 +81,25 @@ pub inline fn getTimerValue() u64 {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(time):
|
/// Returns the frequency, in Hz, of the raw timer.
|
||||||
// /// Returns the frequency, in Hz, of the raw timer.
|
///
|
||||||
// ///
|
/// This function returns the frequency, in Hz, of the raw timer.
|
||||||
// /// This function returns the frequency, in Hz, of the raw timer.
|
///
|
||||||
// ///
|
/// @return The frequency of the timer, in Hz, or zero if an error occurred.
|
||||||
// /// @return The frequency of the timer, in Hz, or zero if an
|
///
|
||||||
// /// error occurred.
|
/// @thread_safety This function may be called from any thread.
|
||||||
// ///
|
///
|
||||||
// /// Possible errors include glfw.Error.NotInitialized.
|
/// see also: time, glfw.getTimerValue
|
||||||
// ///
|
pub inline fn getTimerFrequency() u64 {
|
||||||
// /// @thread_safety This function may be called from any thread.
|
const frequency = c.glfwGetTimerFrequency();
|
||||||
// ///
|
|
||||||
// /// see also: time, glfwGetTimerValue
|
// The only error this could return would be glfw.Error.NotInitialized, which should
|
||||||
// ///
|
// definitely have occurred before calls to this. Returning an error here makes the API
|
||||||
// ///
|
// awkward to use, so we discard it instead.
|
||||||
// /// @ingroup input
|
getError() catch {};
|
||||||
// GLFWAPI uint64_t glfwGetTimerFrequency(void);
|
|
||||||
|
return frequency;
|
||||||
|
}
|
||||||
|
|
||||||
test "getTime" {
|
test "getTime" {
|
||||||
const glfw = @import("main.zig");
|
const glfw = @import("main.zig");
|
||||||
|
@ -126,3 +124,11 @@ test "getTimerValue" {
|
||||||
|
|
||||||
_ = glfw.getTimerValue();
|
_ = glfw.getTimerValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "getTimerFrequency" {
|
||||||
|
const glfw = @import("main.zig");
|
||||||
|
try glfw.init();
|
||||||
|
defer glfw.terminate();
|
||||||
|
|
||||||
|
_ = glfw.getTimerFrequency();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue