This is one of my older tutorials and follows a style unlike
my current one. I also no longer hold the same claims I made about the SDL
documentation that I originally made in this article. I think it's perfectly
fine. You just need to spend some time looking around because it's not
organized like other documentation is. For that reason, I have no plans to
continue this tutorial series unless someone specifically asks for me to
continue it.
#+END_EXPORT
SDL2 is my favorite graphics library right now. It might not be as powerful as
something like raw OpenGL, but it's simple. Simple enough that you can just
pick it up and start using it. There's a glaring issue with it, though. The
documentation is horrible. Absolutely horrible. A lot of it is unfinished, and
it doesn't look like it's getting attention any time soon. The SDL1.2
documentation wasn't as bad, but that version of the library is vastly outdated
by today's standards. So here's my take on a tutorial for SDL - part 0x00 of a
I-don't-know-how-long-I'm-going-to-drag-this-on series. My examples are going
to be written in C, because the constructs I show here can still be used
verbatim in C++ (and probably SDL's other language bindings as well). This
tutorial will be covering the little boilerplate that SDL requires, as well as
the basics of windowing and rendering. Let's get into it.
The first thing you have to worry about is installing and setting up SDL2.0. I
won't cover it in detail because it's something you should be able to figure out
yourself. If your operating system doesn't provide a means of package
management, you should be able to find a download on the [[https://libsdl.org/][official website]].
You should also figure out how to link SDL2 when you're compiling, nothing I
teach here will work if it isn't properly linked. If you're having trouble with
anything, fire up your favorite search engine or feel free to [[http://tsar-fox.com/][contact me]].
Alright, assuming you've successfully installed SDL, let's get to actually
programming. As with any C library, the first thing you should worry about is
including the header files. While SDL provides header files for specific
subsystems, we're not going to worry about that right now. There's a header
file that contains everything and we're going to use that for right now.
#+BEGIN_SRC c :hl_lines 0
#include