raylib game coding library for C

I gotta say right off the bat, that this is a little gem, often when coding in C you may well end up feeling like you’re reinventing the kitchen sink. C doesn’t come encumbered with a weighty run time library that some languages are hampered with and while there are quite the range of single header “libraries” for doing a single specific function, (for example loading a png file) sometimes they don’t always work together so well, typically ending up with a number of different defines for the same type of data structure (vec3, vector3, v3, arrg3!), its not critical, but it is… well untidy, and you know what, that just doesn’t help with readability, I like code I can come back to years later and just see at a glance whats going on, of course this is why you comment your code (you do comment your code don’t you!?)

Anyhow back to the subject in hand, raylib has managed to do that rare thing of being both comprehensive, not bloated, and refreshingly straight forward, even when dealing with quite complex topics like shaders…

While there isn’t any doxygen style API docs and the wiki does seem a little light… that is less of an issue than you might suspect, there is a cheat sheet with one liner comments for each function in the library, and pretty much all the structures used are both simple and obvious. The code is both clear and well written, its actually a joy to look at the code just to clarify some point of the inner workings as you use it…

Learning how to use the library, is really not a long process, in many regards this is due to the generous volume of examples, not including raylibs source dependencies there is literally more than twice the lines of code in the examples than the library itself ! Compiling the examples is simplicity itself, with a cross platform Makefile that just works… there is cmake if you want to complicate things unnecessarily. Assuming you’re a reasonably experienced C coder, by the time you’ve run all the examples while viewing their code, you’ll basically have more than enough knowledge to just dive straight in and enjoy raylib.

On the topic of dependencies, its amazing the static lib is less than a few megabytes in size, all its dependencies are compiled in from source (it has its own source tree for GLFW for example) it has no right to be so small when you consider the dynamic libraries it pulls in, on Linux it couldn’t really be any less!!! the bare minimum it takes to interface reasonably with Linux and X windows, this certainly helps with compatibility and will also increase the lifespan of any game you write making it much easier for any future game archeologist that wants to resurrect your old game! I put together a simple lighting example that showed a number of coloured point lights rotating round some 3d geometric primitives, without optimization it still weighed in at less that 900KB

Used in a larger project I’ve found it doesn’t seem to get in the way, and is a great companion, providing the tools you need to really enjoy your game coding, taking care of the boring minutia so you can get on with the fun stuff!

2 thoughts on “raylib game coding library for C”

Leave a Reply

Your email address will not be published. Required fields are marked *