Jach's personal blog

(Largely containing a mind-dump to myselves: past, present, and future)
Current favorite quote: "Supposedly smart people are weirdly ignorant of Bayes' Rule." William B Vogt, 2010

Hello World to get with the times using SDL2 and Common Lisp

Long ago I learned how to program simple 2D games using PyGame. PyGame was built around a C library, SDL 1.2, and both presented a very attractive model for programming 2D games that followed from some old-school techniques. Specifically, the structure of your game was built on the assumption of a single CPU talking to a video memory buffer used by the display to show pixels. If you wanted to make a 3D game, you could do it classically with a pure software renderer, controlling every pixel. Of course to be more useful SDL allowed you to setup an OpenGL context, so you could make a 3D game taking advantage of graphics cards, but you'd do it with OpenGL; SDL wouldn't help you with the actual video part of that, though it remained very useful for input polling, sound, and other game programming aspects.

Times have changed, and almost everyone has some sort of 3D acceleration hardware even if it's bundled with their CPU. CPUs have more cores. Resolutions are higher. More people have multiple monitors. The optimal graphics pipeline is very different than it once was. CPUs are also faster, so it's not like you can't do software rendering, but you're leaving a lot of performance on the table that could be used to do more stuff per frame in your game. So SDL2 was made to address modern realities while keeping a nice high level API to create 2D games. Things aren't that different, but now you can get a huge performance boost, because SDL2 will do hardware stuff behind the scenes on your behalf.

I've played with SDL2 a few times since it's been out, and each time left not too satisfied. For some reason I never bothered to read the Migration Guide. Reading it this time I've convinced myself SDL2 is the right approach and worth relearning a few things and changing approaches to take advantage of it. In other words it's time to get with the times. The guide also explains the main approaches people have used to make 2D games and how each approach can be, with few drastic changes, done just fine with SDL2, but now can be much faster.

See Full Post and Comments