A UI framework that only recalculates when changes, not on every frame.
- Odin Compiler - Install from https://odin-lang.org
- Sokol Bindings - Clone as git submodule
git clone <your-repo-url>
cd dawn
git submodule update --init --recursive
# Build Sokol C libraries
cd vendor/sokol/sokol
./build_clibs_linux.sh
cd ../../..Or manually:
git clone https://github.com/floooh/sokol-odin.git vendor/sokol
cd vendor/sokol/sokol
./build_clibs_linux.sh
cd ../..odin run main.odin -file -collection:sokol=vendor/sokol/sokol -strict-styleThis project includes a comprehensive three-tier testing system that allows you to verify UI behavior without needing a GPU or display.
Test layout logic, spacing calculations, and command generation without any graphics dependencies.
# Run all unit tests
odin test tests/ -collection:sokol=vendor/sokol
# Run with verbose output
odin test tests/ -collection:sokol=vendor/sokol -vWhat's Tested:
- Layout spacing calculations (ensures 24px gaps between elements)
- Container nesting behavior
- Draw command generation
- Coordinate math verification
Example Test Output:
✓ Layout test passed: First at Y=0.000, Second at Y=24.000 (spacing: 24.000)
✓ Nested container test: 4 commands generated
Why It's Useful:
- CI/CD friendly - runs on headless servers
- Fast feedback loop (< 1ms per test)
- Catches coordinate math bugs before visual testing
- Validates data-to-command pipeline
Run the UI with real-time command logging to see exactly what's being rendered.
# Run with debug output
./dawn_ui -debug
# Or
./dawn_ui --debugOutput Format:
=== DRAW COMMANDS ===
Total commands: 7
[00] TEXT | X: 0.0 Y: 0.0 | W: 300.0 H: 20.0 | Tournament Standings
[01] TEXT | X: 0.0 Y: 0.0 | W: 300.0 H: 20.0 | Name
[02] TEXT | X: 0.0 Y: 44.0 | W: 300.0 H: 20.0 | HP
...
=== END COMMANDS ===
Why It's Useful:
- See exact X/Y coordinates for every element
- Detect overlaps immediately (two items with same Y)
- Verify rectangle commands are generated
- Debug layout issues without screenshots
- Works with the actual GPU renderer
Capture the rendered output for visual regression testing.
# Save a snapshot
./dawn_ui --snapshot
# Output saved to: dawn_ui_snapshot.png.ppmHow It Works:
- Renders one frame
- Saves pixel data to PPM format (portable pixmap)
- Can be converted to PNG or compared directly
- Useful for catching visual regressions
Why It's Useful:
- Automated visual regression testing
- Compare against "golden" reference images
- Detect rendering artifacts
- CI/CD integration for UI consistency
Simple console-based tests for core logic.
odin run test_slider.odin -file -strict-style
odin run test_soa.odin -file -strict-styleFull rendering tests that require a display.
odin run test_display.odin -file -collection:sokol=vendor/sokol/sokol -strict-style- Write Unit Test First - Define expected layout behavior in
tests/layout_test.odin - Run Headless -
odin test tests/to verify coordinate math - Console Mirror -
./dawn_ui -debugto see live command output - Visual Verify - Run actual UI to confirm rendering
- Snapshot -
./dawn_ui --snapshotto save reference image
This approach catches layout bugs at the data level before they become visual glitches.
Data-Native UI uses dirty epoch tracking to skip rendering when data hasn't changed, dramatically reducing CPU/GPU usage.
tests/layout_test.odin- Unit tests for layout spacing and command generationmain.odin- Supports-debugand--snapshotflags for testingtest_*.odin- Traditional test harnesses
# 1. Unit tests (fastest, no GPU)
odin test tests/ -collection:sokol=vendor/sokol
# 2. Console mirror (see live commands)
./dawn_ui -debug
# 3. Snapshot capture (visual regression)
./dawn_ui --snapshot
# 4. Full run (visual verification)
./dawn_uiWhen you see "Mamenament Standings" (overlapping text) or missing rectangles:
- Run with debug flag:
./dawn_ui -debug - Check console output: Look for duplicate Y coordinates
- Verify command types: Should see both TEXT and RECT commands
- Fix in unit test: Add regression test to
tests/layout_test.odin - Verify fix: Run unit tests + debug mode again
dawn/
├── main.odin # Demo application (Tournament Standings UI)
├── odinui/ # Core UI framework package
│ ├── odinui.odin # Layout system, widgets, data structures
│ └── backend_sokol.odin # Sokol graphics backend (rendering)
├── tests/ # Unit tests
│ └── layout_test.odin # Headless layout tests
├── vendor/
│ └── sokol/ # Sokol graphics bindings
└── README.md
odinui/- Core UI framework (package with modular backend)odinui.odin- Widgets, layout, command buffer, dirty trackingbackend_sokol.odin- Sokol-specific rendering, shaders, text
main.odin- Demo application showing Tournament Standingstests/- Unit tests for layout logic (headless, no GPU)vendor/sokol/- Sokol graphics library bindings