The absolute newbies guide to SDL.NET

From SDL.NET

This article introduces SDL.NET and offers some information regarding the assembly and its dependencies.

Table of contents

What is SDL.NET

SDL.NET is a set of object-oriented .NET bindings for SDL - a cross-platform multimedia library designed to provide level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

Home Page: http://cs-sdl.sourceforge.net

Current Maintainer: David "jendave" Hudson (jendave@yahoo.com)

Approach: SDL.NET's API is modelled somewhat after PyGame (http://www.pygame.org). Since PyGame is a successful object-oriented wrapper around SDL, it made sense to look to PyGame for inspiration. Obviously there will be areas where they will differ.

Assembly

Zip/tar file contains:

  • /bin - Assemblies
  • /examples - demo apps and extra libraries based on SDL.NET
  • /lib - Dependencies. e.g. SDL.dll, SDL_gfx.dll etc. Please put these libs in your path.
  • /doc - CHM files (zip). HTML files (tar)
  • /source - info files, Strong name keys, build/solution files.
  • /source/examples - source for demo apps and extra libraries based on SDL.NET
  • /source/lib - library dependencies.
  • /source/src - SDL.NET source
  • /source/setup - build scripts
  • /source/tools - utils and logos
  • /source/tests - unit tests

Dependencies

Make sure these are in your path.

Installation Under Windows

If you're using Windows and wish to develop using SDL.NET, please follow the following instructions. You can either install it using the installers or the zip archive.

Using the Runtime Installer

