Freeing textures.

Started by
13 comments, last by Gorax 18 years, 10 months ago
Is there some slick way to release all of the textures you've created? Totaly wiping out every texture, or do you always have to manualy do it for each one. I'm just wondering if there is some cool quick way to wipe the slate clean without any risk of missing one, there by waisting memory.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
Advertisement
glDeleteTextures()
im sure that if your textures are in one array then you can use the function above to delete them in one time with on waste memory.
Quote:Original post by _the_phantom_
glDeleteTextures()


I am aware of the function, but thats not what I was looking for. I'm talking about something that deletes any and all textures without any need or regard for their ID value. The equivalent of droping a bomb on a town to make sure alllll the buildings are down at once instead of walking in with a bulldozer and wrecking ball to take them out one at a time.

I don't think such a thing exists, but I wanted find out for sure, since it would be handy.

edit...
Quote:Original post by dopo
im sure that if your textures are in one array then you can use the function above to delete them in one time with on waste memory.


Their not. Thier in groups mostly, but there are sets which are way more complicated, and the amount can very wildly.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
well the only other way would be to delete the context as that will free up the resources linked with it (unless they are shared by another context)
Quote:Original post by Goober King
I am aware of the function, but thats not what I was looking for. I'm talking about something that deletes any and all textures without any need or regard for their ID value. The equivalent of droping a bomb on a town to make sure alllll the buildings are down at once instead of walking in with a bulldozer and wrecking ball to take them out one at a time.

Well, destroying the render context should work... as long as it's not shared, and it'd destroy more than just the textures but you did say equivalent of dropping a bomb... -.^

edit: d'oh, too slow >>;
Quote:Original post by tolaris
Quote:Original post by Goober King
I am aware of the function, but thats not what I was looking for. I'm talking about something that deletes any and all textures without any need or regard for their ID value. The equivalent of droping a bomb on a town to make sure alllll the buildings are down at once instead of walking in with a bulldozer and wrecking ball to take them out one at a time.

Well, destroying the render context should work... as long as it's not shared, and it'd destroy more than just the textures but you did say equivalent of dropping a bomb... -.^

edit: d'oh, too slow >>;


That would unforutantly be too big a bomb. The deal is for the fighting game Lore in my sig. When I go from game play, back to the character select screen I have to kill off a whole mess of textures. I don't want to kill off the rendering context which I'm guessing would be a really slow and just bad way to program.

Most of the textures are in arrays. Sets reserved for the stages, option screen, title screen. Those can all be easily be wiped out at once. The animation frames however get tricky. Seeing as how all the ID are all wrapped up with all the animation information. It recently occured to me I hadn't been freeing up those texures. Just replacing them with more of the same. Since I will have to go through all the sturctures and such to figure out how to correctly remove them all, I was hoping for an easy way to wipe them all out since I wont need a single one of the textures once I leave the gameplay mode and go back to the character select screen.


------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
If you are using a class or similar to encapsulate your data, you can put any freeing in their destructor. That way you can just delete them, or let them go out of scope, rather than explicitely calling the gl functions.
Quote:Original post by baldurk
If you are using a class or similar to encapsulate your data, you can put any freeing in their destructor. That way you can just delete them, or let them go out of scope, rather than explicitely calling the gl functions.


Wouldn't that just wipe out the ID value? The actual texute data is never given to you by OGL, just a reference value. I would think you MUST use gl functions to free a texture up.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
yes, you are right, you must free up the textures via OpenGL functions, however I belive the point baldurk was driving at was that you could place the glDeleteTextures() call in the destructor of the class and use that to free the texture on release.

The alternative is that if you have a resource manager of some type on creation you request a handle to a texture from the texture manager and then when you destroy the object it just tells the texture manager it doesnt require it any more, then before you pull up your character selection screen you ask the texture manager to flush all unused textures thus freeing them in one lump (either via driect calls to the glDeleteTextures() function or by destorying objects which do the same job).

Really the best way depends on how your game engine is arranged.

This topic is closed to new replies.

Advertisement