How to see if a resource group exists?

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

How to see if a resource group exists?

Post by Zeal »

Is there anyway to check and see if a resource group already esists? I tried..

Code: Select all

Ogre::ResourceGroupManager::getSingleton().getResourceDeclarationList( "GroupName" );
But it crashes if the resource group doesnt exists.

The reason I want this feature is so I can easily tell if a resource group has already been initialised when my app reloads, or switches game states, ect...
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

Post by stoneCold »

You can always extend the above with "try{}catch(...){}" to get the desired effect, though it might be worth a patch if such a function not already exists.
At least I don't know one.
my tweets | www.fuse-software.com | home of vektrix (Flash GUI for Ogre3D) and caspin (ActionScript 3 Virtual Machine Wrapper)
CheetahShrk
Kobold
Posts: 38
Joined: Wed Dec 13, 2006 4:52 am

Post by CheetahShrk »

http://www.ogre3d.org/docs/api/html/cla ... Managera43

Use getResourceGroups, and go through the list you get to check if it exists.

A quick function, not sure if it works though.

Code: Select all


bool groupExists( Ogre::String &group )
{
	Ogre::StringVector groupNameList = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 
	Ogre::StringVector::iterator resGroupIter = groupNameList.begin(); 

	for(;resGroupIter < groupNameList.end();resGroupIter++)
	{ 
		Ogre::String resGroupName = (*resGroupIter); 
		if( resGroupName == group )
		{
    			return true;
 		} 
	}
	return false;
}
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

Yeah I thought about writing a little function like that to iterate through the groups.

I was hoping there would be a built in command, but this will work I guess.
Post Reply