zoeesilcock/handmade-zig
Learning Zig by following along with the Handmade Hero series of videos by Casey Muratori.
e8739b32a33ce48a3286aba31918b26a9dfc6ef0.tar.gz
f75e8d1cad7d90d72ef7a4661f1b994ef78b4e31
Learning Zig by following along with the Handmade Hero series of videos by Casey Muratori. This implementation follows Casey's approach as closely as Zig allows with some minor departures when I want to explore some specific Zig feature (like using @Vector
to get SIMD vector math for example).
Graphical assets are not included as they are not created by me. They need to be added to the data/
directory manually. We currently expect the assets found in this location of the pre-order data: handmade_hero_legacy_art.zip/v0_hhas
.
The asset files need to be packed using the asset packer before running the game. The current version of the asset builder doesn't produce files compatible with the game anymore since we made the reader compatible with asset files created by Casey, use the original files from handmade_hero_legacy_art.zip/v0_hhas
.
zig build build-assets
The game is split up into an executable for the runtime and a DLL that contains the actual game. This allows hot reloading for most of the game code. When the DLL is rebuilt, the game will automatically reload it.
To make this even more automatic you can run a separate terminal which automatically rebuilds the DLL when you save a file:
zig build --watch -Dpackage=Library
The included debugger config under .vscode/launch.json
is compatible with the nvim-dap plugin in Neovim and the C/C++ extension in VS Code. Using regular Visual Studio with C/C++ tooling appears to give the most reliable results. Another alternative that works almost as well as Visual Studio is Rad Debugger.
When running outside of an IDE, OutputDebugString
messages can be viewed using DebugView.
The build is setup to emit the generated assembly code which can be used to analyze the code for bottlenecks using llvm-mca
which is bundled with LLVM version 18+.
asm volatile("# LLVM-MCA-BEGIN ProcessPixel");
// Code to analyze.
// ...
asm volatile("# LLVM-MCA-END ProcessPixel");
Analyze the emitted assembly code:
llvm-mca .\zig-out\bin\handmade-dll.asm -bottleneck-analysis -o .\zig-out\bin\handmade-dll-mca.txt