Skip to main content
gamedev.net
🔒 Locked

Texture storage

Started by Mr Lane Mar 24, 2004 at 9:12 AM 2 replies 300+ views
Original Post
Mr Lane
Mr Lane
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
JinJo
JinJo
I just use a linked list for it.
Mr Lane
Mr Lane
Yeah i think i will. I have done BST''s before, but I think I will keep things simple.

Thanks.
JTippetts
JTippetts
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.