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>
This commit is contained in:
2026-03-07 00:39:03 +01:00
parent 951bd51f12
commit c5c1436bc7
2 changed files with 5 additions and 3 deletions

View File

@@ -7,5 +7,7 @@ rustflags = [
"-C", "link-arg=-sWASM=1", "-C", "link-arg=-sWASM=1",
"-C", "link-arg=-sALLOW_MEMORY_GROWTH=1", "-C", "link-arg=-sALLOW_MEMORY_GROWTH=1",
"-C", "link-arg=-sINITIAL_MEMORY=67108864", "-C", "link-arg=-sINITIAL_MEMORY=67108864",
"-C", "link-arg=-sFULL_ES3=1", "-C", "link-arg=-sUSE_WEBGL2=1",
"-C", "link-arg=-sMIN_WEBGL_VERSION=2",
"-C", "link-arg=-sMAX_WEBGL_VERSION=2",
] ]

View File

@@ -4,7 +4,7 @@
set -euo pipefail set -euo pipefail
# Flags required by raylib-sys for WASM compilation. # 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" 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..." echo "Building for wasm32-unknown-emscripten..."
cargo build --target wasm32-unknown-emscripten --release cargo build --target wasm32-unknown-emscripten --release
@@ -20,5 +20,5 @@ echo "Build complete. Output in web/"
if [[ "${1-}" == "--serve" ]]; then if [[ "${1-}" == "--serve" ]]; then
echo "Serving at http://localhost:8080" echo "Serving at http://localhost:8080"
python3 -m http.server 8080 --directory web cd web && python3 -m http.server 8080
fi fi