I am a computer science student and I am wondering why do some games only run on certain platforms. I have never written any code that is OS specific.
Direct X, just made it easy to run games on windows mostly if I'm not mistaken.
Pretty sure it because that PC has been the same for quite some time. Consoles prior to the Xbox One and PS4 are harder to develop on. But this current gen makes it easier cause the consoles are just dumbed down PCs.
It's not that it DirectX made it easy, it isn't easy on any API. It's mostly because the game engine is using a non cross platform graphics API (the said DirectX) instead of OpenGL (and soon Vulkan API), sometimes games are tied to the Windows API too. Most pre 2000's games could run in OpenGL mode, some coincidences and unlucky calls later a decade ago made DirectX mainstream, this still is hurting the gaming industry today. I bet drivers on Linux would be just as good if not better than on Windows, because people would actually play on Linux, i think that's one thing that still keeps Windows together (besides the user base that does not want to learn to use anything else).
Regarding consoles, PS4 an prior use their own proprietary API called GNM (obviously they can't get DirectX, because of their own firmware and platform), while Xbox One uses DirectX. It's harder to make games on consoles, because they have specialized hardware that programmers have to code for to use efficiently. Which is less of an issue these days because as mentioned, consoles now basically use standard computer chips (AMD APU's to be exact). There is still a lot of effort put in to optimization, those chips are still inferior to pc hardware and can't run as smoothly.
Dude above me pretty much said it all. The framework. Ever try to get a modern .NET application to run on anything else besides windows? In a word; difficult.
Mono certainly makes it a lot easier, but Mono still isn't 100% compatible with all features in .NET, so if an application uses one of those features, no go.
Also, for some older platforms, not everything was even x86 architectures, so that put some complications in running everywhere.
I thought that specialised hardware made it easier to make games for consoles (ceteris paribus), because (as a programmer) you know exactly what hardware your game will be using, and so can plan/program appropriately. For example, you wouldn't have to worry about a code optimisation breaking the game on certain platforms/hardware configurations, because the game will only run on one* system/hardware config/etc.
*(I know that for various reasons it might not actually be only system, but hopefully you still understood what I'm getting at).
Making a game for a console is/was not necessarily more difficult, but making a game run as efficiently as possible on a specific piece of hardware is.
I gotcha, you are definitely right about not having to worry about any other platforms when making game. Though it's still quite a sizable job to program on specialized hardware (speaking about pre AMD APU's in consoles era, non standard computer chips), because you have to know the machine's capabilities at a low level and code accordingly, they used to be very different than x86, so no standard API's apply, and it makes me wonder if Assembly language was used together with C/C++ in code. That was pretty much was I was getting at, sorry for not clarifying.
Lets also not forget that console corporations are paying companies to be exclusive. They want a game to only be available on their platform to get people to buy their platform. Or at the very least, not available on their main competitor's platform.
True that, I suppose that makes it (devving for specific hardware) a double-edged sword I suppose; on the one hand, the game will only run on one system, but on the other, you need to have a silicon-level understanding of how the system works.
Dunno how old we're talking, but IIRC a lot of older games (like, 80s- 90s I guess, my timeline of gaming isn't very good) were indeed programmed partially in assembly code for the platform in question AFAIK. The example I often hear is the first Rollercoaster Tycoon, which was written mainly in assembler, with around 5-10% C code (again, IIRC).