Module emscripten

Source
Expand description

Select functions (with rust-native parameter and return value types) from the emscripten emscripten.h header file, and helper functions and types for them. Only most of the “Calling JavaScript From C/C++” and “Browser Execution Environment” functions are implemented.

Structs§

MainLoopInvalidTiming
The main loop timing parameters can be set to other values than the ones with valid modes. If this is the case and we want to retrieve them, we use this error type.
ScreenSize
The result of the get_screen_size function.

Enums§

MainLoopTiming
Parameters of the main loop’s scheduling mode.

Functions§

cancel_main_loop
Cancels the main loop of the calling thread that was set using set_main_loop_with_arg or set_main_loop.
exit_with_live_runtime
Exits the program immediately while keeping the runtime alive, using emscripten_exit_with_live_runtime.
force_exit
Exits the program and kills the runtime, using emscripten_force_exit. Like libc’s exit, but works even if exit_with_live_runtime was run.
get_device_pixel_ratio
Returns the value of window.devicePixelRatio, using the emscripten-defined emscripten_get_device_pixel_ratio.
get_main_loop_timing
Returns the main loop timing parameters of the main loop.
get_now
Returns the representation of the current app running time with the highest precision using the emscripten-defined emscripten_get_now. It is most likely implemented using performance.now(), and is relevant only in comparison with other calls to this function.
get_screen_size
Returns the width and height of the screen in a nice ScreenSize structure.
get_window_title
Returns the window title, using the emscripten-defined emscripten_get_window_title.
hide_mouse
Hides the OS mouse cursor over the canvas, unlike SDL’s SDL_ShowCursor, which works with the SDL cursor.
is_main_loop_set
It returns true if the main loop function is set, and false if the main loop function isn’t set.
pause_main_loop
Pauses the main loop of the calling thread.
random
Returns a random number in range [0,1), with Math.random(), using the emscripten-defined emscripten_random.
resume_main_loop
Resumes the main loop of the calling thread.
run_script
Runs the given JavaScript script string with the eval() JS function, in the calling thread, using the emscripten-defined emscripten_run_script.
run_script_int
Runs the given JavaScript script string with the eval() JS function, in the calling thread, using the emscripten-defined emscripten_run_script_int. It returns the return result of the script, interpreted as a C int. Most probably the return result is passed to parseInt(), with NaN represented as 0.
run_script_main_thread
Runs the given JavaScript script string with the eval() JS function, in the main thread, using the emscripten-defined MAIN_THREAD_EM_ASM.
run_script_main_thread_double
Runs the given JavaScript script string with the eval() JS function, in the main thread, using the emscripten-defined MAIN_THREAD_EM_ASM_DOUBLE. It returns the return result of the script, interpreted as a C double.
run_script_main_thread_int
Runs the given JavaScript script string with the eval() JS function, in the main thread, using the emscripten-defined MAIN_THREAD_EM_ASM_INT. It returns the return result of the script, interpreted as a C int. Most probably the return result is passed to parseInt(), with NaN represented as 0.
run_script_string
Runs the given JavaScript script string with the eval() JS function, in the calling thread, using the emscripten-defined emscripten_run_script_string. It returns the return result of the script, interpreted as a string if possible. Otherwise, it returns None.
set_main_loop
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.
set_main_loop_timing
Applies the given main loop timing parameters to the main loop.
set_main_loop_with_arg
Sets the given function as the main loop of the calling thread, using the emscripten-defined emscripten_set_main_loop. The given function accepts a mutable reference (argument arg) to the variable that will contain the loop state and whatever else is needed for it to run.
set_window_title
Sets the window title, using the emscripten-defined emscripten_set_window_title.