Monday, April 05, 2010

Clanlib vs Allegro vs SDL on Mac OSX

I want to write a little game in C++. Previously, on Windows, I've used Clanlib. This is nicely designed and has pretty much all you need for a game. However, I now have a Macbook (OSX 10.6.2) and Clanlib has fallen behind the times Mac-wise as it still uses Carbon. There don't seem to be any plans to port it and I don't have the experience or time to this work. So I had a look round at the alternatives (again!).

Clanlib 2.1
  • Pretty mature, modern library with some nice features (e.g. slots and GUI support).
  • Hardware acceleration through OpenGL or DirectX depending on platform.
  • Windows and Linux are well supported but Mac has fallen behind, no Cocoa support.
  • Version 2.0 was the previous 0.9 version; and 1.0 is the old 0.8 version, renamed. Version 1.0 compiles for the Mac but uses the 32-bit Carbon API. In Xcode 3.2.1 you can no longer create a Carbon project, it must be Cocoa; and if you want to do iPhone, this must definitely be the case.
  • Xcode project files provided for Mac. Version 2 needs work.
  • Licence: BSD.

SDL 1.2 / 1.3
  • SDL is a well thought out low level library, but SDL libraries a bit scattered and some look unmaintained.
  • Very portable and core well supported.
  • OpenGL compatible.
  • Uses Cocoa on Mac.
  • Can be built as a framework. 
  • Basic sprites don't support rotation.
  • Licence for version 1.2:  LGPL.
  • Licence for version 1.3: Dual licence, LGPL and commercial (closed source). On embedded platforms (e.g. iPhone) you have no choice but to buy a commercial licence or you are forced to go open source.

Allegro 4.4
  • This is quite an old game library but seems to be well supported. Some of it is quite archaic, with palette support and support for old DOS compilers.
  • Mac port uses Cocoa.
  • API being reworked in Allegro 5.
  • Can be built as a framework.
  • Uses cmake to generate project files.
  • Polling API.
  • Minimal external dependencies (e.g. includes JPEG decoder).
  • Licence: Giftware.

Allegro 5.1
  • Allegro 5 been a long time in development, but worth the wait. Allegro had a lot of cruft from DOS and pre-graphic cards. The latest version is 5.1.
  • The API is a lot more organised than 4.x. It is simple and elegant.
  • The live version, straight from git (with build instructions) is available. Please note that whilst this contains new features and fixes, it also sometimes contains bugs (which happens during development). If you aren't comfortable with this use the latest stable release.
  • OpenGL and DirectX renderers (hardware accelerated) by default.
  • Event based API (i.e. not polling).
  • Notes on building for Mac OSX.
  • Licence: Giftware.
  • (This was version 4.9 in the original comparison, which was a work-in-progress version of Allegro 5.0.)

Conclusion

I like the extra features that Clanlib and Allegro supply in their default libraries. Clanlib unfortunately uses Carbon on the Mac and Mac version not supported for long time. This is a real shame because Clanlib includes everything you need (including a GUI).

SDL provides extra features in libraries which I find a little scattered and iPhone development requires a commercial licence if you don't want to release your source code.

So as a result I decided on switching to Allegro 4.4, because unsure how mature 4.9 is, and generally Mac lags behind the main development platforms (Linux and Windows). I'll build my own API, hiding some of the the archaic nature of Allegro. I also decided on Allegro because I found the retro games site, which uses AllegroGL. :-)

I've now switched to Allegro 5. It is still a nice simple API, much improved and tidied up, and libraries updated for modern hardware. Works fine for OSX 10.6.  This is the best, simple cross platform (Windows, Linux, OSX) solution I have found.

[24-Jul-10] Updated because SDL 1.3 has now move to dual licence.
[25-Mar-11] Updated for Allegro 5.0. Removed notes on 4.9 as not useful.
[16-Jan-13] Updated notes on Allegro 5.1.

3 comments:

Oscar (.teri) Triano said...

Allegro 5.0 finally is out! :) Check it

Anonymous said...

SDL does not require a commercial licence for use on iOS, as long as you're willing and able to supply precompiled object files for the rest of your program to existing customers, so they can relink it.

Gezegond said...

Hi. I wanted to inform you that Allegro 5 is licensed under zlib, not Giftware.

http://alleg.sourceforge.net/license.html

https://en.wikipedia.org/wiki/Zlib_license