Skip to content

edwardgushchin/SDL3-CS

Repository files navigation

SDL3#

Modern C# bindings for SDL3 and its companion libraries.

Build cross-platform .NET applications with SDL3, SDL_image, SDL_ttf, SDL_mixer, and SDL_shadercross.

NuGet SDL3-CS version NuGet SDL3-CS downloads zlib license GitHub contributors GitHub last commit

.NET 7, 8, 9, and 10 C# 14 SDL3 target 3.4.10 SDL companion libraries

Windows win-x86, win-x64, win-arm64 Linux x64 and arm64 macOS x64 and arm64 Android arm, arm64, x86, x64 iOS device and simulator tvOS device and simulator

About - Versioning - Documentation - Platforms - Installation - Examples - Feedback - License

πŸš€ About

SDL3# is a C# wrapper and native package set for SDL3. It gives .NET applications direct access to SDL3 APIs while keeping native runtime distribution predictable across desktop, mobile, and Apple TV targets.

The repository contains:

  • managed C# bindings for SDL3, SDL_image, SDL_ttf, SDL_mixer, and SDL_shadercross;
  • platform-specific native NuGet packages for Windows, Linux, macOS, Android, iOS, and tvOS;
  • Android SDLActivity bridge bindings for managed Android applications;
  • examples that cover window creation, rendering, input, audio, images, fonts, GPU usage, and mobile app setup;
  • release tooling and tests that validate package layout, native assets, and wrapper metadata.

SDL3# is intended for developers who want low-level SDL3 access from modern .NET without maintaining a separate native binary distribution pipeline for every supported platform.

πŸ”’ Versioning and Native Compatibility

SDL3# package versions follow the native SDL component versions. The first three version segments identify the upstream native component version. The final segment is the SDL3# package revision and may contain binding, packaging, or documentation fixes.

This source tree targets the following release lines:

Component Package pattern Native target Package line
SDL3 managed bindings SDL3-CS SDL 3.4.10 3.4.10.x
SDL3 native runtime SDL3-CS.{Platform} SDL 3.4.10 3.4.10.x
SDL_image native runtime SDL3-CS.{Platform}.Image SDL_image 3.4.4 3.4.4.x
SDL_ttf native runtime SDL3-CS.{Platform}.TTF SDL_ttf 3.2.2 3.2.2.x
SDL_mixer native runtime SDL3-CS.{Platform}.Mixer SDL_mixer 3.2.4 3.2.4.x
SDL_shadercross native runtime SDL3-CS.{Platform}.Shadercross SDL_shadercross 3.0.0 3.0.0.x

{Platform} is one of Windows, Linux, MacOS, Android, iOS, or tvOS.

Published NuGet packages can lag behind a release branch while native packages are being assembled. The NuGet badge, package pages, and GitHub Releases are authoritative for what is currently published.

πŸ“š Documentation

Project documentation lives in the SDL3-CS Wiki. Use the wiki, examples, and GitHub Releases for version notes, migration guidance, platform details, and release documentation.

For upstream SDL API documentation, see the official SDL3 Wiki.

🧭 Supported Platforms

The managed SDL3-CS wrapper targets .NET 7, .NET 8, .NET 9, and .NET 10.

Official native package families are built for the following release targets:

Platform family Package suffix Supported RIDs / ABIs Notes
Windows Windows win-x86, win-x64, win-arm64 Dynamic SDL libraries for desktop Windows apps.
Linux Linux linux-x64, linux-arm64 Built against glibc 2.28 or newer.
macOS MacOS osx-x64, osx-arm64 Dynamic SDL libraries for Intel and Apple Silicon macOS apps.
Android Android android-arm (armeabi-v7a), android-arm64 (arm64-v8a), android-x86 (x86), android-x64 (x86_64) Includes SDL Android bridge bindings and ABI-specific native libraries.
iOS iOS ios-arm64, iossimulator-arm64, iossimulator-x64 Static native assets are linked through package build targets.
tvOS tvOS tvos-arm64, tvossimulator-arm64, tvossimulator-x64 Static native assets are linked through package build targets.

Other platforms can use the managed bindings if the application supplies compatible SDL native libraries manually.

πŸ“ Installation

Install the managed bindings:

dotnet add package SDL3-CS

Add the native package for your target platform:

dotnet add package SDL3-CS.Windows

Replace Windows with the package suffix for your target platform:

Target platform Package suffix
Windows Windows
Linux Linux
macOS MacOS
Android Android
iOS iOS
tvOS tvOS

Optional SDL companion libraries use the same platform suffix:

dotnet add package SDL3-CS.Windows.Image
dotnet add package SDL3-CS.Windows.TTF
dotnet add package SDL3-CS.Windows.Mixer
dotnet add package SDL3-CS.Windows.Shadercross

Use the same platform suffix for every SDL3# package in the same application.

Android

Android applications should reference SDL3-CS.Android and use MainActivity : Org.Libsdl.App.SDLActivity with a managed Main() override. The Android package includes the SDL Java bridge bindings and ABI-specific libSDL3.so files.

Build from Source

git clone https://github.com/edwardgushchin/SDL3-CS
cd SDL3-CS
dotnet build SDL3-CS.sln -c Release

πŸŽ“ Examples

using SDL3;

namespace Create_Window;

internal static class Program
{
    [STAThread]
    private static void Main()
    {
        if (!SDL.Init(SDL.InitFlags.Video))
        {
            SDL.LogError(SDL.LogCategory.System, $"SDL could not initialize: {SDL.GetError()}");
            return;
        }

        if (!SDL.CreateWindowAndRenderer("SDL3 Create Window", 800, 600, 0, out var window, out var renderer))
        {
            SDL.LogError(SDL.LogCategory.Application, $"Error creating window and rendering: {SDL.GetError()}");
            return;
        }

        SDL.SetRenderDrawColor(renderer, 100, 149, 237, 255);

        var loop = true;

        while (loop)
        {
            while (SDL.PollEvent(out var e))
            {
                if ((SDL.EventType)e.Type == SDL.EventType.Quit)
                {
                    loop = false;
                }
            }

            SDL.RenderClear(renderer);
            SDL.RenderPresent(renderer);
        }

        SDL.DestroyRenderer(renderer);
        SDL.DestroyWindow(window);

        SDL.Quit();
    }
}

More examples can be found in SDL3-CS.Examples.

🀝 Feedback and Contributions

Found a bug or have an idea? Open an issue or start a discussion.

Please follow the Code of Conduct in all project interactions.

You can contact the maintainer at eduardgushchin@yandex.ru or join the Telegram chat for questions and feedback.

πŸ’» Contributors

SDL3-CS contributors

See the full list of contributors who participated in this project.

πŸ“ƒ License

SDL3 and SDL3# are released under the zlib license. See LICENSE for details.

About

This is SDL3#, a C# wrapper for SDL3.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors

Languages