Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacroQuad with shaders don't work in WASM #702

Closed
Ozombia opened this issue Feb 25, 2024 · 1 comment
Closed

MacroQuad with shaders don't work in WASM #702

Ozombia opened this issue Feb 25, 2024 · 1 comment

Comments

@Ozombia
Copy link

Ozombia commented Feb 25, 2024

Thanks for MacroQuad, a nice way to learn Rust for a newbee like myself.
I think i am going to love it so much, i want to use it in production. But I have a problem with compiling to WASM.

  1. Snake compiles to WASM, and works in the browser:
    https://github.com/not-fl3/macroquad/blob/master/examples/snake.rs

  2. Shadertoy compiles to WASM, but does not work in the browser (tested in recent Chrome, Brave)
    https://github.com/not-fl3/macroquad/blob/master/examples/shadertoy.rs

I think Snake (1) uses a html 2d canvas, and Shadertoy (2) uses a html 3d canvas (with Shaders).
Is using a 3d canvas a problem for WASM?

Shadertoy has a lot of errors is the browser inspector console:

No __wbindgen_string_new function in gl.js
add_missing_functions_stabs @ mq_js_bundle.js:3
(anonymous) @ mq_js_bundle.js:3
Promise.then (async)
load @ mq_js_bundle.js:3
(anonymous) @ (index):27
mq_js_bundle.js:3 No __wbindgen_is_object function in gl.js
add_missing_functions_stabs @ mq_js_bundle.js:3
(anonymous) @ mq_js_bundle.js:3
Promise.then (async)
load @ mq_js_bundle.js:3
(anonymous) @ (index):27
mq_js_bundle.js:3 No __wbindgen_is_string function in gl.js
add_missing_functions_stabs @ mq_js_bundle.js:3
(anonymous) @ mq_js_bundle.js:3
Promise.then (async)
load @ mq_js_bundle.js:3
(anonymous) @ (index):27
mq_js_bundle.js:3

...

mq_js_bundle.js:3 WASM failed to load, probably incompatible gl.js version

@not-fl3
Copy link
Owner

not-fl3 commented Feb 25, 2024

__wbindgen_string_new

this means you are using wasm-bindgen. Wasm-bindgen requires post-processing your .wasm file with a third party binary tool. Its not very easy to set up, there is a script someone posted that might help with that: #212 (comment)

You can also search for wasm-bindgen here on github, there was a lot of issues about that.

@not-fl3 not-fl3 closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants