SDL3# provides hand-crafted C# language bindings for SDL3.
In contrast to the promoted C# bindings (SDL3-CS), SDL3# is entirely hand-crafted, with no auto-generation of API code based on the native library.
Every part of the API is deliberately designed to feel native to C#, translating SDL's functionality into idiomatic, well thought-out counterparts that existing C# users should feel right at home with.
It makes heavy use of modern C# features to provide an API that is expressive and comfortable to work with from managed code, while still exposing the full breadth of SDL's functionality.
Warning
This project is a work in progress and is not yet complete or usable in production. The public .NET API is subject to change at any time and in any form without prior notice. Use at your own risk.
At the moment, I'm the sole maintainer and contributor to this project, and all of it I do in my free time.
If you like this project and like what I'm doing, please consider supporting it by donating. It would help me dedicate more time into developing and improving SDL3#.
Any donation, one-time or recurring, in any amount, is deeply appreciated!
Thank you so much for your help and support. ❤️
You can donate via PayPal using the button below:
Or you can just scan the QR code below:
At the moment, there's a very crude API documentation available under https://sdl3sharp.github.io/Sdl3Sharp/api/Sdl3Sharp.html.
For now it's very limited and kind of neglected, and it might stay that way for at least as long as DocFx has some major issues with C# 14 features. SDL3# makes heavy use of those features, which, in turn, renders the generated API documentation partially broken. For now, it might be at least useful as a starting point. For everything else, you'll have to rely on IntelliSense (or a comparable tool in the IDE of you choice) and the source code itself.
We'll improve the documentation eventually!
For instructions on how to build the project from source, see BUILDING.md.
- C# 14 or later
- .NET 10 or later
(Example: Visual Studio)
Open the NuGet Package Manager, search for Sdl3Sharp, check "Include prerelease", and install the latest version.
<PackageReference Include="Sdl3Sharp" Version="*-*" />Add the following directive at the top of your file:
#:package Sdl3Sharp@*-*The default Sdl3Sharp package includes pre-built native SDL3 binaries for all supported platforms and is the easiest way to get started.
If you only need to target specific platforms, you can reference the corresponding RID-specific packages instead, for example Sdl3Sharp.win-x64 or Sdl3Sharp.linux-x64, rather than pulling in binaries for every platform.
If you do not want any native binaries bundled at all, reference Sdl3Sharp.Core instead. In that case you are responsible for providing the native SDL3 and libffi binaries yourself, placed alongside the resulting executable of your application.
MessageBox.TryShowSimple(MessageBoxFlags.Information, "Hello World", "Hello World from SDL3#!");using var sdl = new Sdl(static builder => builder
.SetAppName("Simple SDL3# Triangle example")
.InitializeSubSystems(SubSystems.Video)
);
return sdl.Run(new App(), args);
class App : AppBase
{
private Window mWindow = default!;
private Renderer mRenderer = default!;
protected override AppResult OnInitialize(Sdl sdl, string[] args)
{
if (!Window.TryCreateWithRenderer("Hello World", 800, 600, out mWindow!, out mRenderer!))
{
return Failure;
}
return Continue;
}
protected override AppResult OnIterate(Sdl sdl)
{
mRenderer.DrawColorFloat = (0, 0, 0, 1);
mRenderer.TryClear();
mRenderer.TryRenderGeometry([
new Vertex(position: (400, 150), color: (1, 0, 0, 1), texCoord: default),
new Vertex(position: (200, 450), color: (0, 1, 0, 1), texCoord: default),
new Vertex(position: (600, 450), color: (0, 0, 1, 1), texCoord: default)
]);
mRenderer.TryRenderPresent();
return Continue;
}
protected override AppResult OnEvent(Sdl sdl, ref Event @event)
{
if (@event.Type is EventType.WindowCloseRequested)
{
return Success;
}
return Continue;
}
protected override void OnQuit(Sdl sdl, AppResult result)
{
mRenderer?.Dispose();
mRenderer = default!;
mWindow?.Dispose();
mWindow = default!;
}
}The example above makes use of the AppBase lifetime model, where SDL3# manages the main loop for you. You implement OnInitialize, OnIterate, and OnEvent as callbacks, and SDL3# takes care of the rest.
If you prefer to manage the main loop yourself, you can do so: you still initialize SDL via new Sdl(...) and pump events on your own, without using AppBase at all.
In the spirit of transparency, and in line with the contributing guidelines, here is an overview of how AI was used in this project:
- Documentation. AI was used to help write and improve documentation. The content itself comes from the author, but AI was used to clarify and clean up the writing.
- API design. AI was used as a sounding board for API design decisions. Sometimes the options to consider came from the author, sometimes the AI had useful proposals to offer. All decisions were ultimately made by the author.
- Infrastructural documents. AI was used to help write project documents such as this README.md, the BUILDING.md, the CONTRIBUTING.md, and the CODE_OF_CONDUCT.md.
- Code review. AI was used to review some of the author's code, and occasionally this turned out to be fruitful, catching bugs that might otherwise have been overlooked.
- Functional code. No AI was used to write any functional code. All code in this project was written by the author.
SDL3# is licensed under the MIT License. See NOTICE.md for third-party notices.


