Sign in to follow this  
Rozik

Question about Resource Management

Recommended Posts

Rozik    176
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:)

Share this post


Link to post
Share on other sites
ApochPiQ    23065
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this