mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 16:31:14 +01:00
Web build using Emscripten + WebGL2 with HB_GPU_ATLAS_2D mode. Touch support: drag to pan, tap to toggle animation. FPS counter overlay. Viewport meta for mobile. Fix cursor position on first touch by querying glfwGetCursorPos in mouse_func. Left click/tap also toggles animation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Build the hb-gpu web demo with Emscripten.
|
|
# Prerequisites: source emsdk/emsdk_env.sh
|
|
|
|
set -e
|
|
|
|
SRCDIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
OUTDIR="$(dirname "$0")/out"
|
|
|
|
mkdir -p "$OUTDIR"
|
|
|
|
COMMON_FLAGS="-O2 -I$SRCDIR/src -DHB_NO_MT -DHAVE_ROUND -DHB_GPU_ATLAS_2D"
|
|
|
|
# Compile C files
|
|
emcc $COMMON_FLAGS -c "$SRCDIR/util/gpu/matrix4x4.c" -o "$OUTDIR/matrix4x4.o"
|
|
emcc $COMMON_FLAGS -c "$SRCDIR/util/gpu/trackball.c" -o "$OUTDIR/trackball.o"
|
|
|
|
# Compile C++ files and link
|
|
em++ \
|
|
-std=c++17 \
|
|
$COMMON_FLAGS \
|
|
"$SRCDIR/src/harfbuzz.cc" \
|
|
"$SRCDIR/src/hb-gpu.cc" \
|
|
"$SRCDIR/src/hb-gpu-draw.cc" \
|
|
"$SRCDIR/src/hb-gpu-shaders.cc" \
|
|
"$SRCDIR/util/gpu/demo-atlas.cc" \
|
|
"$SRCDIR/util/gpu/demo-buffer.cc" \
|
|
"$SRCDIR/util/gpu/demo-font.cc" \
|
|
"$SRCDIR/util/gpu/demo-glstate.cc" \
|
|
"$SRCDIR/util/gpu/demo-shader.cc" \
|
|
"$SRCDIR/util/gpu/demo-view.cc" \
|
|
"$SRCDIR/util/gpu/web/hb-gpu-web.cc" \
|
|
"$OUTDIR/matrix4x4.o" \
|
|
"$OUTDIR/trackball.o" \
|
|
-sUSE_GLFW=3 \
|
|
-sUSE_WEBGL2=1 \
|
|
-sFULL_ES3=1 \
|
|
-sALLOW_MEMORY_GROWTH=1 \
|
|
--shell-file "$SRCDIR/util/gpu/web/shell.html" \
|
|
-o "$OUTDIR/index.html"
|
|
|
|
echo "Built: $OUTDIR/index.html"
|
|
echo "Serve: python3 -m http.server -d $OUTDIR"
|