- Code: Select all
void Video::ClearTextures(){
// clear all textures except reusables...
for (long l = irrVDriver->getTextureCount() - 1; l >= 0; l--)
if (irrVDriver->getTextureByIndex(l)->getName().find("#default") == -1 &&
//irrVDriver->getTextureByIndex(l)->getName().find("particlered.bmp") == -1 &&
//irrVDriver->getTextureByIndex(l)->getName().find("particlewhite.bmp") == -1 &&
//irrVDriver->getTextureByIndex(l)->getName().find("fireball.bmp") == -1 &&
irrVDriver->getTextureByIndex(l)->getName().find("./media/images/loading.bmp") == -1 &&
irrVDriver->getTextureByIndex(l)->getName().find("./media/fonts") == -1)
irrVDriver->removeTexture(irrVDriver->getTextureByIndex(l));
}
After removing all of the other textures (saving the ones included in the IF statement), I have the correct count and names of the textures that I wanted to stay in the cache.
However, the next time my program attemps a ISceneManager::drawAll(), it crashes.
The 3 lines that are commented in the code above are the textures that seem to be the culprits. If I force those 3 specific textures to be left in the cache (uncomment the lines), my program does not crash.
I take this as either I have a memory leak or something is trying to reference those 3 textures. But I don't understand how it can be the latter if I successfully removed the textures from the cache and I know 100% that nothing else is trying to reference those textures. The getReferenceCount() of those 3 textures gives me a count of 1. I don't have a seperate pointer variables for the textures either.
Any thoughts would be greatly appreciated.
Sorry if I was vague at all. It's 4:30am and I'm pretty tired
Edit:
I was going to ask also if there was something I needed to do after removing individual textures? I'm assuming Irrlicht auto-updates everything that needs to be updated when it comes to referencing textures and such.

