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§
- Main
Loop Invalid Timing - 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.
- Screen
Size - The result of the
get_screen_size
function.
Enums§
- Main
Loop Timing - 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
orset_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’sexit
, but works even ifexit_with_live_runtime
was run. - get_
device_ pixel_ ratio - Returns the value of
window.devicePixelRatio
, using the emscripten-definedemscripten_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 usingperformance.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, andfalse
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-definedemscripten_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-definedemscripten_run_script
. - run_
script_ int - Runs the given JavaScript script string with the
eval()
JS function, in the calling thread, using the emscripten-definedemscripten_run_script_int
. It returns the return result of the script, interpreted as a C int. Most probably the return result is passed toparseInt()
, 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-definedMAIN_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-definedMAIN_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-definedMAIN_THREAD_EM_ASM_INT
. It returns the return result of the script, interpreted as a C int. Most probably the return result is passed toparseInt()
, 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-definedemscripten_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 (argumentarg
) 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
.