This file is used to install just the runtime files. This is aimed at end-users of SDL.NET who do not plan to use the source code.

  1. From the SDL.NET download page (http://sourceforge.net/project/showfiles.php?group_id=52340), download SdlDotNet-x.x.x-runtime-setup.exe .
  2. Double-click on the installer and follow the instructions.

Using the SDK Installer

This file is used to install the full SDK for SDL.NET. This is aimed at developers who may want access to the SDL.NET source code.

  1. From the SDL.NET download page (http://sourceforge.net/project/showfiles.php?group_id=52340), download SdlDotNet-x.x.x-sdk-setup.exe .
  2. Double-click on the installer and follow the instructions.
  3. If you want to build SDL.NET yourself, use the solution file or double-click on the build.bat file (uses NAnt).

Using the Zip archive

  1. From the SDL.NET download page (http://sourceforge.net/project/showfiles.php?group_id=52340), download and unzip the SdlDotNet-x.x.x.zip file.
  2. Copy the files located in the /bin directory (SdlDotNet.dll and Tao.Sdl.dll) into the Global Assembly Cache (c:\winnt\assembly).
  3. Copy the files from /bin/win32deps into a directory in your path. (C:\winnt\system32 is a common choice).
  4. If you want to build SDL.NET yourself, use the solution file or double-click on the build.bat file (uses NAnt).

Installation Under Linux

Installation can vary widely depending on the distribution. The following are instructions on installing SDL.NET on Debian (unstable) and using the generic rpm files. You may need to extrapolate these instructions to install SDL.NET on your distribution.

Using the Tar.gz archive

  1. From the SDL.NET download page (http://sourceforge.net/project/showfiles.php?group_id=52340), download and uncompress the SdlDotNet-x.x.x.tar.gz file.

Debian Linux (testing) Installation

  • Use the SDL.NET tar.gz archive
  • Start the "Synaptic Package Manager" application
  • Install these packages:
mono
gtk-sharp
gtk-sharp2
libgdiplus
libsdl1.2debian
libsdl1.2debian-all
libsdl-mixer1.2
libsdl-image1.2
libsdl-ttf2.0-0
libsdl-gfx1.2-4
libsmpeg0
timidity
  • Note that many dependencies will also be installed as a result
  • You may want to install these packages as well
nant to perform a build
svn if you want to use svn to get the code
monodevelop-boo Mono IDE(this will also install monodevelop)
RapidSVN graphical interface for svn
libglu1-mesa for running the OpenGL examples. This will install the OpenGL libs as well.
  • The Tao.Sdl.dll.config and SdlDotNet.dll.config files needs to be in the same directory as the Tao.Sdl.dll and SdlDotNet.dll assemblies respectively so that Mono knows how to map the SDL dependencies. If you prefer you could edit the master mono config file (/etc/mono/config) to include the entries in the Tao.Sdl.dll.config and SdlDotNet.dll.config to obviate the need for copying the config file everywhere.
  • To run the OpenGL Demos (Gears, NeHe, RedBook but not OpenGlFont), you will need to also keep a copy of Tao.OpenGl.dll.config in the same directories as their respective assemblies. You could instead add them to the master mono config file as well.
  • If you want to build SDL.NET yourself, run the build.sh or use the solution file in MonoDevelop in the source direectory.
  • Go to the 'sdldotnet-x.x.x/examples' directory and type 'SdlDotNetExamples.sh' from a command line. The demo browser should start up. You can then choose an example to run.
  • The audio may not work by default. You may have to open up a terminal and type 'killall esd' before starting an SDL.NET (or any SDL) app. For a more complete audio solution read this thread from the ubuntu forums (http://ubuntuforums.org/showthread.php?t=44753).

RPM Installation

  • Use the SDL.NET tar.gz archive
  • Download and install SDL and related C libraries. You may be able to use a package tool included in your distro.
  1. Download SDL (http://www.libsdl.org/release/SDL-1.2.11-1.i386.rpm)
  2. Download SDL-devel (http://www.libsdl.org/release/SDL-devel-1.2.11-1.i386.rpm)
  3. Download SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.7-1.i386.rpm)
  4. Download SDL_mixer-devel (http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-devel-1.2.7-1.i386.rpm)
  5. Download SDL_image (http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.5-1.i386.rpm)
  6. Download SDL_image-devel (http://www.libsdl.org/projects/SDL_image/release/SDL_image-devel-1.2.5-1.i386.rpm)
  7. Download SDL_ttf (http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.8-1.i386.rpm)
  8. Download SDL_ttf-devel (http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-devel-2.0.8-1.i386.rpm)
  9. Download SDL_gfx (http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-2.0.16.tar.gz). Most distros have a compiled rpm package for this. If yours does not and you cannot locate a third-party rpm, you will need to compile and install the code yourself.
  10. Check out smpeg (http://cvs.icculus.org/smpeg/) code from their CVS repository. Most distros have a compiled rpm package for this. If yours does not and you cannot locate a third-party rpm, you will need to compile and install the code yourself.
  • Install the RPM files. Open a console and use:
rpm -Uvh SDL-1.2.9-1.i386.rpm SDL-devel-1.2.9-1.i386.rpm 
rpm -Uvh SDL_mixer-1.2.7-1.i386.rpm SDL_mixer-devel-1.2.7-1.i386.rpm  
rpm -Uvh SDL_image-1.2.5-1.i386.rpm SDL_image-devel-1.2.5-1.i386.rpm 
rpm -Uvh SDL_ttf-2.0.8-1.i386.rpm SDL_ttf-devel-2.0.8-1.i386.rpm 
  • If it fails, there may be more libraries that depend on the two above that you will need, though it's unlikely.
  • As per the Debian installation, you can copy the *.config files to the same directory as the assemblies. You could also edit the Mono config file.
  • Note that these values can vary widely on every distro so be careful. This is the first place to look if get an exception such as:
Unhandled Exception: System.DllNotFoundException: libSDL_ttf-2.0.so.0
  • Of course, your version may and the files may even reside in another libs folder. To locate an existing SDL lib, try the following (where "[lib]" is the specific library you are looking for):
updatedb
locate libSDL_[lib]

Starting a new MonoDevelop project

  • Fire up MonoDevelop and start a new C# console project.
  • In the project options, set the runtime option - runtime version to "2.0"
  • Right click on References and select "Edit References". Select the .Net Assembly tab and browse to the place where you unpacked the sdldotnet-6.x.x.tar.gz achive. Browse to the bin folder and select the files in there:
SdlDotNet.dll
Tao.Sdl.dll	
  1. Click "Open".
  2. SDL.NET makes a lot of use of the System.Drawing assembly, so click on the "Global Assembly Cache" and check System.Drawing.
  3. Click "OK" to add the assemblies to your project.
  • Replace the entire contents of your Main.cs file with SimpleExample code  (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/SimpleExample.cs?view=markup).
  • Compile and Run and you should have a 640 x 480 window appear cycling through colours.

Special thanks to sausage@zeta.org.au (mailto:sausage@zeta.org.au) for helping with the Linux documemtation.

Installation Under MacOS X

Using the .dmg file

  • From the SDL.NET download page (http://sourceforge.net/project/showfiles.php?group_id=52340), download and mount the sdldotnet-x.x.x.dmg file.
  • Copy the contents of the dmg to a desired location on your computer.
  • Using the .dmg files located in /lib, install all of the SDL dependencies.
  • Download and install Mono for MacOS X (http://mono-project.com/Downloads)
  • Edit the /Library/Frameworks/Mono.framework/Versions/Current/etc/mono/config file to include the entries from the SdlDotNet.dll.config and Tao.Sdl.dll.config files.
  • Double-click on 'SdlDotNetExamples' icon to start the examples browser.
  • Double-click on 'SdlDotNetCDPlayer' icon to start the CDPlayer demo.

Compiling under OS X

  • NAnt (http://nant.sourceforge.net) comes with the Mono installation.
  1. From the SDL.NET source directory, type './create-installer.sh' - This will do a complete release package build of SDL.NET including docs.
  2. MonoDevelop can use the solution files found in the /source directory to build SDL.NET. Note that running the examples from the IDE may have mouse/keyboard issues since MonoDevelop does not package the examples into OS X .app applications.

Next Steps

See Also