caelunshun / dume Goto Github PK
View Code? Open in Web Editor NEWA 2D rendering canvas for wgpu
A 2D rendering canvas for wgpu
@caelunshun Hi, I'm very interested in this library for a nice canvas-like 2D rendering API for wgpu
, and would like to use it for the web target (WebGL 2 / WebGPU) for wgpu
in WASM.
What currently needs to be done to run this library in WebAssembly?
The example runs fine with cargo run --example testbed
on the experimental branch.
However, I'm getting these errors when running the compiled WASM in the browser:
Uncaught (in promise) RuntimeError: unreachable
at __rust_start_panic (:4000/testbed_bg.wasm)
at rust_panic (:4000/testbed_bg.wasm)
at std::panicking::rust_panic_with_hook::ha223473efd20893e (:4000/testbed_bg.wasm)
at std::panicking::begin_panic_handler::{{closure}}::h0eb6605d81329fe7 (:4000/testbed_bg.wasm)
at std::sys_common::backtrace::__rust_end_short_backtrace::h8c7d312a147e1df9 (:4000/testbed_bg.wasm)
at rust_begin_unwind (:4000/testbed_bg.wasm)
at core::panicking::panic_fmt::hca0bee0b11468063 (:4000/testbed_bg.wasm)
at core::panicking::panic::hb05521048dcb55f3 (:4000/testbed_bg.wasm)
at testbed::main::h1175dc00f190c0ea (:4000/testbed_bg.wasm)
at std::sys_common::backtrace::__rust_begin_short_backtrace::h848964148b218d05 (:4000/testbed_bg.wasm)
I've tried changing the Cargo.toml to this:
[package]
name = "dume"
version = "0.1.0"
authors = ["caelunshun <[email protected]>"]
edition = "2021"
[dependencies]
ahash = "0.7"
anyhow = "1"
bytemuck = { version = "1", features = [ "derive" ] }
flume = "0.10"
glam = { version = "0.17", features = [ "bytemuck" ] }
guillotiere = "0.6"
log = "0.4"
lru = "0.7"
lyon = "0.17"
once_cell = "1"
palette = "0.6"
parking_lot = "0.11"
rectangle-pack = "0.4"
serde = { version = "1", features = [ "derive" ] }
slotmap = "1"
smallvec = "1"
smartstring = { version = "0.2", features = [ "serde" ] }
swash = "0.1"
thiserror = "1"
unicode-bidi = "0.3"
wgpu = { version = "0.11", features = ["webgl"] }
web-sys = "0.3.55"
winit = { version = "0.25.0", features = ["web-sys"] }
[dev-dependencies]
image = { version = "0.23", default-features = false, features = [ "jpeg" ] }
pollster = "0.2"
simple_logger = "1"
[profile.dev]
opt-level = 3
And then running:
cargo build --target wasm32-unknown-unknown
wasm-bindgen --out-dir static --target web --no-typescript target/wasm32-unknown-unknown/debug/examples/testbed.wasm
basic-http-server ./static/
@caelunshun Thanks for adding WASM support btw!
Texture colors appear to be inverted on the WASM target, using the latest experimental branch commit 26be4a0:
Inverted colors with same result on Chrome, Firefox, Edge:
Relevant code:
let mut texBuilder = cx.create_texture_set_builder();
texBuilder.add_texture(include_bytes!("../assets/crab.png"), "sprite1").unwrap();
let texSet = texBuilder.build(1024, 1024).unwrap();
cx.add_texture_set(texSet);
let tex = Context::texture_for_name(canvas.context(), "sprite1").unwrap();
canvas.draw_sprite(tex, vec2(20., 20.), 400.);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.