Skip to content

Commit 9d3529f

Browse files
authored
add function cancelMainLoop and setMainLoopArg (#8)
1 parent f84993a commit 9d3529f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/zemscripten.zig

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ pub fn setMainLoop(cb: MainLoopCallback, maybe_fps: ?i16, simulate_infinite_loop
1414
emscripten_set_main_loop(cb, if (maybe_fps) |fps| fps else -1, @intFromBool(simulate_infinite_loop));
1515
}
1616

17+
extern fn emscripten_cancel_main_loop() void;
18+
pub fn cancelMainLoop() void {
19+
emscripten_cancel_main_loop();
20+
}
21+
22+
pub const MainLoopArgCallback = *const fn (arg: *anyopaque) callconv(.C) void;
23+
extern fn emscripten_set_main_loop_arg(MainLoopArgCallback, arg: *anyopaque, c_int, c_int) void;
24+
pub fn setMainLoopArg(cb: MainLoopArgCallback, arg: *anyopaque, maybe_fps: ?i16, simulate_infinite_loop: bool) void {
25+
emscripten_set_main_loop_arg(cb, arg, if (maybe_fps) |fps| fps else -1, @intFromBool(simulate_infinite_loop));
26+
}
27+
1728
pub const AnimationFrameCallback = *const fn (f64, ?*anyopaque) callconv(.C) c_int;
1829
extern fn emscripten_request_animation_frame_loop(AnimationFrameCallback, ?*anyopaque) void;
1930
pub const requestAnimationFrameLoop = emscripten_request_animation_frame_loop;

0 commit comments

Comments
 (0)