Friday, 18 June 2010

Hurdles when Porting Games to Linux

 A recent Shot of Jaq episode described the many problems that indie game developers face when porting their games to Linux, let's break down the problems into categories:

1. Which libraries do I use?
2. How do I package the game?

So here we go.

Which libraries do I use?

This is the one that people make the most fuss about. When developing a game on Windows, you know full well that if you want to create a 3D enabled window, you have Win32 + Direct3D + DirectSound (or whatever it is now) right there. And it works. It works because the whole Windows game world develops using those APIs and they are well tested. When coming over to develop for Linux, many devs don't know where to look for the equivalents, and when they ask around they get different answers from everyone, because people recommend what they like, not what is the most sensible option. Let me answer the question right now:

1. For graphics, use OpenGL 2.1 (or 1.5 if you don't need GLSL)
2. For sound, use OpenAL
3. For windowing and input, use SDL

Now, before I get ransacked by people with opinions, I'll explain why :)


This is the easiest one to decide. OpenGL is the only choice for hardware accelerated graphics on Linux. If you can do without shaders and target 1.5 you can get the lower end hardware, if you need shaders then go for 2.1 rather than 3.x or 4.x because Mesa doesn't support them (yet) and the open source ATI and Intel drivers both support it. You can of course check the version at runtime if you want 3.x or 4.x features, but don't rely on it.


This is the one that causes the most noise (no pun intended), ALSA? Pulse? OSS? etc. No you want OpenAL. OpenAL gives you a consistent 3D sound API that wraps the underlying complexity of various sound systems.  It's not perfect, but it's definitely your best choice. Hemisphere games came to the same conclusion when porting Osmos. Just go with it and test as much as possible. openal-soft has a number of backends too, so if you don't have Pulseaudio, or whatever, it will still work. The openal-soft developers are really responsive. I had a load of help trying to diagnose a problem with openal + pulse (which was a bug fixed some time ago now).

Windowing and Input

I can tell this will stir up a hornets nest of people saying that straight X is better, and indeed straight X is what the Osmos developers went with. But SDL has been used for a load of games (World of Goo, Penumbra, Quake 4 etc.) it's pretty damn good. Again, it wraps the complexity of the underlying X and handles any quirks for you. Also the SDL developers are responsive to both feature requests and bug reports, and have a really busy mailing list. If you have any trouble, you have somewhere to go and get it fixed. If you don't think SDL is flexible enough, then go with X, but let me assure you - you'll be writing a lot more code, and that code is your problem.

There, done. By offloading the work to these libraries you get a number of advantages:

1. Bugs you find and report (and perhaps even fix) help everyone
2. They deal with the hard work for you, reducing the amount you need to code
3. They are widely available
4. All three of them have nice, consistent APIs

Packaging the Game

Packaging is a pain in the arse if you want to target as much of the Linux-based ecosystem as possible. Generally though, packaging in .deb, .rpm and .tar.gz in both 64 bit and 32 bit versions seems the way to go. Games in The Humble Indie Bundle were packaged in various different ways, but World of Goo had a .deb package that worked the best compared to the fiddling I had to do to get the others to run.

It's probably best to go with the distributions package manager to handle dependencies, especially for the big 3 libraries (GL, AL, SDL) and also FreeType and libvorbis.  That's the approach Hemisphere games took and they seem pretty happy with the result.

Other Libraries

Obviously it's not just graphics, sound, input and windowing you need to worry about, here are some suggestions for other libraries:

1. Fonts - Freetype2
2. Image loading - Take a look at SOIL
3. OpenGL extension handling - GLee is popular, but not included in the Ubuntu repos, GLew does the same job and is in the repos.
4. Physics - Box2D for 2D, ODE for 3D


  1. Great analysis! There are also several efforts at making "distribution-agnostic" packaging systems, such as zeroinstall, but I don't know how far they limit your use of the system libraries...

  2. I agree with your suggestions. Thanks for sharing all, this is helpful for many people. I am truly pleased to read this post which carries lots of helpful data, thanks for providing these kinds of information.

  3. Let create a new world for yourselft by way take part in the games– sims 4 cheats in my site. Click link to visit site. Thank you so much.

  4. I am also a game lover person and yes, I have faced some similar issues while my game developer was developing a game. Though, I have left working with him because I had studies to deal with. This is why I have to find someone to write my dissertation online UK based. This year is very important for me because after that my degree will be completed and I’ll be entering into a professional life either as an employee or an entrepreneur.

  5. The Vlone Outfit carries a strong message behind it. It refers to “You live alone, you die alone”. It reflects your lifestyle. The way to express your feelings, thoughts, and ideas in terms of dressing. Vlone Hoodie

  6. amazing thoughts share more engaging content like this love the way you've been write your content

    take my online classes check assignment writing solution

  7. The perks of hiring someone to do my online exam now are numerous. I mean what can go wrong if you have an extra helping hand, might I say a helping mind.

  8. It all relies on the game's design. It would be tough and time-consuming to write it using the Windows API and DirectX natively. It can be as simple as recompiling and correcting a few problems if it was created using cross-platform APIs/libraries/engines like SDL, Unity, Ogre, or OpenGL. Because most decent game APIs are already cross-platform, many single-platform games are produced using cross-platform APIs. Those are simple games to port. With consumers gaming on a wide range of devices and operating systems (PS3/4, Xbox/360, Wii/U, Windows, Linux, Mac, iOS, Android, and so on), game creators must have compelling reasons to use platform-specific APIs directly. Get Elden Ring Classes – A Brief Rundown Of The Different Classes and Garena Free Fire – New Weapons, Character, & More Provided In New Update here in our website.