Files
harfbuzz/util/gpu/web/build-webgpu.sh
T
Behdad EsfahbodandClaude Opus 4.6 ca2fb1eb68 [gpu] Share demo_view between WebGL and WebGPU web demos
Refactor demo_view to work without GLFW (guarded by HB_GPU_NO_GLFW):
- Add demo_view_create_headless() for non-GLFW use
- Store fb/window dimensions in the view struct
- Use emscripten_get_now() for timing when on Emscripten
- Guard GLFW-specific calls (fullscreen, window close, cursor query)

Rewrite WebGPU entry point to use demo_view and demo_renderer_t
interface instead of duplicated view/input code. This gives the
WebGPU demo identical trackball rotation, drag-release animation,
keyboard shortcuts, and gamma cycling as the GL demos.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 15:36:19 -06:00

38 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Build the hb-gpu web demo with Emscripten + WebGPU.
# Prerequisites: source emsdk/emsdk_env.sh
set -e
SRCDIR="$(cd "$(dirname "$0")/../../.." && pwd)"
OUTDIR="$(dirname "$0")/out"
mkdir -p "$OUTDIR"
em++ \
-std=c++17 \
-Oz -flto \
-I"$SRCDIR/src" \
-I"$SRCDIR/util/gpu/web" \
-DHB_NO_MT \
-DHAVE_ROUND \
-DHB_HAS_GPU \
-DHB_GPU_NO_GLFW \
-include gl-stub.h \
"$SRCDIR/src/harfbuzz-world.cc" \
"$SRCDIR/util/gpu/demo-atlas.cc" \
"$SRCDIR/util/gpu/demo-buffer.cc" \
"$SRCDIR/util/gpu/demo-font.cc" \
"$SRCDIR/util/gpu/demo-view.cc" \
"$SRCDIR/util/gpu/web/hb-gpu-web-webgpu.cc" \
--use-port=emdawnwebgpu \
-sALLOW_MEMORY_GROWTH=1 \
-sEXPORTED_FUNCTIONS='["_main","_web_load_font","_web_set_text","_web_get_text","_malloc","_free"]' \
-sEXPORTED_RUNTIME_METHODS='["UTF8ToString","lengthBytesUTF8","stringToUTF8"]' \
--shell-file "$SRCDIR/util/gpu/web/shell.html" \
-o "$OUTDIR/webgpu.html"
echo "Built: $OUTDIR/webgpu.html"
echo "Serve: python3 -m http.server -d $OUTDIR"