14 hours ago, Josheir said:
So a game created on Windows to be ported to Mac must be compiled on that computer using portable C++ code?
Yes or a compiler targeting for that system. The C++ source code is the portable bit and not the .o, .lib and .exe files the compiler generates.
As for loading image files. Agree with what has already been said. For portability, some kind of virtual file system will help. Either use someone else's or write your own, it doesn't have to be that complicated.
The point is, in your game code you must not make assumptions about where your resource (files) originate from. Keep your reading and writing wrapped in some class.
void LoadGameInfo()
{
CMemoryBlock* myBlock = myVirtualFileSystem.LoadFile("mydata.dat");
..
On your PC version of the virtual file system class, it would be loading the file via fopen() / fread() calls, and on Android it would look more like AAssetManager_open() / AAsset_read() etc.
Also on portability, PLEASE DO NOT end up with code littered like this
#ifdef _WIN32
...
#elif __APPLE__
...
#elif __linux__
..
#elif __ANDROID__
...
#elif __IOS__
...
#endif
The code will soon become a mess and in a years time you won't understand it. If you design your game/engine properly you can cut this type of code down to virtually none, even in low level classes like virtual files systems.