Project 7: Hot-Reloading Game Engine

A game engine split into a host executable and game DLL, where you can modify game code and see changes instantly without restarting—like Handmade Hero or Jonathan Blow’s Jai demos.

Quick Reference

Attribute Value
Primary Language Odin
Alternative Languages C (with dlopen)
Difficulty Level 3: Advanced
Time Estimate 2 weeks
Knowledge Area Dynamic Linking / Game Development
Tooling Odin’s -build-mode:shared
Prerequisites Project 4 (Raylib Game), understanding of shared libraries

What You Will Build

A game engine split into a host executable and game DLL, where you can modify game code and see changes instantly without restarting—like Handmade Hero or Jonathan Blow’s Jai demos.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Splitting engine and game code → maps to module design
  • Preserving game state across reloads → maps to memory layout discipline
  • Loading/unloading shared libraries → maps to foreign system interaction
  • Handling function pointer changes → maps to ABI stability

Key Concepts

  • Shared Libraries in Odin: Odin compiler documentation
  • Hot Reloading: “Game Engine Architecture” Ch. 15
  • Memory Layout for Hot Reload: Keep state in host, code in DLL
  • File Watching: Detect source changes

Real-World Outcome

$ odin build host -out:host.exe
$ odin build game -build-mode:shared -out:game.dll

$ ./host.exe
[Host] Loading game.dll...
[Host] Found game_init at 0x7f8a2c000100
[Host] Found game_update at 0x7f8a2c000200
[Host] Found game_render at 0x7f8a2c000300
[Game] Initialized! State at 0x7f8a30000000

[Window shows game running]

# In another terminal, edit game code...
$ vim game/game.odin
# Change player speed from 200 to 500

$ odin build game -build-mode:shared -out:game_new.dll

[Host] Detected game.dll change!
[Host] Unloading old game.dll...
[Host] Loading game_new.dll...
[Host] Game state preserved at 0x7f8a30000000
[Host] Hot reload complete in 0.3s

[Game immediately reflects new player speed - no restart!]

Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: LEARN_ODIN_PROGRAMMING_LANGUAGE.md
  • “Game Engine Architecture” by Jason Gregory