Files
endless-runner-vibe/build_web.sh
Gabriel Kaszewski c5c1436bc7 Fix WebGL2 for web build (raylib 5 requires VAOs)
Add -sUSE_WEBGL2=1 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 to both
EMCC_CFLAGS and linker flags. raylib 5.x enables VAOs by default which
require WebGL2; without it glVertexAttribPointer fails on the clientside
property of an undefined VAO object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:39:03 +01:00

25 lines
783 B
Bash
Executable File

#!/usr/bin/env bash
# Build the endless runner for WebAssembly via Emscripten.
# Usage: ./build_web.sh [--serve]
set -euo pipefail
# Flags required by raylib-sys for WASM compilation.
export EMCC_CFLAGS="-O3 -sUSE_GLFW=3 -sASSERTIONS=1 -sWASM=1 -sASYNCIFY -sGL_ENABLE_GET_PROC_ADDRESS=1 -sUSE_WEBGL2=1 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2"
echo "Building for wasm32-unknown-emscripten..."
cargo build --target wasm32-unknown-emscripten --release
OUT=target/wasm32-unknown-emscripten/release
echo "Copying build artefacts to web/..."
cp "$OUT/endless_runner.js" web/
cp "$OUT/endless_runner.wasm" web/
echo ""
echo "Build complete. Output in web/"
if [[ "${1-}" == "--serve" ]]; then
echo "Serving at http://localhost:8080"
cd web && python3 -m http.server 8080
fi