I need option 3 in what you mention.
My problem is not only the rendering, but also all the GUI.
So I have:
Game logic thread: runs the game and modifies the resources.
GUI thread: handles the GUI events and also renders the views.
I want the game logic to be compilable in headless mode, and optionally have a plugin with the GUI and rendering. Think of it as a simulation of some physical process:
a) we can have the simulation configured and modified via a GUI, and also visualized. This situation requires the headless mode game logic executable, and the GUI/rendering plugin loaded
b) But other times, we simply want to be able to run, say, 10 simulations in parallel, in headless mode: in that case, we are only interested in the data the simulation produces. This situation only requires the headless mode game logic executable
So all the dependencies to the GUI and OpenGl should be in the plugin, so that the game logic can also easily run on machines that do not have any display (i.e. no OpenGl or graphic card installed)
So I agree that duplicating the resources is a tremendous amount of work, and many things can go wrong if not done properly. So, let's for now forget the resource duplication, and consider that we have only one thread doing everything.
What I currently have is following:
class CObject_A
{
CObject_A();
virtual ~CObject_A();
void doCalculationAndModifyObject();
void renderObject()
CData* data;
};
I basically currently have everything in one class (actually many classes, but for simplification sake). Because of that I cannot compile the gamelogic in headless mode (above class has the dependencies to the GUI/OpenGl). I need to separate the above class in 2 separately compilable entities, with least effort.
For that reason I mentioned the possibility to simply cast a class to another class, if the member variables are the same.
So I want to be able to do following:
// gameLogic executable:
CObject_A* object=new CObject_A();
object->doCalculationAndModifyObject();
callPluginRoutine(object);
And in my plugin:
void callPluginRoutine(CObject_A* obj)
{
obj->renderObject();
}
If I want to be able to compile my gameLogic executable in headless mode, I am not allowed to have routine "renderObject()" in class CObject_A during compilation.