Skip to content
Rust+GL+WASM triangle sample
Rust HTML
Branch: master
Clone or download
Latest commit f4bbf31 Dec 14, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Make it run on native Dec 14, 2017
.gitignore Basic implementation Dec 14, 2017
Cargo.lock Basic implementation Dec 14, 2017
Cargo.toml Basic implementation Dec 14, 2017
LICENSE Initial commit Dec 14, 2017
README.md Make it run on native Dec 14, 2017
triangle.html Basic implementation Dec 14, 2017
wasm-triangle.png Basic implementation Dec 14, 2017

README.md

Rust+GL+WASM Triangle

This is a simple demo showing how to get WebGL2 working via the Wasm/Emscripten target of Rust. Code is fully adopted from the gl-rs triangle example.

Preparing

You'll need Rust-1.22 or newer as well as Emscripten SDK installed.

In Emscripten configuration, set USE_WEBGL2=1. I did it by just modifying emscripten/src/settings.js directly (from where it's installed). Hopefully, we'll be able to pass the linker parameters to emcc via cargo one day.

Running

rustup target add wasm32-unknown-emscripten
cargo build --target=wasm32-unknown-emscripten
firefox triangle.html

Result

screenshot

You can’t perform that action at this time.