I've run into this problem several times before and wanted to hear what other's experience and advice is. Assume you have a working and stable but relatively small game engine that works on only one platform, and you want to port it to another platform.
The first step is obvious: you take the code, link it to the platforms libraries instead of the old ones, make necessary changes to the project or target build settings and then hit build. About five to twenty thousand errors appear. Of course there are a lot of duplicates but it immediately raises the question what the next steps should be?
How do you approach porting a game engine to another platform, or any platform-specific code that can't just be compiled on the other platform due to inherent changes in system and API design? How do you wade through all these error? How do you identify the parts that should be approached first?
In general: how should i approach porting existing source code?
I'm looking for general advice on how to approach a source code port. Assume the programming language and compiler are the same on both platforms, so it's mostly API changes.
Fortunately, porting can be done faster if a product was developed in a game engine such as Unity or Unreal Engine. This is because games created with big engines are designed to work on multiple platforms with equal efficiency.
The porting process requires direct developer intervention, and it usually takes a long time to import the source code, make the necessary changes, and transfer the game experience to a new platform. Fortunately, porting can be done faster if a product was developed in a game engine such as Unity or Unreal Engine.
Moreover, you’ll learn to choose an external provider of game porting services to speed up the process and not exceed the budget. Porting in gaming is a process of converting a game in order to make a product suitable for another format. For example, gamers that have a PC can’t play games launched exclusively for consoles.
This popularity has driven video games to be played on different platforms and on various devices, which is why the demand and need for game porting services have also drastically increased. Game porting poses a lot of cost benefits for both developers and for the eventual customers.
A textbook answer (perhaps) might be wrapping all of your platform-specific calls and using these wrapper functions throughout your code instead of the platform-specific. This way, if you can match the methods you use one-to-one on both platforms (easier said than done, maybe) then you can switch out which platform-specific function is called with your wrapper functions, and not change the rest of the logic in your code.
Say you have:
void RenderBadGuy(int badGuyID)
{
// Windows-specific bad-guy rendering code here
}
For now you can just write ("G_" is for generic)
void G_RenderBadGuy(int badGuyID)
{
RenderBadGuy(badGuyID);
}
This adds a small amount of overhead to your engine, but this shouldn't break things as you have them (just an extra function call).
Now, every place you use RenderBadGuy, just use G_RenderBadGuy. Rinse and repeat for all of your methods, and now later you can switch out your code to something like
void G_RenderBadGuy(int badGuyID)
{
// now we're rendering on a Mac
RenderBadGuy_Mac(badGuyID);
}
and then your main engine wouldn't change.
You probably can do this a lot nicer and more generically than this (pointers to functions, I don't know) but that's the idea.
Or, you could do a Java-like thing and have your library talk with a module that in turn knows the specifics of your platform. Just develop different modules (like VMs) for each platform, and you only develop your library once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With