🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

SDL-Sharp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

SDL-Sharp

Is a SDL2 for c# The wrapper provides bindings for the following libraries: - SDL2 (2.30.7) - SDL2_image (2.8.2) - SDL2_mixer (2.8.0) - SDL2_ttf (2.22.0) - Utils (functions that facilitate the development) And contains the necessary DLLs for the project in SDL-Sharp-DLL

2.2.5
Source
NuGet
Version published
Maintainers
1
Created
Source

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);

Keywords

FAQs

Package last updated on 21 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts