Page 1 of 1

Overlaymanager pointer?

Posted: Mon Feb 14, 2005 7:42 pm
by LordMyth
Ogre::OverlayManager* OverlayManager = Ogre::OverlayManager::getSingleton();
When doing this I get an error:
MythApp.h:144: error: cannot convert `Ogre::OverlayManager' to ` Ogre::OverlayManager*' in initialization

Is this fixed in the CVS?

Posted: Mon Feb 14, 2005 7:49 pm
by pjcast
use getSingletonPtr() or use the & operator on the result of getSingleton()

Posted: Mon Feb 14, 2005 7:51 pm
by haffax
Actually it never was broken. use getSingletonPtr().

Posted: Mon Feb 14, 2005 8:03 pm
by LordMyth
Oh, OK thanks! What does the getSingleton() function do?

Posted: Mon Feb 14, 2005 8:06 pm
by DWORD
It returns a reference instead.

Posted: Mon Feb 14, 2005 8:06 pm
by bal
LordMyth wrote:Oh, OK thanks! What does the getSingleton() function do?
It return a reference to the class instead of a pointer.

Posted: Mon Feb 14, 2005 8:13 pm
by LordMyth
Ahh! yes of course... I'm stupid these days :lol:
Hmm.. Wonder if it would look better if I accessed things with App::SceneManager.blabla() instead of App::SceneManager->blabla();

Posted: Mon Feb 14, 2005 8:33 pm
by haffax
getSingleton() has an advantage compared to getSingletonPtr(), imho: You get an expressive assertion failed excepetion, when it isn't initialized. getSingletonPtr() will only give you a null pointer.

Posted: Mon Feb 14, 2005 8:38 pm
by LordMyth
Ow! Cool! I'll change everything to references then...