Singleton with irrlicht device?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Singleton with irrlicht device?

Post by Lil Margin »

Hey,
I have a question i could not solve on my own and that is : i heard everywhere to avoid using singletons BUT there is no need for more then 1 irrlicht device...
So in the case of the irrlicht device...isn't using singleton a better idea or not?
and why?
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Singleton with irrlicht device?

Post by randomMesh »

Using singletons is a good design decision in general. So yes, use singletons where they are appropriate.
"Whoops..."
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

You might need more than one Irrlicht device, at least in theory, say having 2 windows with 2 different configurations (if that is possible nowadays).

Singletons IMHO is for things that is never needed to be instantiated more than once (well, I learn you nothing here) so say the file system of irrlicht could be one.

I never really understood why people don't like singletons (when as randomMesh said, used where appropriate).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Singletons are also using a very special access scheme. The static method is rather API-disrupting and often not necessary. E.g. the filesystem in Irrlicht is not user constructable, because there's no public API function for it. However, we can also avoid the static method, as we can pass the pointer to the filesystem instead. IMHO singleton is seldomly fitting.
Post Reply