A template to use Rust with Emscripten
Find a file
2024-09-19 14:13:27 +09:00
rust_src Impl. example with Raylib 2024-09-18 21:45:13 +09:00
src Init commit template for emscripten Rust 2024-09-18 19:22:56 +09:00
third_party Impl. example with Raylib 2024-09-18 21:45:13 +09:00
.gitignore Init commit template for emscripten Rust 2024-09-18 19:22:56 +09:00
Makefile Refactor "RUST_SOURCES" variable in Makefile 2024-09-19 14:13:27 +09:00
README.md Update README.md 2024-09-18 21:46:12 +09:00
UNLICENSE.txt Add UNLICENSE.txt 2024-09-18 19:24:08 +09:00

Emscripten Rust/C Template

This is a template for an emscripten project with a "Rust backend".

Setting up

(Note that this has only been tested in a Linux environment.)

  1. Clone https://github.com/emscripten-core/emsdk to ${HOME}/git/emsdk.
  2. Set up emsdk with ${HOME}/git/emsdk/emsdk install latest and ${HOME}/git/emsdk/emsdk activate latest.
  3. Set up rustup.
  4. Get the wasm32-unknown-emscripten target with rustup target add wasm32-unknown-emscripten.

Build

Just run make in the root of this project.

Other Notes

This raylib branch pulls the repository (if it doesn't exist) and builds it. It should do this automatically when you invoke make.

The current set up of the update/draw loop uses emscripten_set_main_loop_arg(...) with parameters that should call the browser's requestAnimationFrame that should call update and draw once per each frame at the fps that the browser decides, which should match the fps of your display.