Initialisation problems - SkinSetManager Singleton

hotdot

27-11-2007 18:05:38

Hi,

When i run the demo any time i trace on SkinSetManager::getSingletonPtr or SkinSetManager::getSingleton they seem to be initialized properly (good singleton behaviour) but when i do the equivalent in my code of :

QuickGUI::SkinSetManager::getSingleton().loadSkin("qgui",QuickGUI::SkinSet::IMAGE_TYPE_PNG,mResourceGroup);
mGUIManager = new QuickGUI::GUIManager(mCamera->getViewport());
mGUIManager->setSceneManager(mSceneMgr);


QuickGUI::SkinSetManager::getSingleton().loadSkin generates an error while trying to initialize the mouse cursor. In my code the data member ms_Singleton is NULL or 0x00000... Is there something to do before hand since i am not following the standard OGRE singleton in the declaration of my UserInterfaceManager Dll, we use our own manual singleton in each class, is this a bug when used outside of the ExampleApplication Class ? If so, then relying on Ogre Singleton could pose some potential problems when guessing that a static singleton should be instanciated on the first getSingleton call, as the following code from our managers :

CEventManager& CEventManager::getSingleton()
{
if(m_Instance == NULL)
{
m_Instance = new CEventManager();
}

return *m_Instance;
}


Also i find that having a getSingletonPtr is bad since you can do &xxx::getSingleton if you really need a pointer.

kungfoomasta

27-11-2007 18:13:27

It wasn't very clear in the wiki, but this is what you need to call:

QuickGUI::registerScriptParser();

The reason is because QuickGUI has its own parser for parsing .skinset files, and possibly more files in the future, and needs to be added to Ogre before initializing resource groups. If you call this function all will be fine. :wink:

For completeness, make sure to call it before ResourceGroupManager::initialiseResourceGroups, or before initializing resource groups with QGUI skinset files. It creates the SkinSetManager instance in addition to creating and registering the ConfigParser.