You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for putting together the project/examples :) I don't know how active this project is, but in case it's helpful for anyone else then here's a quick emscripten version of the "linear memory" example for Rust.
// use_wasm.js(async()=>{constresp=awaitfetch("linmem.wasm");constfileBuf=awaitresp.arrayBuffer();constlinMemModule=awaitWebAssembly.instantiate(fileBuf);const{
memory,
put_buffer_index_zero,
get_buffer_ptr,
get_buffer_index_one,}=linMemModule.instance.exports;constp1=document.createElement("p");p1.appendChild(document.createTextNode(`Initial value at buffer index 1: ${get_buffer_index_one()}`));document.body.appendChild(p1);constptr=get_buffer_ptr();constmemBuffer=newUint8Array(memory.buffer);put_buffer_index_zero(200);constp2=document.createElement("p");p2.appendChild(document.createTextNode(`Inserted value at buffer index 0: ${memBuffer[ptr+0]}`));document.body.appendChild(p2);memBuffer[ptr+1]=15;constp3=document.createElement("p");p3.appendChild(document.createTextNode(`Directly updated value at buffer index 1: ${get_buffer_index_one()}`));document.body.appendChild(p3);})();
emcc -O3 -s STANDALONE_WASM -s EXPORTED_FUNCTIONS="['_put_buffer_index_zero', '_get_buffer_ptr', '_get_buffer_index_one']" -Wl,--no-entry linmem.cpp -o "linmem.wasm"# serving files in the current dir with Python, but any other HTTP server will do
python -m http.server --bind 127.0.0.1 8080
Was going to do this in the MVP. But honestly, I know nothing about Emscripten 😂
Thus, I think I will go ahead, launch, and get the hype going, and then teach myself emscripten to make the demos 👍
The text was updated successfully, but these errors were encountered: