A basic spinning 3D cube, using bgfx and glfw3 compiling for WebAssembly (wasm) using Emscripten. Additionally compiles to native Linux/X11. Tested on Debian Bookworm (12), might work on Debian Bullseye (11). Very specific versions of bgfx and Emscripten are targeted; upgrading to newer versions may or may not work.
# apt install git python3 xz-utils cmake make
git clone https://github.com/emscripten-core/emsdk.gitcd emsdk./emsdk install 3.1.51 #only tested version. I've heard newer builds don't work, but they might now./emsdk activate 3.1.51source ./emsdk_env.shcd ..
git clone https://github.com/d3fault/bgfx-glfw-wasm-3dcube-template-starting-point.gitcd bgfx-glfw-wasm-3dcube-template-starting-pointgit submodule update --init --recursivecd bgfxemmake make wasm-debug #it will probably error out on one of the examples, this is fine. just make sure bgfxDebug.bc, bxDebug.bc, and bimgDebug.bc exist in bgfx/.build/wasm/bin/cd ..emcmake cmake -B buildwasmcd buildwasmemmake make
python -m SimpleHTTPServer 8080 #or other webserver- In your web browser: http://localhost:8080/index.html
# apt install git build-essential cmake libglfw3-dev
git clone https://github.com/d3fault/bgfx-glfw-wasm-3dcube-template-starting-point.gitcd bgfx-glfw-wasm-3dcube-template-starting-pointgit submodule update --init --recursivecd bgfxmake linux-debug64 #it might error out on one of the examples, this is fine. just make sure libbgfx-shared-libDebug.so exists in bgfx/.build/linux64_gcc/bin/cd ..cmake -B buildnativecd buildnativecmake --build . --parallel
./bgfx-glfw-wasm-3dcube-template-starting-point
- Release builds
- Multi-threading(?)
- Newer Emscripten and bgfx versions
- Auto-detect screen dimensions