Web build script and updates to web source.

Added Karl Zylinski web build script.
Updated template for better width.
Removed resizing function.
This commit is contained in:
2026-06-28 06:57:48 +02:00
parent d43ec53d8d
commit 5edae5d2d8
3 changed files with 44 additions and 7 deletions
Executable
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash -eu
# Point this to where you installed emscripten. Optional on systems that already
# have `emcc` in the path.
EMSCRIPTEN_SDK_DIR="$HOME/Probe/emsdk"
OUT_DIR="build/web"
mkdir -p $OUT_DIR
export EMSDK_QUIET=1
[[ -f "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh" ]] && . "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh"
# Note RAYLIB_WASM_LIB=env.o -- env.o is an internal WASM object file. You can
# see how RAYLIB_WASM_LIB is used inside <odin>/vendor/raylib/raylib.odin.
#
# The emcc call will be fed the actual raylib library file. That stuff will end
# up in env.o
#
# Note that there is a rayGUI equivalent: -define:RAYGUI_WASM_LIB=env.o
# odin build src/main_web -target:js_wasm32 -build-mode:obj -define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o -vet -strict-style -out:$OUT_DIR/game.wasm.o
odin build src/main_web -target:js_wasm32 -build-mode:obj -define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o -out:$OUT_DIR/game.wasm.o
ODIN_PATH=$(odin root)
cp $ODIN_PATH/core/sys/wasm/js/odin.js $OUT_DIR
files="$OUT_DIR/game.wasm.o ${ODIN_PATH}/vendor/raylib/wasm/libraylib.a ${ODIN_PATH}/vendor/raylib/wasm/libraygui.a"
# index_template.html contains the javascript code that calls the procedures in
# src/main_web/main_web.odin
flags="-sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sSTACK_SIZE=524288 -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 -sASSERTIONS --shell-file src/main_web/index_template.html --preload-file assets"
# For debugging: Add `-g` to `emcc` (gives better error callstack in chrome)
emcc -o $OUT_DIR/index.html $files $flags
rm $OUT_DIR/game.wasm.o
echo "Web build created in ${OUT_DIR}"
+6 -5
View File
@@ -10,13 +10,14 @@
<meta name="viewport" content="width=device-width">
<style>
body {
margin: 0px;
overflow: hidden;
body {
margin: 0px;
overflow: hidden;
background-color: black;
}
canvas.game_canvas {
border: 0px none;
canvas.game_canvas {
max-width: 1550px;
border: 0px none;
background-color: black;
padding-left: 0;
padding-right: 0;
-2
View File
@@ -63,6 +63,4 @@ main_end :: proc "c" () {
@export
web_window_size_changed :: proc "c" (w: c.int, h: c.int) {
context = web_context
// TODO
game.parent_window_size_changed(int(w), int(h))
}