Loki is a AOT-first modern, simple and fast game framework for building games and interactive applications, built on top of SDL3 and its extensions (SDL_image, SDL_mixer, SDL_ttf). It targets .NET 11+ desktop, providing a clean and flexible API that hides the complexity of SDL.
- 2D rendering via the Renderer API and 3D rendering via the GPU API
- Window and display management
- Audio management
- Input & events
- Image and font loading
- Native UI integration
- Native AOT
using KappaDuck.Loki;
using KappaDuck.Loki.Graphics;
using KappaDuck.Loki.Graphics.Rendering;
internal sealed class Pong : Game
{
private Sprite _ball = null!;
public Pong() : base("Pong", 1280, 720)
{
}
protected override void Initialize()
{
Texture texture = Assets.Load("ball.png");
_ball = new Sprite(texture);
}
protected override void Update(GameTime time)
{
// move things by time.Delta
}
protected override void Draw(GameTime time)
{
Renderer.Clear(Colors.Black);
Renderer.Draw(_ball);
Renderer.Present();
}
}
// Program.cs
using Pong game = new();
game.Run();using KappaDuck.Loki;
using KappaDuck.Loki.Events;
using KappaDuck.Loki.Graphics;
using KappaDuck.Loki.Graphics.Rendering;
using KappaDuck.Loki.Input;
using KappaDuck.Loki.Windowing;
using Window window = new("Pong", 1280, 720);
using Renderer renderer = new(window);
using Texture texture = Texture.Load(renderer, "ball.png");
Sprite ball = new(texture);
while (window.IsOpen)
{
while (window.Poll(out Event e))
{
if (e is QuitRequested or KeyPressed { Key: Key.Escape })
{
window.Close();
return;
}
}
renderer.Clear(Colors.Black);
renderer.Draw(ball);
renderer.Present();
}More examples and documentation can be found at Documentation
Note
The public API is still a prototype. Expect to have frequent changes.
Install Loki via NuGet:
dotnet package add KappaDuck.Loki -v 0.1.0or via your .csproj:
<PackageReference Include="KappaDuck.Loki" Version="0.1.0">You can also install via the NuGet Package Manager in Visual Studio or JetBrains Rider.
Warning
Loki is still in early development. Expect breaking changes and frequent updates. Always use the latest version for the best experience.
Pre-release versions are published to NuGet.org alongside stable releases. To install the latest beta:
dotnet package add KappaDuck.Loki --prereleaseFull API documentation and samples are available:
- Full API reference
samples/for runnable code covering common uses cases
Loki supports Windows and Linux thanks to SDL3's abstraction layer.
The framework may have platform-specific implementations or limitations depending on the underlying SDL support. Using platform-specific features will surface a compiler warning indicating the code may not be portable across all targets.
Note
Android and WebAssembly (WASM) support is planned for a future milestone. macOS and iOS are not in scope.
SDL3 native libraries are bundled via KappaDuck.Loki.Runtimes. The table below shows the SDL versions included in each release of both packages.
During active development, KappaDuck.Loki references the pre-release version of KappaDuck.Loki.Runtimes. When a stable release of KappaDuck.Loki is published, it switches to the corresponding production version of KappaDuck.Loki.Runtimes.
| Loki | Runtimes | SDL3 | SDL_image | SDL_ttf | SDL_mixer |
|---|---|---|---|---|---|
source |
1.0.0 |
3.4.16 |
3.4.6 |
3.2.2 |
3.2.4 |
You can build Loki from source and experiment quickly using the included sandbox project.
1. Clone the repository
git clone https://github.com/KappaDuck/loki.git
cd loki2. Build and test
dotnet build
dotnet testTests run headless by default, so they work on a machine without a display. To watch the windows appear, pick a driver:
dotnet test -- --test-parameter video-driver=defaultdefault lets the platform choose, the way a real application does. You can also name a driver directly, such as x11 or windows. An SDL_VIDEODRIVER environment variable that is already set always wins.
3. Restore the local tools (only needed to build the documentation)
dotnet tool restore
dotnet build src/Loki --configuration Release
dotnet docfx docs/docfx.json --serveThe API reference is generated from the compiled assembly and its XML documentation, so the build has to run first.
| Path | Contents |
|---|---|
src/Loki |
The framework |
src/Loki.Generators |
Source generators shipped inside the package |
src/Loki.Sandbox |
Scratch project for experimenting |
tests |
Unit tests and generator snapshot tests |
benchmarks |
BenchmarkDotNet benchmarks |
samples |
Runnable examples |
docs |
Documentation site |
runtimes |
Native runtimes packaging |
The repository includes a dedicated sandbox project at src/Loki.Sandbox/ for experimenting without touching the main source. It references KappaDuck.Loki directly so changes are reflected immediately.
Everything you write there is ignored by git. If the folder holds no source at all, the first build drops a starter Program.cs in for you, so a fresh clone always compiles.
dotnet run --project src/Loki.Sandboxor simply run it in your IDE.
dotnet run -c Release --project benchmarks -- --filter '*'Every benchmark reports allocations as well as time. Results from main are published as charts at kappaduck.github.io/loki/dev/bench.
AI tools assisted with two things in this project: documentation (XML doc comments, README, CONTRIBUTING guidelines) and design exploration (prototyping API shapes, exploring implementation approaches, and thinking through architecture decisions). Everything is reviewed by the author and no generated-AI code will be in the code source.
Built with inspiration from