packages/app/odin-clay-raylib-example
o

odin-clay-raylib-example

v8c869d5app

A web and native app in Odin with raylib and clay.

0 stars0 forksUnknownupdated 9 hours ago
Open repo

Odin Clay/Raylib Counter

The native target uses Odin, Clay's official Odin binding, and raylib. The web target uses the same Odin Clay application and an Odin render-command loop that draws through a tiny JavaScript Canvas 2D host.

Odin

Do not install Odin with Homebrew for this project; package-manager builds may miss the vendor tree required for raylib.

This checkout was set up with the official Darwin arm64 release:

curl -L https://github.com/odin-lang/Odin/releases/download/dev-2026-07/odin-macos-arm64-dev-2026-07.tar.gz \
  -o /private/tmp/odin-macos-arm64-dev-2026-07.tar.gz
mkdir -p ~/dev/releases/odin-dev-2026-07
tar -xzf /private/tmp/odin-macos-arm64-dev-2026-07.tar.gz \
  -C ~/dev/releases/odin-dev-2026-07 --strip-components=1

Verify the install:

~/dev/releases/odin-dev-2026-07/odin version
~/dev/releases/odin-dev-2026-07/odin root
ls "$(~/dev/releases/odin-dev-2026-07/odin root)/base" \
   "$(~/dev/releases/odin-dev-2026-07/odin root)/core" \
   "$(~/dev/releases/odin-dev-2026-07/odin root)/vendor"
ls "$(~/dev/releases/odin-dev-2026-07/odin root)/vendor/raylib"

If macOS quarantines the compiler, clear it:

xattr -d com.apple.quarantine ~/dev/releases/odin-dev-2026-07/odin

Configure the compiler path for this checkout by copying the tracked example and editing ODIN:

cp Makefile.local.example Makefile.local

Makefile.local is git ignored so paths and other machine-specific overrides stay local. You can also supply the compiler for a single invocation with make native ODIN=/path/to/odin. Build-related targets fail with a setup hint when ODIN is not configured; make clean does not require it.

For WebAssembly, wasm-ld must be installed. On this Mac it is available at /opt/homebrew/bin/wasm-ld; the Makefile prepends /opt/homebrew/bin for the web build.

Build

make native
make web

Outputs:

  • Native app: build/native/odin_clay_counter
  • Web app: build/web/index.html plus build/web/app.wasm

Run the native app:

make run

Serve the web app on port 8080:

make serve

Then open http://localhost:8080.

If another local service already owns 8080, use an alternate port:

make serve PORT=18080

Notes

  • Clay's official Odin binding is vendored in vendor/clay-odin.
  • Departure Mono is bundled in web/assets under the SIL Open Font License. The web build copies those assets to build/web/assets, and the native build copies them to build/native/assets.
  • Text uses a small Clay fontId registry. APP_FONT_UI in src/app.odin currently maps to Departure Mono in both renderers; add future fonts by extending the shared font ids, the native font array loader, and the web APP_FONTS table.
  • Native layout uses logical raylib window size and renders Clay commands into a render texture sized with GetRenderWidth()/GetRenderHeight().
  • Native startup uses a manual borderless-window setup matching raylib 5.5's behavior instead of raylib 6.0's ToggleBorderlessWindowed(), which produced mismatched render dimensions on macOS HighDPI.
  • Web layout uses CSS viewport pixels as logical coordinates, sizes the canvas backing store with devicePixelRatio, and renders scaled Clay commands into the backing store.
Package Info
Version
v8c869d5
License
Unknown
Author
@joakin
Type
app
Forks
0
Created
9 hours ago
Updated
9 hours ago
Health
maintained
has releases
has readme
has license
Activity
last 56 weeks