Under heavy research and development, please don't use this yet!
Several demos for embedding RSX and rendering display lists generated by the RSX Primitives library.
Quick and easy example code. For much more in-depth walkthroughs and documentation on how to build your own projects from scratch, see this.
First, clone this repository recursively:
git clone git@github.com:victorporof/rsx-demo.git --recursive
Finally, edit the Cargo.toml
file to specify which target you want to build for. The default target is WebRender, so you don't need to edit the file for that target.
Edit the Cargo.toml
file to specify a native target and make sure the project isn't set up to compile as a library.
[features]
default = ["target-native"]
Then, simply
cargo run
Edit the Cargo.toml
file to specify a web target and make sure the project isn't set up to compile as a library.
[features]
default = ["target-web"]
As prerequisites, you need to install Emscripten, a couple of Rust targets, as well as some npm
development dependencies.
rustup target add asmjs-unknown-emscripten
rustup target add wasm32-unknown-emscripten
Follow the steps outlined in the official docs, or build from source from the Github repo. If you're using fish as your shell, the emsdk_env.sh
script won't add the necessary entries to your $PATH, so either run it under sh
or add the paths yourself.
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
npm install
cargo build --target=asmjs-unknown-emscripten
npm start
First time builds can take a very long time! Be patient.
Edit the Cargo.toml
file to specify an iOS target and make this crate a library. As prerequisites, you need to install the appropriate architectures, as well as cargo-lipo
and build jemalloc.
[lib]
name = "rsx_demo"
path = "src/main.rs"
crate-type = ["staticlib", "cdylib"]
[features]
default = ["target-ios"]
Then, install the appropriate architectures, as well as cargo-lipo
:
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
cargo install cargo-lipo
Then simply:
cargo lipo --release
Then open XCode project, first installing the CocoaPods dependencies:
cd fixtures/ios/Example/
pod install
open Example.xcworkspace
To make changes to the underlying Rust code, simply edit main.rs
and example.css
files inside the src directory. For more examples and syntax, see the RSX compiler plugin crate.
- Editing CSS files require Rust files to be re-saved before building. This is because
cargo build
tries really hard not to rebuild if not necessary, and CSS files aren't on its radar. - Mutation and user input isn't fully supported yet. Although support is trivial to add, there's no implementation or example code yet. Stay tuned.