# Using SDL for C++ Graphics

Published: 2016-03-14
Last updated: 2022-01-26

A few days back, I tried to explain why in my opinion Indian colleges should [abandon Turbo C++](http://blog.gldraphael.com/why-you-shouldnt-be-using-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](https://www.libsdl.org/).

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](http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php). 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](http://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](https://github.com/gldraphael/SdlStaticTemplate) on github will help you get started.

