Friday, October 10, 2014

Setting up SFML.Net

SMFL.Net is a binding of the Simple and Fast Multimedia Library that allows us to use its functions in C# and VB.Net. It's simple to use (hence the name) and portable (although my tutorials will only focus on Windows).

However, setting it up requires some extra work compared to some other libraries. The pre-built libraries available on the SFML website are not only a year old (so they're missing quite a few changes made since then), but the dependencies included probably won't work and one of the DLLs is MIA (technically it wasn't missing at the time, but now it's an important part of the library).

(I know things have been mostly OpenTK up until this point, but I needed a bit of a break. And if these SFML.Net tutorials go on long enough, they'll end up back in OpenTK territory, so don't worry!)


For these reasons, it's strongly recommended to build the libraries yourself from the source available on their GitHub page.

Once you've either cloned their repository or downloaded the zipped version, you'll also need new versions of the CSFML libraries. You can build these yourself, from another GitHub repository, but you can also save time and effort by using pre-built libraries provided by eXpl0it3r on the SFML forums (don't worry about the name, his libraries are good!). There's a pull request for including more recent libraries with the main SFML.Net repo, so this might not be required at some point in the future. Make sure you have the correct build (x86 or x64).

To get started on building SFML.Net, you just need to open the solution (in the vc2008 folder in the build folder). If you have Visual Studio 2010 (or newer), you'll need to let it convert the project and solution files to the newer version. Build the sfml projects, and it will generate four class libraries for you to use in your projects (they're output to the lib directory, with a folder for the architecture you built for). You should have four "sfmlnet" libraries: audio, graphics, system and window.

Now you're ready to add it to a Visual Studio project. The SFML.Net libraries must be added as references, and then the dependency libraries need to be added as existing files (make sure Copy to Output Directory is set to "Copy always"). With the files in place, you'll be ready to follow the other tutorials (setting up a project file will be gone over in the first tutorial as well).

No comments:

Post a Comment