I'm looking more in details about cleaning not needed ressources in my game, but i'm experiencing some difficulties with textures :/
I'm using irrlicht 1.5.1 (don't know if it matters but i didn't tried the 1.6) in OpenGL
I've made a sample code that illustrate my problem :
Code: Select all
irr::IrrlichtDevice* dev = irr::createDevice(irr::video::EDT_OPENGL) ;
irr::video::ITexture* texture = 0 ;
int test = 0 ;
bool t = true ;
while (dev->run())
{
if (dev->isWindowActive())
{
dev->getVideoDriver()->beginScene(true, true, irr::video::SColor(255, 0, 255, 0)) ;
dev->getSceneManager()->drawAll() ;
dev->getVideoDriver()->endScene() ;
if (++test > 1000)
{
if (t) // Add smtg
{
printf("ADD\n") ;
dev->getSceneManager()->addCameraSceneNode(0, irr::core::vector3df(0, 0, 0), irr::core::vector3df(1, 0, 0)) ;
texture = dev->getVideoDriver()->getTexture("./test.png") ;
irr::scene::ISceneNode* img = dev->getSceneManager()->addCubeSceneNode(1, 0, -1, irr::core::vector3df(330, 0, 0), irr::core::vector3df(0, 0, 0), irr::core::vector3df(0, texture->getSize().Height, texture->getSize().Width)) ;
img->setMaterialTexture(0, texture) ;
img->getMaterial(0).getTextureMatrix(0).setRotationDegrees(irr::core::vector3d<irr::f32>(0, 180, 0)) ; // flip
img->setMaterialFlag(irr::video::EMF_LIGHTING, false) ;
img->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL) ;
t = !t ;
}
else // Remove
{
printf("REMOVE\n") ;
dev->getSceneManager()->clear() ; // REMOVE ANYTHING THAT USED THIS TEXTURE OK ?
dev->getVideoDriver()->removeTexture(texture) ;
t = !t ;
}
test = 0 ;
}
}
}
return 0 ;
}
Don't understand what is happening :/ and the debugger don't help me a lot ^^
So thanks if you can help me !
PS : as always, sorry for bad english !