Last time I was bemoaning that getting the time and space to build up a comfortable, capable toolkit was a pipedream. That might still be true—but everything’s got to start somewhere, right? This all starts here.

I decided to just see what I could get up and running in a day or two with Sokol, an open source, cross-platform graphics library: a thin wrapper over OpenGL, DirectX, and Metal apis. I picked it because it’s:

  • C
  • small
  • aims to do as little as possible

These attributes are pretty important.

If I’m going to get anything done quickly, I need to not be faffing about with complicated build systems or new toolchains. C is easy to use in this way: I can build and run with just the incantation cc foo.c -o foo && ./foo—no need even for makefiles, let alone any bigger build system. And I’m familiar enough with C to be comfortable in it.

And I definitely wasn’t going to let C++ get anywhere near this project.

Things that are small and aiming to be simple—as Sokol does—are much more likely to be simple and straightforward. And if something’s simple and straightforward, it’s easy to learn and easy to build on top of without lots of gotchas.

Sokol is also a single-header library. I’m aware of the single-header library concept through Sean Barrett’s stb libraries, but actually using them is new to me. I’m a little sceptical, but at the very least it means that Sokol isn’t going to impose any build system demands on me.

Less important, but still positive, is that Sokol is zlib licensed, which means pretty much no restrictions on anything I make with it. I had previously been thinking about maybe trying to build a game on the Doom 3 engine, which is GPL—taking inspiration from Brendon Chung—but given up on that when I couldn’t get the source code to build after trying for day; and though GPL wouldn’t be a killer for me, a more permissive licence will allow me to target various closed platforms (iOS, PS4, whatever) if I end up wanting to do that. That’s looking waaaaay too far ahead, of course!

So I fire up my text editor, write #include "sokol_gfx.h, and get started.

In the beginning, the game was without form, and void. And darkness filled the surface of the game’s window.

And with a little code to create buffers and pipelines and shaders, and with much greater ease than I had feared, I wrote a small program that, in effect, said:

“Let there be a triangle!”

And there was a triangle.

A window titled “One beautiful triangle!”. Inside the window is black, but in the center is a single perfect triangle: the top vertex is red, the lower right green, and the lower right blue, and the colours blend smoothly between the vertices.