Jump to content

  • Log In with Google      Sign In   
  • Create Account


How would I port a game?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Sixoul   Members   -  Reputation: 179

Like
0Likes
Like

Posted 17 January 2014 - 06:04 PM

If I make a game on Windows using OpenGL, C++, and some other multiplatform libraries what would I need to do to say port it over to Linux or Mac? What would be some mistakes people make when programming that are OS exclusive? Thanks for any help.



Sponsor:

#2 ProtectedMode   Members   -  Reputation: 1109

Like
0Likes
Like

Posted 17 January 2014 - 07:18 PM

If your code doesn't depend on platform-specific libraries or headers, you can easily port your application. But you will still need access to the operating systems you want to port to, in this case Linux and Mac, and a compiler on these specific platforms.

There are not really common mistakes aside thinking you can compile for those platforms using only Windows and including platform-specific headers... If you still need platform-specific headers you will need to provide alternatives for all supported platforms. For example, if you would want to include winsock, you would usually use preprocessors to use another header if the code is being compiled on Mac or Linux.



#3 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 17 January 2014 - 07:45 PM

First, I'd recommend using the same compiler (or as similar as you can get) for each target platform. Gcc is probably the "normal" choice, but Clang or whatever is fine. It will just minimize the compiler-specific issues. You can learn about cross-compiling if you don't want to compile the code on the actual target OS, although you'd obviously want access to a machine for testing and such. If you do want to build all 3 targets at once, it's probably easiest on Linux just because so many people have build servers and such running on Linux.

 

Next, I'd recommend SDL2 or some equivalent. I think you were implying you'd be doing that already, so you're likely set in that department.

 

Once that's going, get a basic program running on all 3 using all the libraries you plan to use. That's going to be the biggest challenge. Once you're up and running, you just need to avoid stupid things like using "C:/..." for a file since obviously that's not going to work on Linux. And avoid things that are obviously OS-specific like wglWhatever or winblahblah. Threading models are also different and might not be as obvious since they're usually just stuff like pthreads, so you'd have to know p is POSIX to know it's OS-specific.

 

It sounds scarier than it is. Even if you mess up, it usually doesn't take long to get things back to working on every OS.



#4 dejaime   Crossbones+   -  Reputation: 3978

Like
0Likes
Like

Posted 17 January 2014 - 08:13 PM

I like to set up a cross-compiler since the start of my projects, just to test their cross-platform side, as I often mess things up. But really, never had any problems with this, it is more out of paranoia that I do it. Just use fully cross-platform libraries (not those with a partial port, missing features on a given platform or with different APIs) and you won't have much to worry about.

The annoying part will probably be setting up all environments while you still don't have experience building, linking and this kind of stuff.
So, to make your life easier, try to use a compiler available on most of your platforms and use some library for file handling for OS abstraction (like PhysFS).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS