Crates.io | minwebgl |
lib.rs | minwebgl |
version | 0.2.0 |
source | src |
created_at | 2024-09-10 07:09:50.758928 |
updated_at | 2024-10-28 12:06:29.388136 |
description | Minimal set of tools for concise WebGL programming |
homepage | |
repository | https://github.com/Wandalen/cg_tools |
max_upload_size | |
id | 1370119 |
size | 196,878 |
Minimal set of tools for concise WebGL programming.
To use this library, you'll need to compile you application to wasm and then use it from javascript.
You can use wasm-pack:
rustup target add wasm32-unknown-unknown #Install wasm toolchain for rust
cargo install wasm-pack #Install wasm-pack
wasm-pack build --target web #Build your app for plain use on the web
--taget web
option will allow you to load your code in a browser directly( in plain HTML ).
You can mark your main function with #[wasm_bindgen(start)]`` And then use it in html:
<script type="module">
import init from "./pkg/you_crate_name.js";
init();
</script>
Another way is to use trunk - a WASM web application bundler for Rust.
rustup target add wasm32-unknown-unknown #Install wasm toolchain for rust
cargo install trunk #Install truck
trunk serve --release #Build and run your server in release mode
Any files you want to load in your project have to lie in a 'static' directory, relatively to the index.html file.
When using trunk you can specify the following, if your file lie elsewhere
<link data-trunk rel="copy-dir" href="assets/" data-target-path="static"/>