Skip to content

is graphics rendering possible? #4

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

Closed
goldenratio opened this issue Dec 27, 2017 · 8 comments
Closed

is graphics rendering possible? #4

goldenratio opened this issue Dec 27, 2017 · 8 comments
Labels

Comments

@goldenratio
Copy link

Hi,

I am looking to render graphics in canvas element via WASM, instead of JavaScript. Is this possible with AssemblyScript?

For example, in game of life demo - rendering is done via javascript, is it possible to move it to assembly code?

@ColinEberhardt
Copy link
Contributor

No, WebAssembly does not have direct DOM access. The only way to render to canvas, or update any HTML is via importing JavaScript functions into your wasm module.

@goldenratio
Copy link
Author

clear now thanks.

@tiye
Copy link

tiye commented Dec 27, 2017

Does WebAssembly have Canvas API support?

@ColinEberhardt
Copy link
Contributor

No, it doesn’t have support directly. All WebAssembly can do is perform computations, reading and writing to memory. For everything else, you’ll need to import JavaScript functions that provide an interface into DOM / canvas etc ...

@dcodeIO
Copy link
Member

dcodeIO commented Dec 27, 2017

Things like these will become more efficient once host-bindings lands. From an AssemblyScript point of view, this could then look like in this String experiment, being part of stdlib, so Web-APIs "just work".

@goldenratio
Copy link
Author

what about webgl? can we use that for rendering in WASM. Recently I have been looking into rust lang. It seems to be possible.
Related RUST + GL + WASM repo https://github.com/kvark/wasm-triangle
Some more info on reddit https://www.reddit.com/r/rust_gamedev/comments/7mc7yk/is_there_any_wasm_friendly_2d_rendering_lib/drto3p9/

@goldenratio goldenratio reopened this Dec 27, 2017
@dcodeIO
Copy link
Member

dcodeIO commented Dec 27, 2017

It's just like with the game of life example: They are importing their own helpers to make it possible. You can do the same in AS.

@goldenratio
Copy link
Author

@dcodeIO thanks! :) you made it really clear for me.

radu-matei pushed a commit to radu-matei/assemblyscript that referenced this issue Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants