Wasm singleton instance with debug draw #2
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Previously, we've used Wasmtime as the primary WebAssembly runtime. This time around, I believe that we should initially use WAVM. My main reason for saying this is because exploring alternative runtimes is valuable in of itself, and WAVM has several benefits over Wasmtime:
vcpkg
portfiles that download and configure binaries, we can write a portfile to actually build it as needed, and if we do so, we could push to the upstreamvcpkg
repoThe first step we can take with Wasm scripting is to create a singleton instance of a WebAssembly module loaded from disk, then call an
update(dt)
(takes anf32
, returns nothing) function exported from it once a frame. Then, debug draw commands can be provided to the script to draw basic colored lines, using a very similar approach todrawTriangle()
from Canary or the prototype engine's UI system.To organize this, a new header/source file pair can be created:
include/scripting/debug_script.h
src/scripting/debug_script.c
Because debug draw is the only access the script has at the moment, the
env
parameter of Wasm functions can be set to the debug draw list itself. Seeworld.c
for an example of how this is wired up.cli/main.c
can then create an instance ofdebug_script
and update it every frame just like how it updatesworld.c
.The text was updated successfully, but these errors were encountered: