How to pre-load textures? [solved]
Posted: Sun May 21, 2006 6:06 pm
For The Blob I have a lot of textures that are initially not in the game and are only used if the player paints a building in a new colour, which uses a different texture. Each time a texture is used for the very first time, the game freezes for a moment to load the texture and then continues. I know exactly which textures will be used, so how can I force the loading of these textures on start-up?
I am currently using something like this to load my resources on start-up:
I figured a very dirty solution for this would be to render one screen in the background at start-up that uses all these textures, but I am hoping a better solution exists.
Thanks in advance!
I am currently using something like this to load my resources on start-up:
Code: Select all
std::string groupName = "levelAssets";
Ogre::ResourceGroupManager& rGM = Ogre::ResourceGroupManager::getSingleton();
rGM.createResourceGroup(groupName);
rGM.addResourceLocation("Textures", "FileSystem", groupName);
//meshes are not automatically loaded by Ogre, so do this by hand
Ogre::StringVectorPtr meshes = rGM.findResourceNames(groupName, "*.mesh");
for (unsigned int i = 0; i < meshes->size(); i++)
{
rGM.declareResource((*meshes)[i], "Mesh", groupName);
}
rGM.initialiseResourceGroup(groupName);
rGM.loadResourceGroup(groupName);
Thanks in advance!