DLL Design
Question submitted by (14 March 2000)




Return to The Archives
 
  I'm relatively new to windows programming and I'm trying to write a small game (for learning purposes) that supports multiple rendering APIs. Now, I want to use OOP but I also want to keep the game 'engine' in explicitly loaded DLLs (using LoadLibrary) so I can easily update the engine but I don't know if you can import OOP classes without linking to the export library.

How do games like Unreal handle DLLs? Do they use explicitly loaded DLLs, if so, do they use OOP, if so, how? Or do they simply link with the export library?

Can you import OOP classes from explicitly loaded DLLs (loaded using LoadLibrary)? Or do you have to use C functions and structures?

Any help clearing up this matter would be appreciated.
 
 

 
  I tend to use LoadLibrary directly. If you link to the export lib, you need to have the DLL present. By manually loading available DLLs using LoadLibrary, you have the ability to choose which DLLs to load/use. From there, you simply define a common API of your own (implemented as an interface class) and simply ask the DLL for a pointer to it's interface class.

The DLL would instantiate an interface object that implements the API you've designed, and when asked, returns the pointer to this class. Everything else in the DLL can remain private to that DLL since the interface class is all that would be needed by the application.

You can find more information on this topic in a couple of previous Q/A called "Modular 3D Engines" (19 November 1999) and "Modular 3D Engines - Part 2" (11 December 1999). Both of these can be found in the FOK archives.



Response provided by Paul Nettle
 
 

This article was originally an entry in flipCode's Fountain of Knowledge, an open Question and Answer column that no longer exists.


 

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.