Testing raylib

This commit is contained in:
2026-02-14 00:30:56 -06:00
parent 8eccf21523
commit 6b91da2875
4 changed files with 2203 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
odin odin
ols ols
emscripten
]; ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [

37
src/build-web.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash -eu
# Point this to where you installed emscripten. Optional on systems that already
# have `emcc` in the path.
EMSCRIPTEN_SDK_DIR="$HOME/repos/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 source/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_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
# source/main_web/main_web.odin
flags="-sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 -sASSERTIONS --shell-file source/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}"

2163
src/build/web/odin.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,8 @@ main :: proc() {
raylib.BeginDrawing() raylib.BeginDrawing()
raylib.ClearBackground(raylib.DARKBLUE) raylib.ClearBackground(raylib.DARKBLUE)
raylib.DrawText("Ur mom", 100, 100, 50, raylib.BLACK)
raylib.EndDrawing() raylib.EndDrawing()
} }