Chapter 1 – Introduction

The introduction is short. SDL abbreviates Simple Direct Media Layer. It is a library to develop powerful applications for many different operating systems (OS, e.g. Linux, Windows XP and later, MacOS X, iOS, Android) by learning only one set of commands. This is called cross-platform development.

Internally the SDL library translates your commands to the OS specific commands. It’s
especially meaningful to use the SDL library if you plan to develop games or need fast paced rendering. Jump and run-, Role-playing-, Real time/turn based strategy-, side-scrolling-, arcade-, board-, card-, simulation-, multi-user dungeon-, puzzle-, shooter-, network games and so on are possible, and any combination of these ;-).

In August 2013 the successor of original SDL (SDL 1.2) has been released, simply called SDL 2.0. There are several packages out there which translate SDL 2.0 to Pascal, since originally it has been written in C. It is hard to predict which of those will be the “quasi-standard” units in the future. Anyway, let’s discuss them one by one. Right now I’m aware of four projects (if you know a further one, let me know):

Tim Blume's SDL 2.0 units Pure translation of SDL 2.0 source files. The original, modular structure of the header files is preserved, so the SDL2.pas is composed of many include files. Translations of SDL2_mixer, SDL2_ttf and SDL2_image are available, SDL_net seems to be missing so far. It provides MacOS X support.
p_daniel's (or danpla's) SDL 2.0 units Pure translation of the SDL 2.0 source files. All the header files of the original SDL 2.0 source code are combined into one large SDL2.pas (similar to JEDI-SDL's SDL.pas for SDL). Translations of SDL2_mixer, SDL2_ttf, SDL2_image and SDL2_net are available. The MacOS X support is unproven.
Imants Gulis' SDL 2.0 units Heavily modified SDL 2.0 units to allow for dynamic loading of the library.
Bare Game Library Bare Game is a game library which is put on top of the SDL2 library. It also allows for easy combination of SDL2 with Lazarus, which is a great plus.

So, which one to choose? – If you are interested in the discussion, just keep on reading. You may otherwise skip the following discussion and go to conclusion.

Modified header translations

Well, the Bare Game Library is a great project and I like the idea to provide an easy-to-use game development library  very much but it isn’t suitable to learn pure SDL 2.0. Many functions are wrapped by new function names, you would learn much about the usage of Bare Game, fewer about SDL 2.0 itself. Also, the ease of use is traded for flexibility, e.g. there is just support for Windows and Linux, no Mac support, and you are more or less forced to use Lazarus IDE (which is an excellent choice, no question!) but for some reason you might not want to use Lazarus. The usage of libraries always trades ease for flexibility. And finally you are dependent upon a second project. If SDL 2.0 is updated, will Bare Game have updates, too? Bare Game is a great project at all, but for learning SDL 2.0 and if you keep the downsides in mind, it is not the best choice here.

Imant’s Gulis units allow for dynamic loading of SDL 2.0, hence your application decides during run-time if SDL 2.0 has to be loaded. This led to heavily modified unit files compared to the original header files. Also it is expected to use Lazarus. Although there are numerous cases where dynamic loading can be a great plus, for the tutorial and a wide variety of applications this is not necessary.

Pure header translations

So there are two projects left. The beauty of p_daniel’s SDL 2.0 units is the fact that there are exactly five files you need. They contain all the translations for basic SDL 2.0 and the official extensions SDL2_mixer, SDL2_ttf, SDL2_image and SDL_net. Tim Blume’s SDL 2.0 units are trying also to support the MacOS X ability of SDL 2.0. That is one important plus for Tim Blume’s SDL 2.0 units. Furthermore, the original comments are kept in the translated files, whereas in p_daniel’s SDL 2.0 units they are cut out! This is a major drawback for p_daniel’s SDL 2.0 units to my mind. Sometimes you need just a quick look at the implementation of a function in the source to get how it works or what is wrong, and these comments are really quite descriptive. In Tim Blume’s SDL 2.0 units though, I don’t like that the file names got changed, e.g. SDL_audio.h got instead of Anyway, this is acceptable to me.


This said, to my mind, the best choice to start with pure SDL 2.0 and Free Pascal: Go for Tim Blume’s SDL 2.0 units.

Now let’s proceed to Chapter 2 (Windows or Linux) and learn how to install SDL 2.0. If you did install SDL 2.0 for Free Pascal already, proceed to Chapter 3.

Chapter 2 (Windows) → | Chapter 2 (Linux) → | Chapter 3 →

Leave a Reply