PDA

View Full Version : "Unload" OpenGL textures



Ñuño Martínez
08-04-2012, 12:53 PM
May be a very simple question.

I know, there's the glDeleteTextures procedure that does the work, so I can create a "texture manager" that loads and unloads the textures, but is there a way to delete all textures in a simple call?

User137
08-04-2012, 02:22 PM
No, i don't think there are other ways. Possibly you can reinitialize the whole rendering context and OpenGL, but that's a little overkill compared to just going through each texture and deleting them 1 by 1.

Jimmy Valavanis
08-04-2012, 02:39 PM
glDeleteTextures does the work and also can delete all your textures at once if you store all of them in a single Array.

WILL
08-04-2012, 08:04 PM
I make my own procedures that will delete those loaded for specific purposes. You can load all your textures into any array like Jimmy states and then simply plug that number into glDeleteTextures yes, but if you want better management be sure to keep those that are needed only at specific times (level specific or splash screens) seperate from those needed all the time. (main menu and in-game menu graphics)

Ñuño Martínez
09-04-2012, 06:39 PM
Ok. Then I should use a "texture manager".

Thank you.

pitfiend
09-04-2012, 11:14 PM
This is obvious, but maybe you can use tlist as it is a general purpouse list manager with add, insert and delete metods for any kind of objects.

Ñuño Martínez
11-04-2012, 12:47 PM
I was concerned about load/unload textures to the OpenGL library, but your suggestion of using TList makes me think about load and unload the bitmaps from disk. Thank you, fitflend.

User137
12-04-2012, 05:57 AM
Obviously you always want to load the textures straight from disk. But another thing you need to pay attention to is how many textures you use. Each call of glBindTexture() is a slow operation. So for example a tile map, being split each in its own texture would be a huge performance loss.

pitfiend
12-04-2012, 02:57 PM
Obviously you always want to load the textures straight from disk. But another thing you need to pay attention to is how many textures you use. Each call of glBindTexture() is a slow operation. So for example a tile map, being split each in its own texture would be a huge performance loss.
That's why loading/setup/init sequence exists in every game before you can actually play. It's no secret, isn't it?