Problem with textures

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
DarkTech
Posts: 2
Joined: Wed Mar 05, 2008 3:48 pm

Problem with textures

Post 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.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Jesus.. your program exploded... are you ok???

:lol:

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.
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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");
Please upload candidate patches to the tracker.
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

Post 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!
Post Reply