get a list of all available Textures?

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

get a list of all available Textures?

Post by johnhpus »

I'm trying to get a list of all of the textures in the Media/Materials/Texture folder. I had thought that this code would give me the names of those textures.

Code: Select all

	std::vector<std::string> getAllTextureNames()
	{
		std::vector<std::string> vecTextureNames;
		Ogre::TextureManager::ResourceMapIterator iter = Ogre::TextureManager::getSingleton().getResourceIterator();
		while( iter.hasMoreElements() )
		{
			Ogre::ResourcePtr rptr = iter.peekNextValue();
			vecTextureNames.push_back( rptr.get()->getName() );
			iter.moveNext();
		}
		return vecTextureNames;
	}
But this doesn't seem to work right. It gives me some textures but far from all. I wonder if maybe this code is only listing the textures that have been loaded by Ogre so far? I use something very similar for listing Material names and it works fine.
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Post by johnhpus »

Ok. It seems that yeah, they're not listed untill they're loaded. I think it must be this way for the GpuManager as well. So does Ogre provide the list I'm looking for somewhere or is it just up to me to make a list?
Captain Nemo
Greenskin
Posts: 134
Joined: Sun May 02, 2004 5:06 pm
Location: Kassel, Germany
Contact:

Post by Captain Nemo »

You could use something along these lines, using the FileSystem class:

Code: Select all

	
FileSystemArchive fileSystem("../Media", "FileSystem");
fileSystem.load();
StringVectorPtr files = fileSystem.find("*.tga", false);

for (StringVector::iterator i = files->begin(); i != files->end(); ++i)
{                  
    String fullName = *i;
    ....

}
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Post by johnhpus »

thanks
Post Reply