Code Monkey home page Code Monkey logo

dume's People

Contributors

caelunshun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

isgasho

dume's Issues

Run in WebAssembly

@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/

Bug: Texture colors inverted on WASM target

@caelunshun Thanks for adding WASM support btw!

Texture colors appear to be inverted on the WASM target, using the latest experimental branch commit 26be4a0:

Native Vulkan target:
image

Inverted colors with same result on Chrome, Firefox, Edge:
image

Original texture:
crab

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.);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.