2024-09-18 10:28:15 +00: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
|
2024-09-18 10:30:41 +00:00
|
|
|
`rustup target add wasm32-unknown-emscripten`.
|
2024-09-18 10:28:15 +00:00
|
|
|
|
|
|
|
## Build
|
|
|
|
|
|
|
|
Just run `make` in the root of this project.
|
2024-09-18 10:34:33 +00:00
|
|
|
|
|
|
|
## Other Notes
|
|
|
|
|
|
|
|
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.
|
2024-09-18 10:36:37 +00:00
|
|
|
|
2024-09-18 12:46:42 +00:00
|
|
|
If you want to use graphics, ~~I suggest using/building `raylib`, but that will
|
|
|
|
require building it separately with `emsdk` and linking to it in the
|
|
|
|
Makefile.~~ try out the `raylib` branch of this repository.
|