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 :)

Graphics

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.

Sound

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

16 comments:

  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...

    ReplyDelete
  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.
    assignment-help-sydney.com

    ReplyDelete
    Replies
    1. As you are talking about assignment help it reminds me of the time when we were struggling a lot because of not having enough resources and handling a lot of workload without any help. But now this is not the issue anymore because there are various cheap nursing dissertation and other writing services available for students.

      Delete
  3. 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.

    ReplyDelete
  4. 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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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.

    ReplyDelete
  7. If you're wondering how to go to Hong Kong on a cheap, Uselect Flights is the way to go. As a leading online travel service, we take pleasure in providing the most affordable Cheapest Flight from the UK to locations all over the world, including Hong Kong. Booking your perfect holiday has never been easier thanks to our user-friendly website and fast customer service.

    ReplyDelete
  8. Profit recording is more difficult than it appears. Traditional paper-based approaches, such as storing sales records in notebooks, can result in inefficiencies, mistakes, and a lack of complete insights into the bakery's financial health. A POS Software for Bakery in Pakistan is an exciting venture, but it is not without its obstacles. The most difficult duty among them is tracking bakery profitability and making educated future judgements.

    ReplyDelete
  9. Oscar POS System in your retail business, you gain a wealth of benefits. By improving customer relationships, reducing complex business procedures, and increasing efficiency, you may produce large revenues and catapult your company to greater success. Furthermore, this cutting-edge technology gives useful information that may be used to guide strategic decisions and increase profitability.

    ReplyDelete
  10. If you're seeking for cheap shopping or a secondhand store in Dubai, go no farther than https://zeilgroup.com/. Explore a diverse selection of preloved and second-hand clothes for men, women, and children, featuring apparel and accessories from leading worldwide brands, all at shockingly cheap costs. If you are seeking for affordable shopping in Dubai, come to one of our three clothing stores in Dubai at Oud Metha, Al-Quoz Mall, or Al-Quoz 3.Dubai's lively culture, busy tourism, and role as a worldwide economic hub make it a city that never fails to enchant.

    ReplyDelete
  11. To grow your current Bike Parts in Pakistani, you should prioritise the quality and authenticity of your items. You may build a loyal client base by ensuring that your consumers are impressed with what you offer. One important tactic is to locate your retail business in an area that is easily accessible to your target demographic. This aspect can help you dramatically extend your consumer base. If you open a retail store in an area that is unfamiliar to many people, you will never be able to attract a large number of consumers.

    ReplyDelete
  12. wholesale markets and internet channels to find the Best Watch Accessories in Pakistan at Wholesale Rates. Cities like as Karachi, Lahore, and Islamabad have thriving wholesale marketplaces, such as Saddar in Karachi and Liberty Market in Lahore, where a varied selection of watch accessories may be obtained. Furthermore, internet platforms such as Alibaba and Tradekey connect buyers with wholesalers, providing an easy way to get large volumes at cheap prices. Engaging with local vendors and distributors that specialise in watch accessories is also important, and visiting trade events or joining relevant business networks may help you make useful contacts.

    ReplyDelete
  13. In Karachi's ever-changing professional scene, Shared Workspace for Freelancer have emerged as a change catalyst. Work Hall, with its dedication to offering more than simply office space, has evolved into a magnet for creativity, collaboration, and community development.

    ReplyDelete
  14. Saima Group offers the Best investment plans 2024. Their completed projects in various places in Karachi demonstrate their dedication to delivering affordable homes in Karachi. Saima Group provides simple payment plans, making it easier for people to obtain their dream houses.

    ReplyDelete
  15. Porting games to Linux can be tricky, especially because of the many different Linux distributions and hardware configurations. Developers often face challenges in ensuring the game works smoothly across all setups. It requires a lot of testing and troubleshooting, which can delay the release. For companies new to Linux, using business assignment writing services to find experts in game development could be helpful. Professionals who understand Linux can guide the process, making it easier to solve technical issues and ensure the game runs well for all players.

    ReplyDelete