Archived

This topic is now archived and is closed to further replies.

Texture storage

This topic is 5017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys I was after some advice about texture management. I am writing a small app and currently it stores up to 20 textures in an array though of course it is easy to make that larger. Geometry that uses these textures just contains a reference to the array element where the texture it uses resides...so the texture can be found instantly. However if I want to make things scalable and have an unlimited number of textures i need something dynamic. Obviously i could use a linked list, and i do this for my world objects, but i heard that binary search trees or even red-black trees are better for texture lookup beacuse traversal is so fast. I was wondering what professional programs, or what you use for storing your textures, and what you would recommend. Thanks in advance

Share this post


Link to post
Share on other sites
I personally use a std::map (C++), with each element being a structure holding a texture handle and a reference count so that I know when textures can be safely released. A linked list presents the problem (albeit a minor one, unless you have a _lot_ of textures) of having O(n) search time when looking for a specific texture.

My texture handler will also report at program exit which textures were not properly released, and release them, to help debugging.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites