Skip to content
Justin Skiles edited this page Apr 17, 2020 · 3 revisions

Installation & Setup

Import NuGet

See the library in the NuGet gallery here.

Package Manager:

Install-Package SharpDL

.NET Core CLI:

dotnet add package SharpDL

Download Native SDL2 Libraries

After you've imported the NuGet package, you will still need to download the native SDL2 libraries for your platform and place the libraries alongside your executable.

Windows & Mac

Ubuntu

While the below will install SDL2 dependencies, SharpDL may still fail to function because of a limitation in the way .NET Core handles native library resolution when libraries are named differently across operating systems. See #7.

apt install libsdl2-2.0-0
apt install libsdl2-image-2.0-0
apt install libsdl2-ttf-2.0-0

Arch / Manjaro

This doesn't have the same limitation as Ubuntu because the libraries are distributed as simply libSDL2.so and thus are resolved by .NET Core properly. See #7.

pacman -S sdl2

Code Organization

SharpDL consists of four main projects: SharpDL, SharpDL.Events, SharpDL.Graphics, and SharpDL.Input. A project for audio is not yet available.

SharpDL
Responsible for the base Game class, GameTime, and some experimental classes such as Logger and Timer.
SharpDL.Events
responsible for various EventArgs implementations that are based on the SDL_Event union. For example, the SDL_Event union is processed in the SharpDL's Run loop, EventArgs of the proper type are created, and an event of that handles that type is fired. This allows for a more .NET-like event system.
SharpDL.Graphics
Contains any class that is responsible for graphical operations such as creating a SDL_Window, rendering with a SDL_Renderer, creating a SDL_Surface, or loading a SDL_Texture. Examples of some of these classes are Color, Font, Renderer, Window, Texture, TrueTypeText, and more. Some classes do not have direct relations to SDL structures such as Vector, which represents an X,Y coordinate in a 2D space.
SharpDL.Input
Contains classes to handle Keyboard and Mouse input by capturing mapped SDL structures into .NET-style enumerators. Joystick and controller input is not yet available.