Using SDL for C++ Graphics

A few days back, I tried to explain why in my opinion Indian colleges should abandon Turbo C++ for a more modern (and standard compliant) C++ compiler. However, most colleges have courses on Computer Graphics for which they tend to use the 16 bit graphics.h, and that's not supported by most modern compilers. An alternative to using graphics.h is using an API like SDL.

Take a look at the following program that draws a line using graphics.h and was compiled and tested in Turbo C++:

The algorithm is implemented in lines 21 - 44. We will port this program to use SDL rather than graphics.h.

SDL stands for Simple DirectMedia Layer. It's a cross platform game development open-source library.

Since SDL is a third party library, you'll have to manually setup your compiler to use it. You can find a setup guide for Visual Studio here. SDL opens up new possibilities that just cannot be done with graphics.h, and if you're really interested, you might even make a few simple games by the end of the Computer Graphics course in your college. I learnt SDL from lazyfoo.net and I recommend it.

If all you're going to be using SDL for is to write the same kind of programs you were writing with graphics.h, this repo on github will help you get started.