How do Valve create games that run on Linux, Mac and Windows? I imagine they dont really write one version for each platform bec that would just be a nightmare.. or do they? I imagine it is written in a portable C++ code (or C#?) but I wanted to know more details about this. I've developed an app on Adobe AIR and considering on porting it to a diff language as Adobe abandoned linux support.

  • I am sure they don't use C#, because compiled C# runs inside a virtual machine and it is too slow for a videogame. I am also sure that they write videogames using libraries that are cross-platform. I think it is in some sense similar to write JavaScript that runs inside different browsers. Nov 18, 2013 at 22:16
  • 6
    You'd really need someone from the dota2 devteam to really answer this
    – Zavior
    Nov 18, 2013 at 22:17
  • @Vitalij Don't completely rule out languages like C#. Dota may not be written in it, but Bastion, a cross-platform game available for Windows, Mac, Linux, Playstation 3 and XBox 360, was written in C# with Monogame.
    – KChaloux
    Nov 18, 2013 at 22:33
  • @VitalijZadneprovskij you'd be surprised how many games I have from Steam (not Valve, but Steam in general - on a mac) that do an update of mono as part of their install.
    – user40980
    Nov 18, 2013 at 22:46
  • 3

2 Answers 2


Every Valve product is developed using their own in-house game engine called Source. The Source Engine is written in C++. The source engine contains both an OpenGL and a DirectX renderer which helps it in being cross platform, but the key is SDL. The open source Simple Direct Media Library is used by a team inside Valve which is tasked almost exclusively with taking Valve's popular products cross-platform. SDL allows Valve to focus less on writing redundant code that will work here, there, and everywhere and instead focus on fixing what needs to be changed to allow for the build to work on platform X, Y, and Z and let SDL take care of the rest.

SDL allows for this by creating a simple interface that works for every platform (well not every platform, but the ones that matter) when it comes to things like window management, context management, event handling, etc. Without SDL you would have to write code that makes a window for Windows, OSX and Linux just to get the basic window management stuff to work cross platform. In SDL, you call three functions and you have a window. See the reason why people use it now? SDL is at the heart of most of Valve's games today because they are beginning to think about cross-platform from the beginning.

Here is a good article about Linux support and the team that makes it possible at Valve.

  • you sure it's SDL they are using? that thing is pretty much out dated for a company with such a big name!
    – Ali1S232
    Nov 18, 2013 at 22:33
  • 1
    @Ali.S from the libsdl webpage: "It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games."
    – user40980
    Nov 18, 2013 at 22:41
  • @Ali.S Positive. SDL is not dated at all, they just reached their 2.0 milestone very recently and remain extremely popular for game developers large and small. Nov 18, 2013 at 22:45
  • 1
    @JacobKrustchinsky as you said V.2 is pretty much a recent thing, while valve started to work on linux porting a long time ago. when I said out dated I meant the time valve started working on linux project. anyway your answer after your edits is pretty much more acceptable.
    – Ali1S232
    Nov 18, 2013 at 23:01
  • 1
    @Ali.S I understand. Valve has been using SDL for a number of years (7 I think?) and I do believe the first ports were released using SDL 1.2, SDL's age doesn't mean much because it merely simplifies the things that need to be simplified and doesn't force a specific graphics API or way of doing things down your throat. Hell, I could go back to 1.0 and still port a modern game provided that it uses OpenGL Nov 18, 2013 at 23:07

I'm not specifically talking about Dota2 but about most of cross-platform games in general.

Usually developers create/use a middle were called GameEngine. It's usually in a form of a large scale library containing tools for all sorts of things such as handling game physics, loading and rendering graphical objects, loading and running scripts, managing network related stuff, and so on...

That GameEngine thing can also provide support for those kind of things across multiple platforms. It provides developers with a unified interface, while having different implementations across different platforms. The same thing happens almost every time you see a cross platform application. Even C# itself that you mentioned is doing the same thing under the hood; it's providing a unified developing experience across all platforms, while handling platform-specific differences under the hood.

In case of valve (Dota2 and their other games) that GameEngine is called "Source Engine". while anything built on top of Source Engine is platform independent, the engine itself have different implementations for different operating systems. Here is an example: the engine might have a function to draw an sphere. In windows this routine is written using DirectX while in linux and mac it's using OpenGL.

It means higher level developers including those who are implementing game logic and pretty much everything in a game, won't even notice platform changes, but in it's base level code Dota2 (and pretty much any other game) is written once per platform.

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.