Chapter 1: Introduction, installation and configuration (JEDI-SDL)

This is an SDL 1.2 chapter. SDL 1.2 is obsolete since it has been replaced by SDL 2.0. Unless you have good reasons to stay here you may prefer to go for the modern SDL 2.0 :-).

The introduction is short. SDL library gives you the ability to develop powerful applications for many different operating systems (OS, e.g. Linux, Windows, MacOS) only by learning one set of commands. The SDL library takes on the assignment to translate your commands to the specific OS commands. It’s especially meaningful to use the SDL library if you plan to develop two-dimensional games or similar software. Role-playing-, Real time/turn based strategy-, side-scrolling-, arcade-, board-, card-, simulation-, multi-user dungeon-, puzzle games and so on are possible. SDL helps you to set up easily an SDL/OpenGL environment which allows for creation of 3d applications. This finally allows even for three-dimensional games.

Now something about the licensing: Both, Free Pascal and the SDL library are free and your created work can be used in commercial programs! The license of Free Pascal is: modified LGPL and the license of SDL: GNU LGPL.

By this the introduction to SDL is finished already. Before you accidently proceed reading the manual installation of the SDL units for the Free Pascal compiler (FPC) I’d like to express that since version 2.2.2 of FPC the pure, pre-compiled JEDI-SDL units are released along with the compiler so actually there is no need to install the SDL units manually anymore. Keep in mind though, many chapters assume you did the manual installation, so there are some envornment settings described you can skip. You don’t have to set individual pathes to the different unit files. However, what you always HAVE TO consider is the download and copy of the corresponding DLL files described in the chapters. If you already have installed Free Pascal (version 2.2.2 or later) just go on with Chapter 1a now.

If you decide to do the manual installation there are two different unit packages which allow the development of SDL applications with the Free Pascal environment. If you don’t know which to choose I recommend strongly to choose the package of the JEDI-SDL Project! It is more advanced and supports a greater variety of features. This is also the package which is included in FPC nowadays.

LINUX USERS: The following description of the configuration is related to the MS Windows OS. The further chapters (except chapter 1 and 1a) will work for Linux OS, too. (If you want to contribute a configuration tutorial for Linux OS let me know; you would be mentioned as author of course.)

Which package of SDL units you want to install (MS Windows OS)?

JEDI-SDL (recommended)

SDL4FP

Now this chapter concerns on the installation of all necessary software on your system for programming SDL applications with Free Pascal on Windows XP (probably this will work for other Windows systems as well; please report if you tried out; what about Vista?).

First of all, we have to consider which software is needed. We need three different software packages. We need the Free Pascal compiler of course. Furthermore we need the original SDL library files and finally we need something what translates our Pascal programs to the SDL library (written in C/C++). This will be done by a few units. These units come from the JEDI-SDL Project (Joint Endeavor of Delphi Innovators – Simple Direct Media Layer Project).

This table provides all information you need about the files you need to download with respect to installation steps 1) – 3).

Software Version Size, MB Source Description
fpc-2.2.4.i386-win32.exe 2.2.4 ~35 http://www.Free Pascal.org Download the latest stable Free Pascal compiler.
JEDI-SDLFullSetup.exe
(Full Installer!)
1.0 Final RC2 ~5 Main site:http://jedi-sdl.pascalgamedevelopment.com/
Downloads:http://sourceforge.net/forum/forum.php?forum_id=724777
Download the latest version of JEDI-SDL package.
SDL-1.2.13-win32.zip 1.2.13 ~0.1 http://www.libsdl.org (German readers may prefer: http://www.libsdl.de/) Download the latest stable runtime library of SDL.

1) Download the latest stable Free Pascal compiler, version 2.2.4 or higher.

2) Download the latest version of JEDI-SDL, version 1.0 Final or higher. Be sure it is the full installer (not headers only or demos only).

3) Download the latest version of SDL runtime library, version 1.2.13 or higher.

Of course, if you have installed Free Pascal already you haven’t to download it again and you can skip step 4.

4) Execute “fpc-2.2.4.i386-win32.exe” to install Free Pascal. Let the self-installer create a shortcut on your desktop. Don’t modify any checked options during installation process. The default path is: ‘C:\FPC\2.2.4\’.

5) Extract “SDL-1.2.13-win32.zip” to get the SDL runtime library. This leads to two extracted files. There is a text file and the very important SDL.dll.

6) Copy those files (especially the SDL.dll!) to your
system32-folder! Usually you find it at “C:\WINDOWS\system32\”.
Don’t confuse it with the similar system-folder. (This works for
WinXP, probably for NT-series and Win2000 as well; if you use Win9x
or WinME you should copy it to system-folder instead of system32-folder)

If it isn’t possible for any reason to copy the files into this folder you later have to copy that file into the same folder where the application is. Now you have installed Free Pascal and the SDL runtime library on your system. Finally JEDI-SDL has to be installed.

7) Execute the “JEDI-SDLFullSetup.exe” and follow the installer’s instructions. Since you should avoid a folder name like “JEDI-SDL Full” which is suggested by the install program when asking for the install path, I suggest as full path: “C:\FPC\2.2.4\units\JEDI\”. All later tutorials will assume you installed to this path.

Now the compiler has to be told about where to find the new units.

8) Open the Free Pascal IDE (for example by clicking the shortcut on desktop).

