Texture Unload Problem

I have hundreds of textures that are 1024x1024 in size. I only need to display around 10-20 of those textures at once. I am using texture compression as well. The program displaying the textures will be running on video hardware with at least 128 meg of RAM. I am employing culling code so that I only display what I need to.

Here is my problem:
After I first start the program everything is really fast. However, if I pan around the window and view more than 50 of those 1024x1024 compressed textures my frame rate drops to the floor. I suppose that texture swapping is occuring but I only view 10-20 textures at once. It seems to me that the system is trying to load the other textures that I previously (but no longer need to) viewed. Why?
If (after viewing 50 or so textures) I only try to view one texture on screen at a time it is still very slow. However, if I delete all the textures except the ones that I need to view the speed kicks back up again. I thought that since I am culling the other textures and not trying to view them (IE…not calling glBindTexture(…)) the system would not attempt to load them (IE…the swapping I am experiencing).

Any suggestions?


I don’t know very much about dealing with that much textures, there are others here who have more experience, but a simple man’s suggestion would be to assign the textures different priorities. For example, set priority=1 for the textures that can be seen from current viewpoint and 0 to others. I don’t know whether it helps, I guess it depends on the drivers, but it’s easy to try out.

A more difficult way is to have a fixed amount of textures in memory, so your card can handle them, and update them dynamically making assumptions on which textures might become visible in the near future.