Sign in to follow this  

Game/graphic engines resource systems

This topic is 4019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a little bit of trouble with my design of my resource system. Actually the basic concept of the resource system is pretty good. The problem is when I'm loading textures, and presumably later on, shaders. I'm using D3D9, so to create a texture, you need access to the D3D device pointer. Here's a little how my resource system is supposed to work: We have a series of objects, IResource, IResourceLoader, CResourceManager, CFileSystemManager, IReadFile. Whenever something needs to be loaded, the resource manager checks that it hasn't been already loaded. If it has, it just returns a IResource pointer to the object (if something is returned from an IResource derived class, it should be const). If it needs to be loaded, the resource manager checks the numerous file systems (hard disk, archive, etc), gets an IReadFile pointer to an object to read the file, and then searches for a resource loader that loads that specific kind of file (identified by file extension). Once the file is loaded by it's resource loader, an IResource pointer is returned. Each IResource object has reference counting, but does not automatically delete itself when the count reaches 0. I might put that in later, but I'm not willing to deal with the problems at the moment. Okay, that's how resources work ... except for shaders and textures. I have a set of objects designed to add a layer of abstraction between the user app and any pointer to a texture or shader object. So, all the app gets to play with is an object with the file name and an id, which is allocated by the video driver object. These objects are also reference counted, seperatly from the IResource objects (ie. they are not derived from IResource). Basically, the whole problem is that: 1. I think I've introduced too many layers of abstraction and am thinking of getting rid of the texture and shaders objects that contain only the id's, and 2. You need a pointer to the D3D device to create a texture or shader, and this device pointer is kept in the video driver object, which has no communication with an IResourceLoader derived object, and passing pointers around seems very messy. I know I haven't explained as well as I'd like, but I'll come back tonight (in a hurry at the moment) to expand and expound some more. My question is: do you have any ideas? Should I be getting rid of those extra texture and shader abstraction objects? How have you structured your resource system?

Share this post


Link to post
Share on other sites
I'd probably pass the device pointer to the constructors of the concrete IResourceLoader-derived classes that handle textures and shaders - if they require device pointers in order to operate, then don't allow them to exist without one.

Share this post


Link to post
Share on other sites

This topic is 4019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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