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?)
Thanks
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.
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:
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.
cross-platform
tag) \$\endgroup\$