Question about Resource Management

Started by
0 comments, last by ApochPiQ 18 years, 1 month ago
Hey everyone, I was going to write a resource manager and came across some questions. first i thought i would load my resource and lets say make a texture out of it and then safe that in my manager thats going to be a singleton and thus accessable from everywhere. But then i thought about a lost device and i realized that i would have the reload the complete manager. so the plan for now is: load a resource into memory and save it then create a texture from file in memory my question now is: with this solution dont i need twice the space ? one for the safed file in memory and then when i create the texture from the file in memory? this is some code out of game coding complete:

Resource resource(m_textureFile);
int size = g_pApp->m_ResCache->Create(resource);
assert(size);
char* textureBuffer = (char*)g_pApp->m_ResCache->Get(resource);
if(FAILED(D3DXCreateTextureFromFileInMemory(....))

So with every call to D3DXCreateTextureFromFileInMemory(....) do i need more memory or am i just getting a pointer to the file in memory? sorry if this is a stupid question but i am still at the beginning:) thx a lot in advance for any hints or answers:)
Advertisement
Losing a device is rare enough that you shouldn't have to worry about the cost of reloading your data. In any case, loading texture data from disk isn't that slow; you're right that storing an extra copy in memory is going to be a bit wasteful. In general, you should be fine just loading the texture data itself, and re-reading from disk in case of catastrophic failures (like a device becoming invalid).

Hope that helps clarify your plans a bit [smile]

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement