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§
- 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.
- The result of the
get_screen_sizefunction.
Enums§
- Parameters of the main loop’s scheduling mode.
Functions§
- Cancels the main loop of the calling thread that was set using
set_main_loop_with_argorset_main_loop. - Exits the program immediately while keeping the runtime alive, using
emscripten_exit_with_live_runtime. - Exits the program and kills the runtime, using
emscripten_force_exit. Like libc’sexit, but works even ifexit_with_live_runtimewas run. - Returns the value of
window.devicePixelRatio, using the emscripten-definedemscripten_get_device_pixel_ratio. - Returns the main loop timing parameters of the main loop.
- 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. - Returns the width and height of the screen in a nice
ScreenSizestructure. - Returns the window title, using the emscripten-defined
emscripten_get_window_title. - Hides the OS mouse cursor over the canvas, unlike SDL’s
SDL_ShowCursor, which works with the SDL cursor. - It returns
trueif the main loop function is set, andfalseif the main loop function isn’t set. - Pauses the main loop of the calling thread.
- Returns a random number in range [0,1), with
Math.random(), using the emscripten-definedemscripten_random. - Resumes the main loop of the calling thread.
- Runs the given JavaScript script string with the
eval()JS function, in the calling thread, using the emscripten-definedemscripten_run_script. - 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. - Runs the given JavaScript script string with the
eval()JS function, in the main thread, using the emscripten-definedMAIN_THREAD_EM_ASM. - 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. - 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. - 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. - 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. - Applies the given main loop timing parameters to the 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 accepts a mutable reference (argumentarg) to the variable that will contain the loop state and whatever else is needed for it to run. - Sets the window title, using the emscripten-defined
emscripten_set_window_title.