A Simple SDL Program

If you want to test your SDL installation to make sure it all works, here is a sample SDL program which you can download and compile.

Put the file into your project directory, add the .c file to your project and build and run it. Don't forget to follow the instructions in the "Building an SDL Program" section of this tutorial.

The example program should produce some moving coloured patterns on the screen. If it flickers or does not run, your graphics card may not support 640x480 with a colour depth of 32 bits. We'll discuss in the tutorial how to modify the program so that it will support other graphics modes.

If the program does not even compile, more than likely you have set up SDL incorrectly. Log in to our forum and discuss the problems you are having and someone will almost certainly help you out.

There are more example test programs in the SDL source code zip file which you will have obtained from the SDL website.

Over the next few lessons we will discuss this basic SDL program, how it works and how to modify it to your own ends. Later lessons in this module discuss the creation of game-like graphics, based on these simple SDL beginnings.