example-hello
Hello Garnet
The smallest Garnet game: one sprite that moves with WASD, the arrow keys, a gamepad's left stick, or the D-pad, and follows a finger on touch screens. It builds for every platform Garnet supports.
Installation
Clone it next to a Garnet checkout (the cli and engine repositories as siblings) and install Crystal 1.19.1 or later. garnet doctor checks the toolchain.
Usage
garnet run # desktop GL (default target)
garnet run --target desktop-vulkan
garnet test # headless specs
garnet build --target android # arm64 APK
| Target | Entry | Notes |
|---|---|---|
desktop-gl, desktop-metal, desktop-vulkan |
main.cr |
GLFW window (Hello.exe on Windows); GARNET_HELLO_LOAD=N adds N sprites and prints frame times |
ios |
ios.cr |
Shared UIKit host in engine/native/ios/host.m |
android |
android.cr |
NativeActivity with GLES 3; see below |
Windows
Desktop targets build a Windows executable on a Windows host with MSVC (see the cli README's "Windows builds" for setup: Visual Studio 2022 Build Tools, Crystal for Windows, and GLFW 3.4 on CRYSTAL_LIBRARY_PATH). Then, in Git Bash or PowerShell:
garnet doctor
garnet build --target desktop-gl
.garnet/build/desktop-gl-debug/Hello.exe
The build folder holds Hello.exe with glfw3.dll and Crystal's runtime DLLs beside it, so it can be zipped and run elsewhere. Without a GPU driver (as on CI), place Mesa's llvmpipe opengl32.dll beside the exe. The windows CI job builds the exe that way and renders 30 frames with GARNET_CAPTURE_FRAMES=30 GARNET_CAPTURE_DIR=shots, then uploads the exe, its DLLs and the frame as the hello-windows artifact.
Android
garnet doctor android checks the SDK, NDK and build-tools. Then:
garnet build --target android
adb install -r .garnet/build/android-debug/Hello.apk
adb shell am start -n org.garnetengine.hello/android.app.NativeActivity
adb logcat -s garnet # the game's output
The APK runs on arm64 devices and on arm64 emulator images (Android 10 / API 29 or later). In the emulator, -gpu host renders at full speed. The SwiftShader software GPU (-gpu swiftshader_indirect) works but manages only a few frames per second.
Contributing
Open issues and pull requests on GitHub. Run garnet test and ameba before sending changes.
License
MIT
example-hello
- 0
- 0
- 0
- 0
- 0
- about 3 hours ago
- November 30, 2026
Thu, 03 Dec 2026 03:21:30 GMT