dave news

Game programming

[NYI] Stuff

The Resource Manager

This document outlines my thoughts on resource management. Every game needs a resource manager to manage keeping track of which resources or assets of various types are loaded, so that you don't load any given texture or whatever twice. Like with the file manager doc, none of this is revolutionary. Game Programming Gems has perfectly good descriptions of how resource managers should work.

One fundamental choice to make is how to make sure that the game doesn't free any resources that are in use. There are two major choices: ref counts and locking, although really they're basically the same. I slightly prefer the Lock/Unlock method to the AddRef/Release method for tracking resource usage, because to me it's a little more clear what's going on. You also don't have to deal with the complexity of whether the rseource manager itself holds a reference on the object (in which case a ref count of 1 indicates that the object isn't in use).

Typically resource managers expect all managed resources to derive from some base class; we will do that here as well. Our base Resource class will implement the locking semantics described above.

The resource manager should support tracking memory usage and resource counts by resource type, so you know how many textures you have loaded and how much RAM is being consumed.

Game links:


File Manager

Resource Manager


Solitaire spec