I mean: i don't think they made 4 differnet game for each platform.

How they achived such huge cross-platform? (Did they use a graphic engine that already supports all of them?)


  • \$\begingroup\$ Do you want to know specifically how portal 2 did it or how you can do it in general? \$\endgroup\$
    – lathomas64
    Commented Feb 28, 2011 at 16:20
  • 1
    \$\begingroup\$ Heavily related: gamedev.stackexchange.com/questions/195/… (as well as anything with the cross-platform tag) \$\endgroup\$
    – Tetrad
    Commented Feb 28, 2011 at 17:45
  • \$\begingroup\$ why down voting ? \$\endgroup\$
    – dynamic
    Commented Mar 1, 2011 at 14:14
  • 2
    \$\begingroup\$ For my part, I down voted (and voted to close) the question because it's way, way too broad and suggests a relative lack of any research effort into the process of writing cross-platform software on your part. \$\endgroup\$
    – user1430
    Commented Jan 15, 2012 at 6:46

4 Answers 4


They utilized their proprietary Source engine. Many game engines and libraries are cross platform, it's nothing new. Portability is typically built into most contemporary engines.

The simple answer: their engine supports all of those platforms. The gameplay code isn't rewritten for each. Only necessary platform-specific systems are re-written to an API specified by the engine.

Unreal is another example of a cross-platform FPS engine, as is the Infinity Ward engine. You'd be hard pressed to find a contemporary game engine that isn't cross platform.


As A.A Grapsas (that's a tongue-twister) said, their underlying library/engine was created to be cross-platform.

One of the reasons that things like the Unreal engine are so expensive is that they've (mostly) conquered the cross-platform challenge, allowing games based on it to run on the Xbox/PS3/Windows/etc. Since cross-platform means working with different platform-specific compilers, different target processors (X86, ARM, PowerPC, Cell, etc), different GPUs (NVidia, ATI, though this is handled quite well by the drivers these days), etc. Implementing a new engine that provides that capability is non-trivial, as is maintaining it and keeping up with new platforms, especially mobile devices. Poorly implemented code will rapidly mire a project in bugs and maintenance challenges.

From a development standpoint, the key is to use a native, compiled language that's pretty well standardized and available on all target platforms, which today means C++. Platform-specific methods are placed in pluggable libraries, and the entire code base is compiled using each platform-native compiler. g++ is a good baseline - unfortunately, "good baseline" also means lowest common denominator. I'm not sure which compilers are used for the Xbox and PS3, but I'd bet that the professional Xbox kit uses Visual C++. VC is an amazing tool, and offers one of the best compilers and most advanced debugging environments available in the world.

If you're interested in more detail, check out Brian Hook's book, Write Portable Code. It's pretty inexpensive and an easy read. He's been around the game industry for quite awhile and, though the book doesn't focus on games per se, the advice it provides definitely applies.

  • 1
    \$\begingroup\$ As an aside, the actual compiler in VC++ is, whilst better than before, not held up to be world beating. \$\endgroup\$
    – Will
    Commented Feb 28, 2011 at 18:41
  • \$\begingroup\$ @Will - that depends upon your priorities. It lags behind on standards compliance, but tends to be smarter than other compilers when it comes to things like templates and references. Sometimes it will let you get away with things that aren't standards compliant but make more sense. \$\endgroup\$
    – James
    Commented Feb 28, 2011 at 21:16
  • \$\begingroup\$ Ugh, get back to me when they've actually acknowledged the existence of C99. \$\endgroup\$
    – Bob Somers
    Commented Mar 1, 2011 at 5:54
  • \$\begingroup\$ @James I was particularly thinking of its performance, as I guessed the answer alluded to VC++ giving good performance, when for windows binaries you'd be better to look at Intel's compiler or even the newer GCC 4.x series - compile with all of them and benchmark the results for your own codebase, obviously! \$\endgroup\$
    – Will
    Commented Mar 1, 2011 at 12:24
  • \$\begingroup\$ @Bob Somers: Microsoft hasn't actually even implemented a true C compiler, so the fact that it lacks C99 doesn't really surprise me, as C99 makes C no longer a subset of C++. As I tend to code exclusively in C++ these days, it hasn't particularly affected me. \$\endgroup\$
    – James
    Commented Mar 1, 2011 at 15:30

A while back I did a GDC talk on how we built Source to be cross-platform, and best practices for cross-platform development generally:

  • \$\begingroup\$ No video? It looks like an interesting talk, but a slideshow without the presentation is always going to miss something. \$\endgroup\$ Commented Jan 14, 2012 at 13:15
  • \$\begingroup\$ @eBusiness If you open the slides in Adobe Reader (rather than in the browser), there should be a little mouse-over button in the top left corner that transcribes the narration. GDC Vault has an audio recording, but behind a paywall: gdcvault.com \$\endgroup\$
    – Crashworks
    Commented Jan 14, 2012 at 13:21
  • 1
    \$\begingroup\$ That security hole is not going anywhere near my computer. But it seems to work in Foxit. \$\endgroup\$ Commented Jan 14, 2012 at 13:46

As already stated their Source engine is written to be cross platform. Writing a cross platform engine is no trivial task (if you want it to work well on all hardware) which is why may companies license engines rather than develop them from scratch.

The trickiest part of making a performant cross-platform engine is no longer differences between processors. Less than 0.1% of the engine code will likely be in assembly - usually just the lowest level vector/matrix math libraries. C++ is fairly portable these days, especially if you are doing Continuous Integration and testing/building on all targets - the STL is typically the sticking point - which is why games companies either have their own alternative (slimmer) template libraries or have their own custom versions of STL (eg EASTL).

The biggest problems these days are down to hardware differences between the various target platforms. ..

You need to support some modern version of DirectX for the PC build, a variant of DirectX 9 on the 360, a variant of OpenGL (or Sony's proprietary libraries) on PS3, and OpenGL ES on mobile. You then have to deal with each platform having it's own audio libraries (although many companies just go with middleware these days), their own game load/save systems, different filesystems and different requirements for streaming/caching assets. Each platform have different balances between pixel and vertex processing speeds and available features.

On top of that you have completely different multi-processing approaches on each machine - 360 has 3 identical multithreaded CPUs, PS3 has one main CPU and then a bunch of self contained SPU processors to keep fed, Wii and iOS are single processor machines, PCs have a varying number of identical cores to keep running.

Oh and the memory models of each machine require you to handle how textures/vertices are loaded differently - PS3 has it's memory split between the CPU and the GPU, 360 has unified memory, PCs have the gfx card memory to keep filled. You also have very differing memory sizes from iPhone up to PC. So not only does your runtime need to be organizing memory differently on each platform but your tools pipeline needs to be able to target these different machines also (ideally with the same source art assets).

So yeah, to answer the original question - they have a cross platform engine. And it was likely a non trivial undertaking.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .