Which SDL2 unit to choose?

Last updated on August 13th, 2022

Right now I’m aware of these translation projects that provide SDL2 units (if you know a further one, let me know):

Project
Link
Description
SDL2 for Pascal units Pure translation of SDL2 source files. It is based on a fork of Tim Blume's SDL2 units, but is updated quite regularly.
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.
Daniel Plachotich'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.
LazSDL2 units Heavily modified SDL 2.0 units to allow for dynamic loading of the library by Imants Gulis.
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. [Official website (baregame.org) is down, is the project dead?]

Now we go for a detailed discussion of them.

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. It has been updated back in 2019 the last time.

Imants Gulis’ LazSDL 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. The last update is from 2016.

Pure header translations

The unmodified header translations of the original SDL 2.0 headers is the best choice when it comes to learning SDL 2.0.

The beauty of Daniel Plachotich’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. Unfortunately, the original comments are cut out. This is a major drawback 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. Also the MaxOS support is unproven. The last update happened in 2015.

In contrast Tim Blume’s SDL 2.0 units kept the comments. The unit names differ slightly from the original names (e.g. SDL_audio.h got sdlaudio.inc instead of SDL_audio.inc ), which I don’t like, but it is acceptable. This allows for a better understanding in how SDL 2.0 works. Also it allows for better flexibility with regards to later projects.

After a lack of updates for one year, the PGD Community decided to fork Tim Blume’s units and establish SDL2 for Pascal. It is a regularly updated version of Tim Blume’s units and has changed drastically as a result.

Conclusion

This said, to my mind, the best choice to start with SDL 2.0 and Free Pascal: Go for the units of SDL2 for Pascal. For other purposes, other units may be the better choice.