Frequently asked questions

From SDL.NET

The following is some quick information about SDL.NET along with some questions that are frequently brought up by users.

Table of contents

The Library

What is the difference between SDL.NET and Tao.Sdl?

Tao.Sdl (http://www.mono-project.com/Tao) contains the low-level .NET bindings (P/Invoke) to the SDL C library and related libraries. I wrote Tao.Sdl with some help from Randy Ridge and I am a regular contributor to the Tao project. The Tao.Sdl bindings are meant to match the C API very closely for ease of maintainability. Programmers moving from the SDL C API can easily use this version of the library. Tao.Sdl is released under the MIT license.

SDL.NET takes Tao.Sdl and wraps it in an Object-Oriented interface. SDL.NET provides an easy way to use SDL in .NET. Also the project provides many code examples.

What license is SDL.NET released under?

LGPL. The text can be found at the Gnu Website (http://www.gnu.org/licenses/lgpl.txt).

What supporting libraries do I need?

You need to have the .NET Framework 2.0 (http://www.microsoft.com/) installed or you can use Mono (http://mono-project.com) on Linux and Mac OSX. You also need to have the SDL libraries installed:

For Linux, make sure also to install the devel versions of the libraries as well.

Using SDL.NET

An error is brought up on the first SDL.NET statement.

You are probably missing the required Win32 libraries. They can be found in the /lib directory and must be placed in either your application path, or your Windows/System32 path. If you are using Linux, you may need to install some dependencies.

An MPEG-1 movie runs very slowly and has no sound

The smpeg and SDL_mixer libraries conflict when running an MPEG-1 movie. You must call Mixer.Close() before instantiating a new Movie object.

Optimize SDL.NET

These are a few things to think about when looking to optimize your application.

Rotation

Rotation is dead slow as it needs to be done on the processor. If you're doing rotations, find a common ground between required rotations and not required rotations. You will want to use pre-rendered graphics as much as possible.

Software to Hardware Rendering

If you're blitting a surface onto another surface, make sure that both surfaces are in the same memory location (software or hardware). SDL.NET gives you this option when creating new surfaces. You could try using all hardware surfaces, and then using all software surfaces and then seeing which is faster for what you're doing.

Alpha Blending

Alpha blending is actually pretty fast in SDL as it's usually done on the hardware device. If the card doesn't support 2D blending, it's again done on the processer which can be slow (definately not as slow as rotations though). You should not have to worry about this unless you're doing a mass amount of complex alpha blending. Additionally, SDL optimizes the specific case where the alpha value is equal to 128 (exactly half-transparent), so use of this value will generally speed things up as well.

Surface Formats

Ensuring that all of your surfaces have the same pixel format (16-bit, 24-bit, etc) will also speed up your application in most cases. The best pixel format to use tends to be the same as whatever your Video.Screen's pixel format is. You can convert the pixel format like so:

Surface tmp = new Surface("myImage.bmp");
tmp = tmp.Convert(Video.Screen);

Regional Updates

The basic concept is that instead of updating the whole screen every tick, you update a portion of it instead, possibly saving valuable processor ticks. SDL.NET implements this concept through its sprite system. Take a look at the bouncing sprites example for a demonstration of their use. Although this might not be best for your situation, it has been known to provide quite a boost in performance in some applications.

Update SDL.NET

SDL.NET is updated frequently and many of these updates fix performance issues. Keep up to date with it and make sure to bring your issue to the Forum (http://cs-sdl.sourceforge.net/forum).

Lexicon

These are terms that are commonly used with SDL.NET.

Blit

A blit occurrs when two bitmap images combine into one. In SDL.NET, this is used to describe the effects of rendering one Surface onto another.

Boo

Boo (http://boo.codehaus.org) is a new object oriented statically typed programming language for the Common Language Infrastructure (http://en.wikipedia.org/wiki/Common_Language_Infrastructure) with a Python (http://www.python.org) inspired syntax and a special focus on language and compiler extensibility.

You can develop SDL.NET applications using Boo (http://boo.codehaus.org) as both languages are CLS (http://msdn2.microsoft.com/en-us/library/bhc3fa7f(VS.80).aspx) compliant. For more information on this, please visit Boo's (http://boo.codehaus.org) official website.

Nemerle

Nemerle (http://nemerle.org) is a high-level statically-typed programming language for the .NET platform. It offers functional, object-oriented and imperative features. It has a simple C#-like syntax and a powerful meta-programming system.

Since Nemerle is CLS-compliant, it can be used to develop with SDL.NET.

OpenGL

Rendering from SDL.NET can be done through OpenGL using the Tao.OpenGL library. Some OpenGL/SDL integration can be done via the SurfaceGL class in the SdlDotNet.OpenGl namespace.

Examples

Tao.FreeGlut

Tao.FreeGlut are .NET bindings to the FreeGlut (http://freeglut.sourceforge.net/) library.

Tao.OpenGl

Tao.OpenGL are .NET bindings to the OpenGL library.

SDL.NET has the capability to link up to these bindings when rendering with OpenGL.

The OpenGL Programming Guide aka the Red Book is available online.

Tao.Platform.Windows

Tao.Platform.Windows are .NET bindings to the OpenGL library for Windows-specific functionality.


See Also

See Also