Basic C# binding setup question

Hi,

Not sure if this is the appropriate place for this question, but here goes.

I was developing a 2d game using the built in draw functions in csharp but performance was horrid so I’m planning to use sdl to get adequate performance, but since I’m using csharp need to use bindings for that, and I’ve never used bindings before. Tried searching for basic binding setup but didn’t get too far with my search results.

I got the binary sdl2 dll, and I also got the SDL2.cs c# binding source. As mentioned I’ve never used bindings before, tried adding a reference to the sdl2.cs in visual studio but it didn’t appear as an option under browse unless ‘all files’ was selected on browse, which suggest this might not be the correct course of action. I’m thinking that compiling the sdl2.cs as library file and then adding that as reference might work, but not sure. Also do I also need to put the sdl2.dll binary in the project for the binding to work? Is compiling sdl2.cs as library file and adding reference all that is needed? if not what is the basic procedure for binding setup?

Thanks In advance,
Daedalus17

Hi,

Not sure if this is the appropriate place for this question, but here goes.

I was developing a 2d game using the built in draw functions in csharp but performance was horrid so I’m planning to use sdl to get adequate performance, but since I’m using csharp need to use bindings for that, and I’ve never used bindings before. Tried searching for basic binding setup but didn’t get too far with my search results.

I got the binary sdl2 dll, and I also got the SDL2.cs c# binding source. As mentioned I’ve never used bindings before, tried adding a reference to the sdl2.cs in visual studio but it didn’t appear as an option under browse unless ‘all files’ was selected on browse, which suggest this might not be the correct course of action. I’m thinking that compiling the sdl2.cs as library file and then adding that as reference might work, but not sure. Also do I also need to put the sdl2.dll binary in the project for the binding to work? Is compiling sdl2.cs as library file and adding reference all that is needed? if not what is the basic procedure for binding setup?

Thanks In advance,
Daedalus17

I’ve never looked into sdl.cs code file, I didn’t even knew that c# binding was available for sdl, but I’m going to answer the question anyways.
If sdl.cs is what I think it is - the c functions signatures for the sdl functions inside sdl.dll - all you have to do is add sdl.cs to your project file and build. Now you can invoke c functions from sdl.dll from your c# code. You don’t need to create a separate C# class library for this.