Page 1 of 1
Problem with textures
Posted: Fri Mar 21, 2008 4:50 pm
by DarkTech
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.
Posted: Fri Mar 21, 2008 5:28 pm
by JP
Jesus.. your program exploded... are you ok???
Show us the code that you use relating to the textures and the bug. Using your debugger might also be a good idea to see if you can see anything wrong that's going on.
Posted: Fri Mar 21, 2008 7:23 pm
by rogerborg
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");
Rogerborg your answer this very well, but the problem was no
Posted: Fri Mar 21, 2008 10:24 pm
by DanielLoynaz
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!