glfw: add glfw.pollEvents
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
022b9f6860
commit
522f26e15f
1 changed files with 37 additions and 32 deletions
|
@ -127,37 +127,35 @@ pub inline fn getVersionString() [*c]const u8 {
|
||||||
return c.glfwGetVersionString();
|
return c.glfwGetVersionString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(events):
|
/// Processes all pending events.
|
||||||
// /// Processes all pending events.
|
///
|
||||||
// ///
|
/// This function processes only those events that are already in the event queue and then returns
|
||||||
// /// This function processes only those events that are already in the event
|
/// immediately. Processing events will cause the window and input callbacks associated with those
|
||||||
// /// queue and then returns immediately. Processing events will cause the window
|
/// events to be called.
|
||||||
// /// and input callbacks associated with those events to be called.
|
///
|
||||||
// ///
|
/// On some platforms, a window move, resize or menu operation will cause event processing to
|
||||||
// /// On some platforms, a window move, resize or menu operation will cause event
|
/// block. This is due to how event processing is designed on those platforms. You can use the
|
||||||
// /// processing to block. This is due to how event processing is designed on
|
/// window refresh callback (see window_refresh) to redraw the contents of your window when
|
||||||
// /// those platforms. You can use the
|
/// necessary during such operations.
|
||||||
// /// [window refresh callback](@ref window_refresh) to redraw the contents of
|
///
|
||||||
// /// your window when necessary during such operations.
|
/// Do not assume that callbacks you set will _only_ be called in response to event processing
|
||||||
// ///
|
/// functions like this one. While it is necessary to poll for events, window systems that require
|
||||||
// /// Do not assume that callbacks you set will _only_ be called in response to
|
/// GLFW to register callbacks of its own can pass events to GLFW in response to many window system
|
||||||
// /// event processing functions like this one. While it is necessary to poll for
|
/// function calls. GLFW will pass those events on to the application callbacks before returning.
|
||||||
// /// events, window systems that require GLFW to register callbacks of its own
|
///
|
||||||
// /// can pass events to GLFW in response to many window system function calls.
|
/// Event processing is not required for joystick input to work.
|
||||||
// /// GLFW will pass those events on to the application callbacks before
|
///
|
||||||
// /// returning.
|
/// Possible errors include glfw.Error.NotInitialized and glfw.Error.PlatformError.
|
||||||
// ///
|
///
|
||||||
// /// Event processing is not required for joystick input to work.
|
/// @reentrancy This function must not be called from a callback.
|
||||||
// ///
|
///
|
||||||
// /// Possible errors include glfw.Error.NotInitialized and glfw.Error.PlatformError.
|
/// @thread_safety This function must only be called from the main thread.
|
||||||
// ///
|
///
|
||||||
// /// @reentrancy This function must not be called from a callback.
|
/// see also: events, glfw.waitEvents, glfw.waitEventsTimeout
|
||||||
// ///
|
pub inline fn pollEvents() Error!void {
|
||||||
// /// @thread_safety This function must only be called from the main thread.
|
c.glfwPollEvents();
|
||||||
// ///
|
try getError();
|
||||||
// /// see also: events, glfw.waitEvents, glfw.waitEventsTimeout
|
}
|
||||||
// ///
|
|
||||||
// GLFWAPI void glfwPollEvents(void);
|
|
||||||
|
|
||||||
// /// Waits until events are queued and processes them.
|
// /// Waits until events are queued and processes them.
|
||||||
// ///
|
// ///
|
||||||
|
@ -270,7 +268,7 @@ pub fn basicTest() !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test "version" {
|
test "getVersionString" {
|
||||||
// Reference these so the tests in these files get pulled in / ran.
|
// Reference these so the tests in these files get pulled in / ran.
|
||||||
_ = Monitor;
|
_ = Monitor;
|
||||||
_ = GammaRamp;
|
_ = GammaRamp;
|
||||||
|
@ -282,6 +280,13 @@ test "version" {
|
||||||
std.debug.print("\nstring: {s}\n", .{getVersionString()});
|
std.debug.print("\nstring: {s}\n", .{getVersionString()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "pollEvents" {
|
||||||
|
try init();
|
||||||
|
defer terminate();
|
||||||
|
|
||||||
|
try pollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
test "basic" {
|
test "basic" {
|
||||||
try basicTest();
|
try basicTest();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue