pub fn set_main_loop<F>(func: F, fps: c_int, simulate_infinite_loop: bool)where
F: 'static + FnMut(),
Expand description
Sets the given function as the main loop of the calling thread, using the emscripten-defined emscripten_set_main_loop
.
The given function has no parameters.
The main loop can be cancelled using the cancel_main_loop
function.
§Arguments
func
- The function to be set as main event loop for the calling thread.fps
- The number of calls of the function per second. If set to a value <= 0, the browser’srequestAnimationFrame()
function will be used (recommended when using the main function for rendering) instead of a fixed rate.simulate_infinite_loop
- Iftrue
, no code after the function call will be executed, otherwise the code after the function call will be executed.
§Examples
set_main_loop(|| {
println!("Hello world every half second!");
}, 2, true);