   Implementing Renderers in a DLL
  Just fishing for some opinions here. I've been looking at trying some simple render abstraction lately into DLLs, mostly for personal education rather than an actual release of anything. I figure that if I'm going to research it I may as well try to make it as real world as possible, though, so I've set out a list of requirements for myself:1) The DLLs will be linked at runtime, not at compile time. (I'd just do it as a lib otherwise...)2) I would very much like the render interface to be object based, or at least emulate it.3) One of the big benefits of abstraction (IMO) is that anyone else can come along and build a new renderer that suits their needs/platform, so I want to design this with ease-of-use for other implementors in mind.And that last point is why I'm here! If you were to be given an abstract rendering API that you were supposed to implement in a DLL, how would you want it to work? I've tossed around a couple of ideas thus far, the most attractive being that I would have some pre-defined classes that would wrap DLL calls and store a void* inside them that the DLL can use however it wants, but on a real-world level that seems to get cumbersome pretty quick. Does anyone have any cleaner/better ideas, or have you seen any existing systems that you liked?   
  The best way I've found of doing this is to use the following (but wrapped up better):Project Interfaces.lib:IInterfaces.h:bool operator < (GUID lhs, GUID rhs){  return memcmp (&lhs, &rhs, sizeof (GUID)) < 0;}typedef void *(*CreateInstanceOf) (void);class IInterface {public:  virtual ~IInterface (void)  {  }  const static GUID ID;};class IRenderer : public IInterface{public:  virtual ~IRenderer (void)  {  }  virtual void DoSomething (void) = 0;  const static GUID ID;};IInterfaces.cpp:const GUID IInterface::ID = {0x741f726f, 0x18ae, 0x42ce, {0x89, 0x63, 0xc2, 0xb3, 0x1b, 0x04, 0x7f, 0x7b}};const GUID IRenderer::ID = {0xc19a323b, 0xe508, 0x41ba, {0x85, 0x91, 0xef, 0x7c, 0xc9, 0x3c, 0xfb, 0x29}};Project: main applicationinterface.cpp:#include <map>std::map <GUID, CreateInstanceOf>  m_factory;void RegisterInterfaces (void){  for each DLL in app directory  {    LoadLibrary (filename of dll);    proc = GetProcAddress (RegisterInterfaces);    proc (&m_factory);  }}void CreateInterfaceFromGUID (GUID *id){  return m_factory [id] ();}interface.h:void *CreateInterfaceFromGUID (GUID *id);template <class T>T *CreateInterface (void){  return reinterpret_cast <T *> (CreateInterfaceFromGUID (T::ID));}DLL Project:class CRenderer : public IRenderer{  virtual void DoSomething (void)  {    OutputDebugString (TEXT ("Hello world!\n"));  }};void *CreateRendererInterface (void){  return new CRenderer;}void RegisterInterfaces (std::map <GUID, CreateInstanceOf> *factory){  factory [&IRenderer::ID] = CreateRendererInterface ;}Then, you call CreateInterface to create an instance of an interface, thus:ISomeInterface *i = CreateInterface <ISomeInterface> ();Things to add: you'll need some way to handle multiple creators of a given interface, for example DLL A implements and registers a creator for IAnInterface as well as DLL B.Skizz   