Edit:
About the games on linux. Porting is not the reason why so little games are made for linux.
The problem is much bigger then it first seems and it might not be sutable for this forum since theres a lot of Windows guys here.
Wrong. In the early 2000s there was a huge movement to port games to Linux, and many were. Most of them were OpenGL games. Loki was a huge part of that. Games like Quake 3 [Team] Arena and Neverwinter Nights were ported to Linux, among many others. Those were all OpenGL games. This was at the height of Linux hype (when ZDTV was raving about it and showing people how to install it on Leo Laporte's show like 3 days a week, Lol).
But there were a ton of games that couldn't be ported, because DirectX usurped OpenGL as the [generally] preferred API for game development and it's not portable to non-Microsoft OSes. That's why a lot of games aren't ported to Mac OSX. Same difference.
We all know about Linux' lack of backward/forward compatibility, unstable kernel driver ABI, crappy X.ORG, and 100k different distros with varrying configurations/package versions/etc. We know about its sub 2% marketshare as well.
That still is non-factor because DirectX stops that before you even get to those considerations. You'd have to port the whole graphics engine (built on DirectX) to OpenGL or use some generally terrible (for large scale projects) API layer like Wine to even get the game to compile and run on Linux or MacOS, which isn't worth the money or time given Windows' desktop marketshare. The first thing any company looks at when considering a port is whether the graphics engine and other libraries (additionally physics engines, UI toolkits, etc.) are portable. With game development costing millions these days and developers already (in many cases) rushing products to market due to budgeting issues, non-portable engines and Libraries simply cost too much to work around.
Additionally, you can use XNA (also unportable and built on DirectX IIRC) to target both XB360 and Windows Desktop OSes.
Some graphics engines can use both OpenGL or DirectX but not all and I'm not even sure if we can say the majority can...
Yes, porting logic code can be trivial, even between platforms AND programming languages. Stuff like this, however, isn't. If the UI toolkits and graphics engines are not available, it means you aren't porting the code but essentially rewriting it for the other platform. Alternatives almost always exist, but it's a cost/effort vs. returns (often monetary) consideration.