Hi
I have a problem with my work, the bug ocur when I load a texture then delete the texture and then try reloading again the same texture, the program explode.
how can I work this out.
Problem with textures
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Code: Select all
ITexture * tex = driver->getTexture("../../media/sydney.bmp");
// This is the correct way to 'delete' a texture
driver->removeTexture(tex);
// All is well when getting it again
tex = driver->getTexture("../../media/sydney.bmp");
// This is more evil than Dick Cheney in a Darth Vader costume.
delete tex;
// HORRENDOUS KABLOOIE!
tex = driver->getTexture("../../media/sydney.bmp");
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
DanielLoynaz
- Posts: 6
- Joined: Tue Mar 11, 2008 5:06 pm
Rogerborg your answer this very well, but the problem was no
The problem is when we load a. obj file that has the address of the. mtl file and it is the one that has address of the textures, I don't worry to assign the textures to the materials.
Now, we need to load many objects that have many textures and the memory that it is consumed by the program it increases considerably. We need to remove objects and load them again. When you eliminate the node with the mesh, the consumed memory doesn't lower, only lowers when we eliminate the textures, we make it this way:
for (int j = 0; j <node.MaterialCount; j++)
{
Material mat = node.GetMaterial(j);
Texture text2 = mat.Texture1;
mat.Texture1 = null;
if (text2 != null)
device.VideoDriver.RemoveTexture(text2);
}
node.Remove ();
//we program in C #
If we load the mesh again and assign it to the scene is when the programs crash.
Now, my questions!!
there is some other efficient way for liberating memory?
How i can eliminate the textures and load the mesh again without problems?
Thank you
Forgive my English, it is very bad!
Now, we need to load many objects that have many textures and the memory that it is consumed by the program it increases considerably. We need to remove objects and load them again. When you eliminate the node with the mesh, the consumed memory doesn't lower, only lowers when we eliminate the textures, we make it this way:
for (int j = 0; j <node.MaterialCount; j++)
{
Material mat = node.GetMaterial(j);
Texture text2 = mat.Texture1;
mat.Texture1 = null;
if (text2 != null)
device.VideoDriver.RemoveTexture(text2);
}
node.Remove ();
//we program in C #
If we load the mesh again and assign it to the scene is when the programs crash.
Now, my questions!!
there is some other efficient way for liberating memory?
How i can eliminate the textures and load the mesh again without problems?
Thank you
Forgive my English, it is very bad!
