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 » Mon Apr 23, 2007 3:19 am

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...
0 x

User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria

Post by stoneCold » Mon Apr 23, 2007 3:32 am

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.
0 x
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 » Mon Apr 23, 2007 4:02 am

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;
}
0 x

User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal » Mon Apr 23, 2007 4:55 am

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.
0 x

Post Reply