Assemblyscript: is graphics rendering possible?

Created on 27 Dec 2017  路  8Comments  路  Source: AssemblyScript/assemblyscript

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?

question

All 8 comments

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.

clear now thanks.

Does WebAssembly have Canvas API support?

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

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".

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/

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blooddy picture blooddy  路  3Comments

evgenykuzyakov picture evgenykuzyakov  路  3Comments

torch2424 picture torch2424  路  5Comments

Iainmon picture Iainmon  路  3Comments

DanielMazurkiewicz picture DanielMazurkiewicz  路  4Comments