AppendixExamples

Sokol Triangle

The strongest FFI proof target in the repo: generated Sokol bindings, manifest-driven static linking, and a real triangle app.

The Sokol triangle example is the main proof target for the first FFI version.

It proves all of these together:

  • manifest-driven native library description
  • Clang-driven autobinding generation
  • generated Kira bindings emitted as a normal module
  • static library build rules per host
  • direct use of generated declarations from hand-written Kira code
  • native callbacks from Sokol into Kira @Native functions

Check The Binding Setup

Start with:

kira check examples/sokol_triangle

That validates the import/manifests/autobinding path before launching the app.

Run The Native Proof

kira run --backend llvm examples/sokol_triangle

This example opens a window, initializes Sokol, draws a triangle, and shuts down through Kira-written native code using the generated bindings directly.

Files That Matter

  • examples/sokol_triangle/native_libs/sokol.toml
  • examples/sokol_triangle/sokol.kira
  • examples/sokol_triangle/app/main.kira

There is also examples/sokol_runtime_entry/app/main.kira, which uses the same general binding flow with slightly different state handling.

Non-GUI Companion Proof

If you want a no-window proof that still exercises Sokol FFI, the corpus includes:

zig build run -- run --backend hybrid tests/pass/run/ffi_sokol_hybrid

Current output:

sokol ffi

That is useful when you want to confirm the binding path without launching the full triangle app.

On this page