DLL loading for an engine?

Started by
14 comments, last by FxMazter 20 years, 3 months ago
Hi I''ve been thinking about how to implement the loading of DLL''s - "Systems" - in my engine, but can''t come to a sollution yet :/ I have thought of two ways of implementing this: 1.) Making a DLLManager, which will load DLL''s and store an Interface loaded from that DLL in a Map. This will be a singleton. I find that this sollution is the simpliest for me to do, but somehow I don''t like this too much at all... Feels wrong saving all different Interfaces in one Manager... 2.) Making a class DLLLoader, from which other classes that want to be able to load Systems will need to inherit from. So If my BaseApplication wants to be able to load all different systems like MemoryManagerSystem or RenderingSystem it will need to derive from the DLLLoader and then be able to load different interfaces from DLL''s. This way it feels like I''m storing the Interfaces at the "right" places. (Feels more right that the SceneManager loads the TextureManager than the BaseApplication Loading the TextureManager...) But on the other hand it feels more complicated and it feels like it will be a hard time figuring from where to get a particualar interface etc... (is it in the SceneManager or is that interface stored in the BaseApplication...) Or maybe only the BaseApplication should be able to load DLL''s ? How would you guys implement a DLL loading system? Thank you all!
Advertisement
Don''t even mess around with DLL''s. They aren''t very stable.
wtf are you talking about? in what way arent dll''s stable?

As for an implementation it all depends what language your using. If your using C++ i guess the easiest way to do it is to have a standard interface for all the dlls (for example a function called StartDLL or something). That way you can execute that particular function and the dll can do whatever it has to do to get itself into the system, like adding a plugin to a manager...
-jonnii=========jon@voodooextreme.comwww.voodooextreme.com
Yup, i'm using c++

And yes, every dll will have the same interface... with a CreateInterface function which will return a pointer to the wanted interface.

The thing is that my game engine will mostly consist of dll's. I will use the dll version of a main function and use the Core of the engine from a dll.

And all systems will be in dlls.

The RenderingSystem, the SceneManager, the TextureManager... everything will be in Dll's ... so I need a nice system for loading the dll's, and I'm not sure how to inplement it :/

thx!

(and of course dll's is a programmers friedn^^ ... unless you want to recompile everything for a simple change heh...)

[edited by - FxMazter on January 4, 2004 5:51:44 PM]
One way to do it would be to use an interface similar to COM. Look for some introduction to writing COM objects and use the general sturcture to write your own system. Of course you could just use COM, but that wouldn''t be very portable and would require registration of the dll''s. Also you probably don''t need to make the dll''s available through the COM system as you probably won''t be reusing the componenets in another app.

James
how 3d studio max does to load all windows ressources and function from an unknow dll ? its very powerfull, but seem to be very hard.
you''re over-engineering! you''ll be accesing the pointers in a local context anyway, so you''re not really "storing" anything.
Nah, I don''t think i''m over engineering :/

I say it''s better to plan everything ahead, than making the project with crappy planning and in the middle of the project getting to the conclusion that the structure of the engine is too crappy to continue on it...

Anyway, I have already implemented the 1.) sollution. I made a SystemEnumerator that searches for any modules and then adds them to a list, while my SystemManager loads dlls from the SystemEnumerator. It''s all gonna work with interfaces, so the user may later change the MemoryManager or any other system to work the way they want... unless they change the interface

thx anyway guys, though I''m still interested how you guys have done this if you have made a system similar to this.

thx
I think you're overengineering, too. This is something you couls accomplish with one function call:

Init_Engine();

Put it in a class if it fits, but otherwise it's overkill. One function tucked away in a single source file, or in a lib, and you're good to go. The function loads all of the required DLLs one-by-one and you're good to go.


Unless I'm missing something and you're trying to architect a plugin system. Loading DLLs from a configuration script, for example. Even then there's no need to inherit from a DLLLoader interface.

[edited by - aldacron on January 5, 2004 11:47:47 AM]
eh, k... now I got two against me , maybe I am overengineering a little then.

And yes, it is going to be a plugin system. The whole gameengine will consist of plugins. I was thinking of having maybe like 20 or 30 interfaces, covering the SceeneGraph, MemoryManager, LoggingSystem, the Renderer etc.

And the user of my engine will be able to modify the actual behaviour of the SceneGraph or the LoggingSystem by changing the classes, as long as the interfaces still apply.

And I am thinking of having some EditorTool to Enable and Disable different Systems, appart from the Core Systems like the MemoryManager which are mandatory. (some kind of script file that will be loaded...)

And I will also have a InitEngine function that will init all systems that are added...

So basically, I want to have a PreInit phase where I load the systems and retrieve the interfaces and then I actually Init the the systems from the InitEngin or whatever...

[edited by - FxMazter on January 5, 2004 12:16:30 PM]

[edited by - FxMazter on January 5, 2004 12:18:29 PM]

This topic is closed to new replies.

Advertisement