How could i get a singleton instance of IrrlichtDevice

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

How could i get a singleton instance of IrrlichtDevice

Post by Guest »

How could i get a singleton instance of IrrlichtDevice, Since i must use it in a dll which as a plugin. And i apparently know when i create the device, and when i load then use the plugin. i can make sure that i use the dll(plugin) after the creation of the IrrlichtDevice.

But now, i can't ge a singleton of the IrrlichtDevice to access it. How can i do it. Should I write a wrap for it, or irrlicht has already implemented it.
Guest

Post by Guest »

Why no men response?
Jedive
Posts: 146
Joined: Wed Apr 28, 2004 5:51 pm

Post by Jedive »

AFAIK, you can get a singleton instance of an IrrlichtDevice, basically because it's not a singleton class. You can have several devices in your application, you are responsible of storing the resulting devices after calling createDevice();
Guest

Post by Guest »

The Singleton pattern doesn't apply well to DLLs, if you had a singleton in your host app or your dll, you'd still get two different instances of the singleton because they live in separate address spaces.

You *could* hack it and have a static global IrrDevice in your DLL and retreive the pointer to it using an exported function, but as Irrlicht isn't coded for multi-threading it might start becoming tricky for your to manage, especially if other applications are using your DLL (however unlikely).
Post Reply