SDL-Sharp 2.2.5

dotnet add package SDL-Sharp --version 2.2.5                
NuGet\Install-Package SDL-Sharp -Version 2.2.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SDL-Sharp" Version="2.2.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SDL-Sharp --version 2.2.5                
#r "nuget: SDL-Sharp, 2.2.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SDL-Sharp as a Cake Addin
#addin nuget:?package=SDL-Sharp&version=2.2.5

// Install SDL-Sharp as a Cake Tool
#tool nuget:?package=SDL-Sharp&version=2.2.5                

SDL-Sharp

Is a SDL2 for c#. The wrapper provides bindings for the following libraries (contains the necessary DLLs for the project in SDL-Sharp-DLL):

  • SDL2 (2.30.7) in SDL_Sharp
  • SDL2_image (2.8.2) in SDL_Sharp.Image
  • SDL2_mixer (2.8.0) in SDL_Sharp.Mixer
  • SDL2_ttf (2.22.0) in SDL_Sharp.Ttf
  • Utils (functions that facilitate the development)

To use opengl and openal in SDL we recommend using Silk.NET and OpenTK

New Nuget

Nuget Obsolete

Note1: All extensions have all functions (or should have) updated, and nuget has updated DLLs. 
However the SDL has been down in time since update (2.0.7), and has many new functions between (2.0.8) and (2.24.1).
I'm working to go adding these functions until the latest update, in case it's (2.24.1).
Note2: News are coming in this project, it has been updated again!!!!!

How to setup

First install SDL-Sharp nuget in your .NET project

Before using any SDL function, consider calling SdlLoader.LoadDefault();, this function will load the necessary DLLs for the project. Otherwise, you will have to load the DLLs manually.

Linux

Just install the sdl using a package manager of your system that SDL-Sharp will already use the sdl binaries

Windows

Just install SDL-Sharp-DLL nuget in yot .NET project

Base projects for SDL-Sharp

The SDL-Sharp project was made based on other projects:

With some modifications in both

About this Project

  • This project aims to make SDL2 non-aggressive in c#

  • In SDL-Sharp Window, Renderer, Texture, Font and Music are pointers same as IntPtr. So the SDL.CreateWindow() function returns a Window and not a Window* (exemple)

  • However Surface, Chunk and others are not pointers, so the functions return a Surface* or PSurface (example), in these cases there are P(Structure name) such as PChunk, PSurface... (P of pointer)

  • To be able to use pointers in C#, you have to enable Unsafe Code and use these pointers (void*) inside an unsafe { //Pointers here// }

Exemple 1 (SDL2#)

SDL2# code would look like this:

SDL.SDL_Init(SDL.SDL_INIT_VIDEO);

IntPtr window = SDL.SDL_CreateWindow("Window", SDL.SDL_WINDOWPOS_UNDEFINED, 
  SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN);

IntPtr renderer = SDL.SDL_CreateRenderer(window, -1,
  SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED | 
  SDL.SDL_RendererFlags.SDL_RENDERER_PRESENTVSYNC);

Exemple 2 (SDL-Sharp)

And on SDL-Sharp like this:

SDL.Init(SdlInitFlags.Video);
Window window = SDL.CreateWindow("Window", SDL.WINDOWPOS_UNDEFINED, SDL.WINDOWPOS_UNDEFINED, 800, 600, WindowFlags.Shown);
Renderer renderer = SDL.CreateRenderer(window, -1, RendererFlags.Accelerated | RendererFlags.PresentVsync);
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.5 160 9/21/2024
2.2.4 99 9/16/2024
2.2.3 225 6/2/2024
2.2.3-beta2 209 11/26/2023
2.2.3-beta1 89 11/26/2023
2.2.2 857 10/22/2022
2.2.1 362 10/22/2022
2.2.0 439 7/24/2022
2.1.2 513 5/7/2022
2.1.1 422 5/7/2022
2.1.0 419 5/2/2022
2.0.1 427 5/1/2022
2.0.0 425 4/27/2022

Add SdlLoader