Skip to main content
gamedev.net
🔒 Locked

ResourceManager question?

Started by McZ 1 reply 450+ views
Original Post
McZ
McZ
well... I have seen some different aproaches with a ResourceManager.. and I got some different ideas so.. what I have some questions 1. is there any difference if I have one ResurceManager for everything that is a resource in my engine, or to have like one resource manager for each? 2. well, what is the difference between using a ID for all resources then call he ResourceManager for the data, or using pointers directly to the data?! 3. what is the benefits of having one TextureManager of itself instead of use the ResourceManager? 4. if I have a stand-alone TextureManager and then make that one abstract and implement one TextureManagerGL and one TextureManagerD3D or something like that what would be the benefits of that?
Alan Kemp
Alan Kemp
quote:

1. is there any difference if I have one ResurceManager for everything that is a resource in my engine, or to have like one resource manager for each?



Its mostly a matter of personal taste, as far as I can see it makes little difference.

quote:

2. well, what is the difference between using a ID for all resources then call he ResourceManager for the data, or using pointers directly to the data?!



One advantage of using IDs instead of returning pointers would be allowing the resource manager to verify that the resource still exists (or maybe reload it) when its needed.

quote:

3. what is the benefits of having one TextureManager of itself instead of use the ResourceManager?

4. if I have a stand-alone TextureManager and then make that one abstract and implement one TextureManagerGL and one TextureManagerD3D or something like that what would be the benefits of that?



There are two ways of doing this. You could specialize the texture manager, or specialize the texture data structure it contains. Personally I would go with the later, so:


class TextureData
{
};

class TextureData_DX9 : public TextureData
{
LPDIRECT3DTEXTURE9 m_Texture;
};

class TextureData_OGL : public TextureData
{
unsigned char * m_Texture;
};

class TextureManager
{
std::some_storage_class < TextureData > myTextures;
};


Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
psykr
psykr
Also, if you use resource handles (IDs) instead of straight pointers, you can rearrange the memory used however you like without having to inform the client about the changes.

Topic Locked

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

Sign in to reply to this topic.