You are asking a specific question here, but then the reason you say you are asking is kind of unrelated.
The question:
Is it faster and more effective to design a seperate copy of an engine for (each) different platform or to handle all platforms in one version (source) of an engine (multimedia framework) in one big project |
You don't need multiple copies of the same engine. What you really want here is to separate/remove platform specific code from your engine and interface with it through an abstracted layer.
I/O is typically the only place where platforms differ (unless you're doing extremely low level stuff, but since you're talking about a game I'm going to assume that isn't the case here). Fortunately I/O for most computer-style devices are the same. There's the concept of a keyboard, a mouse, and joypads for input. For output, there's concepts of windows, streaming audio, textured polygons, etc.
The underlying concepts are the same across platforms, but the implementation to make them work is what differs. For example on Windows, if you want to get keyboard input you can use GetAsyncKeyState. But of course that exists only on windows and not on other platforms. So if you want your engine to be portable, you need to abstract that.
This is typically done by putting OS specific calls behind a wrapper. Continuing with that simple keyboard example, you could create your own GetKey function:
1 2 3 4 5 6 7
|
bool GetKey(int key)
{
if(GetAsyncKeyState(key) & 0x8000)
return true;
else
return false;
}
|
This is a big step towards portability because this routine can be easily swapped out with a different implementation to work on Linux or whatever platform you want:
1 2 3 4 5 6 7 8 9 10
|
#ifdef WIN32 // if compiling for Windows...
bool GetKey(int key)
{
//... do the windows implementation
}
#else // otherwise (assuming Linux... I forget what's defined for Linux... maybe __unix__?)
bool GetKey(int key)
{
//... do the linux implementation that does the same thing
}
|
Do all of your I/O that way, and your code becomes [mostly] portable (there are other things that can make your code non-portable, but I'm trying to keep this brief).
But it can be even easier than that! Several libraries like SFML and SDL already do this for you. They have multiple different implementations... one for each platform they support. But the interface for the library is always the same.
As for coding for different compilers, this isn't much of an issue, really. Ideally you'd want the same code to compile the same way on all mainstream compilers. The best way to accomplish this is:
1) Stick to C++ standards and don't try to do anything that's undefined.
2) Don't use compiler-specific extensions
3) Pick which version of which compilers you want to support, and don't use features not supported in those compilers (for example if you want to support older compilers, you might not want to use C++11 functionality).
4) Compile your code on all target compilers and make sure it compiles OK.
The unrelated bit:
Im asking this because recently broke apart my Game Engine in order to better design it and divide it into more manageable modules. |
Breaking a large project into smaller modules is often a good idea. But it might also be unnecessary. It's really a judgement call you have to learn to make for yourself.
Though I'm not sure what this has to do with different versions or different OS's/compilers. There should only be one copy of the game engine.