So I ran into this little issue while working on an idea of a small online game.
Here's a simple idea of how it works: Client and server would use the same implementation of the "world" - objects, physics simulation. So say we have class World, which contains a vector of WorldObjects. WorldObject is a base class for other classes to derivate from (like PlayerObject, BoxObject, MonsterObject). The problem here is how to efficently declare custom rendering methods for those object classes. For example a PlayerObject has to be rendered differently than BoxObject.
The thing to keep in mind is that we can't just create a virtual render method, because that would imply that eg. BoxObject has to #include "OpenGL.h" which CANNOT be done on the serverside (we want to keep the serverside clear off graphic libraries).
So how can this be done? I've come up with an idea like this: create a separate singleton (only clientside) that would contain implementations of rendering methods for different object types (identified by an enum for example), but is that the best way to do this? Do you know anything more efficent and flexible?
Of coure we're talking C++ here, but if there's a rule or practice that you know and use in another language please do share (that's why I didn't really specify the language in the post). Thanks.