9) In the menue choose the following item “Options”. From “Options” choose “Directories…”. Now a window should pop up.

10) The first tab whitin this new window is called “Units”. Here you add the full path to your SDL-units (e.g. C:\FPC\2.2.0\units\JEDI\SDL\Pas) below the other pathes. Leave the last backslash out. Make sure the path leads to the folder, where the sdl.pas file is located! This file contains all the basic features of SDL.

JEDI-SDL Directories

The picture doesn’t show the correct path! It is old. We use “C:\FPC\2.2.4\units\JEDI\SDL\Pas” instead. Confirm by clicking “OK”.

Congratulations! You have configured your system for developing SDL applications with Free Pascal! Now let’s check if it really was that easy…

11) To check if you installed your system successfully download the file demo02.pp (right click and “save as”) into demo-folder (C:\FPC\2.2.4\demo\) or anywhere else.

12) Open this file and run it.

If you see some cool colourful red and blue lines you have done everything as it has to be done :)! Have fun with your configured system!

For those of you who try running the demo and get an abortion together with a messege saying “exitcode = 309”: You skipped step 6! Did you copy the SDL.dll to your system32- or system-folder respectively? If so and the error still occurs you should copy the SDL.dll into the folder where the demos are placed. Now it should work.

VERY IMPORTANT

Since most users will not install FPC/SDL manually I removed the information about setting up the unit pathes in the compiler settings part of each individual chapter. However for you, without setting the unit pathes in your IDE you will get errors. Next is a list of the settings for each chapter where necessary IF you do the manual installation.

Chapter 3a

1) Make sure your compiler finds the new unit. (IDE: Options –> Directories… –> Units)

JEDI-SDL Directories for font handling2) Copy the file “jedi-sdl.inc” from the “../SDL/Pas”-folder into the “../SDL_image/Pas/”-folder. Both folders are located in the JEDI-SDL project folder (e.g. C:\FPC\2.2.4\units\JEDI\). If you forget this you will get an error on compiling saying SDL_IMAGE is not finding jedi-sdl.inc.

3) You need this .dll file:

Software Version Source Description
SDL_image-1.2.7-win32.zip 1.2.7 http://www.libsdl.org/projects/SDL_image/ This is the corresponding dynamic link library file for unit and image formats.

Chapter 5

1) Make sure your compiler finds the new unit. (IDE: Options –> Directories… –> Units)

JEDI-SDL Directories for font handling2) Copy the file “jedi-sdl.inc” from the “../SDL/Pas”-folder into the “../SDL_tff/Pas/”-folder. Both folders are located in the JEDI-SDL project folder (e.g. C:\FPC\2.0.4\units\JEDI\). If you forget this you will get an error on compiling saying SDL_TFF is not finding jedi-sdl.inc.

3) You need this .dll file:

Software Version Source Description
SDL_ttf-2.0.10-win32.zip 2.0.10 http://www.libsdl.org/projects/SDL_ttf/ This is the corresponding dynamic link library file.

Chapter 7

1) Make sure your compiler finds the new units. (IDE: Options –> Directories… –> Units) For the usage of SDL_MIXER you have to include both, the SDL_MIXER itself and the SMPEG unit (which is used by SDL_MIXER unit). The SMPEG unit actually is only used for mp3 support but your programs will fail to run even if you don’t use mp3 files.

JEDI-SDL Directories for sound handling2) Copy the file “jedi-sdl.inc” from the “../SDL/Pas”-folder into the “../SDL_Mixer/Pas/”-folder and “../smpeg/Pas/”-folder. All folders are located in the JEDI-SDL project folder (e.g. C:\FPC\2.0.4\units\JEDI-SDLv1.0\). If you forget this you will get an error on compiling saying SDL_Mixer or smpeg is not finding jedi-sdl.inc.

3) You need this .dll file and a music and sound file:

Software Version Source Description
SDL_mixer-1.2.8-win32.zip 1.2.8 http://www.libsdl.org/projects/SDL_mixer/ This is the corresponding dynamic link library file.
In my mind.ogg In-my-mind.ogg A music file. “In my mind” by First. Of course you could also use any other music file you desire.
dial.wav dial.wav Public domain sounds: http://www.pdsounds.org. Of course you could also use any other sound file you desire.

Chapter 8

1) Make sure your compiler finds the new units. (IDE: Options –> Directories… –> Units) You will need to add the path to the OpenGL units GL and GLU. GL provides the whole basic OpenGL functionality and GLU (OpenGL Utilities) provides some additional functions which are very useful but not provided as basic functions of OpenGL (version 1.1).

JEDI-SDL Directories for OpenGL support2) Copy the file “jedi-sdl.inc” from the “../SDL/Pas”-folder into the “../OpenGL/Pas/”-folder. All folders are located in the JEDI-SDL project folder (e.g. C:\FPC\2.2.4\units\JEDI\). If you forget this you will get an error on compiling saying GL or GLU is not finding jedi-sdl.inc.

3) You need this software:

Software Version Source Description
OpenGL driver Usually your graphic card provides the corresponding OpenGL driver and you don’t have to do anything. And if so it is very likely that version 1.1 is fully supported. However if you are one of the few poor people whose graphic card doesn’t support OpenGL, check the graphic card’s manufacturer’s homepage for OpenGL drivers.

Leave a Reply

Your email address will not be published. Required fields are marked *