In DirectX is CreateTextureFromFile smart enough to know
if it has already loaded a particular texture?
The reason I ask is that many examples load a mesh's textures by looping through
the materials, using the material's pTextureFilename field to load the textures-
so that may mean a lot of needlessly duplicated textures in memory if DirectX doesn't
recognise textures as being previously loaded (unless you keep track yourself).
quote:In DirectX is CreateTextureFromFile smart enough to know
if it has already loaded a particular texture?
Short answer: It doesn't as far as I can tell, and I'd be surprised if it did. One way to check would be just to try and load a texture from the same file and see if the function returns the same pointer.
Longer answer: I can see that sort of functionality causing weird and confusing problems for us users. It would mean DirectX would have to maintain some sort of internal texture library - do you bother trying to work out if two different directory paths point to the same file? What if some external program overwrites the file or renames it? What about textures modified, or even created procedurally, at runtime? It's quite possible to sort through the issues, but the seemingly simple CreateTextureFromFile function suddenly has different semantics and side-effects from what is documented.