How are games created for different platforms?

For example, Call of Duty: Modern Warfare 3 is available on PS3, Xbox 360, Wii and PC.

Are they completely reprogrammed with no common code? Is there any intermediate code?


Most production level game engines have what is known as a Hardware Abstraction Layer. This is a generic API that the game engine can use to talk with hardware with out having to know which hardware that is. They just call SoundManager.PlaySFX(SFX_ID) or the like. Underneath in the sound manager however it will know which hardware its actually working on and make the appropriate calls to get the sound effect to play.

This allows the engine to be developed using that layer of abstraction so it can run on any system provided an API is provided for that hardware that matches the abstraction. EDIT: As noted by Johnathan, an API for each platform you want to run on is required. And to Trevor's point, when moving from a high memory system to a low memory (Worst for me was PS3 to PSP) you may have to tackle the different hardware limitations. Luckily for me I have not had to rewrite an entire system because of a platform, but I have had to go through and optimize objects to take up less of a foot print.

The other side of things is in the art area where resolutions of textures or models and the like are different. The assets of the game can be built towards a specific target so a PC gets its wav files for its sound effects while they are turned into the specific formats that the PS3 support and the like.

Hope this helps.

  • 1
    \$\begingroup\$ I'll add to this that in most cases, PC/PS3/Xbox360 will share one common codebase, while Wii/PS2/PSP will share a different codebase. Gameboy will have a separate codebase all by itself, and iPhone/Android will usually share a codebase. These are mostly due to broad levels of processing power, available memory, and the graphics faculties of the various platforms. I once had to port a game from Xbox 360 to PS2; very little of the original code survived the process, just because it assumed that there was lots and lots of RAM available for use; I had to rewrite it to use less memory. \$\endgroup\$ – Trevor Powell Nov 17 '11 at 20:56
  • \$\begingroup\$ +1, You didn't explicitly mention that the HAL is different between platforms (the reason Psykocyber also answered) - maybe add that you need a HAL for each platform? Also that using ANSI C/++ is probably a requirement as you need to cross-compile it. \$\endgroup\$ – Jonathan Dickinson Nov 17 '11 at 22:19
  • \$\begingroup\$ Trevor: Gameboy? Damn, I must have traveled to the past, better get back to my time machine... \$\endgroup\$ – user4248 Nov 18 '11 at 0:08

The other answers spell things out in the ideal cases. Most code is common for games, and a clean abstraction layer is used for hardware/platform dependent parts.

However, many games have ports done by an outsourced company, and code diverges significantly. This is especially true with the consoles, but also common of ports to OSX or Linux from Windows.

On consoles, the hardware is different enough that often entire chunks of the core rendering (and rarely also other systems) must be completely rewritten. On the PC you can jut abstract over D3D and OpenGL, as the OS APIs differ but all the PC hardware is roughly the same.

On the console space, you might find that your super efficient gorgeous rendering engine is outright impossible to port directly over to a different console, since the GPU capabilities are so different and you literally need to squeeze out every last percentage of performance to get 7 year old hardware to run your modern game. You can easily find cases where the lighting passss that work best on the XBox are horrendously slow on the PS3, and where the best approach on the PS3 dogs on the XBox. The other hardware and platform differences (eg the SPUs on the PS3 vs the tri-core CPU of the XBox) make it very difficult to rely on a simple thin hardware abstraction layer as your only platform-dependent code path.

Since each platform also requires an extensive amount of expertise to utilize it properly, many games require a specialized outsourced porting company to bring the game to additional platforms. In the PC space you can sometimes find solo developers who do the ports (like Ryan "icculus" Gordon who does many Linux game ports; straight forward work usually, changing D3D to GL and Win32 to POSIX/SDL), while in the console space there are companies with all teams to do rather massive porting work to larger games.

Ports to some platforms do require almost complete rewrites or asset redesigns. The Wii ports of Call of Duty for instance where done by an outsourced company, and everything - including the art assets - had to be redone to fit within the constraints of the Wii's very limited hardware. The Wii doesn't even have shaders, for instance, so simply reusing the same engine and effects/materials was outright impossible, and the limited memory and CPU/GPU required smaller textures and less details models, plus gameplay limitations and so on. Ports to mobile platforms likewise are typically entirely rewritten, usually by a third party.

Newer engines make it easier to port between platforms, but larger games typically still need to update sizable portions of their code and redo many assets to change from more capable PC platforms and consoles to more restricted platforms.


James reponse only relates to PC and not for the implementation on the specific platforms.
While all engines abstract the platform for the far majority of the game code, some parts have to be written per platform. This includes all I/O including network, rendering, audio, device input & I think video output.
Compare the rendering code for say Unreal on the Xbox and PS3. The Xbox uses the Xbox DirectX version, while the PS3 uses libgcm (the OpenGl library is too slow). To simplify it a bit, on all platforms the gameplay programmers only see a "AudioSystem.PlaySound(SoundName here), while for each platform they function internally would call the platforms API for sound output.
See also Tatrad's comment for more programming.

  • 1
    \$\begingroup\$ This is exactly what James said, he just neglected to mention that the HAL is different for each platform. \$\endgroup\$ – Jonathan Dickinson Nov 17 '11 at 22:17
  • \$\begingroup\$ I actually did mention that it will run on any system that a HAL API is provided for, but I made it more clear since this clearly was causing confusion. Also, You do not port code on the PC to another PC unless you are going cross OS like to a Mac or Unix system. For windows environments, where most games run, it is the hardware drivers that handle this already for you, you make a DirectX or OpenGL data buffer via the driver calls and the hardware knows what to do from there. \$\endgroup\$ – James Nov 17 '11 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.