Skip to main content

Game Resource Management

Game Resource Manager

  • Sound understanding C++, pointer, and template.
  • basic understanding of std::vector and std::map. 

Depending on your level of programming in C++ this tutorial maybe easy or hard to comprehend. I will try to explain things in a way that is simple to understand. Note that the resource manager here uses C++ template. If you don’t know what a template is in C++, it is highly recommend that you review and understand it before you read this article. This is a general-purpose resource manager; C++ templates will allow us to use the same class to create many different resource-manager to manage different objects of different type. The core resource manager will be used to create manage resource managers automatically, and manage them. 

@Note ds::dlist is my own custom linked list. std::vector can be used instead. 
@Note ds::astring is my own custom string. std::string can be used instead.


What is a Game Resource Manager? A game resource manager manages objects in the fallowing way. Adding a resource to its list, removing a resource from its list, deleting a resource from its list, creating and loading a resource to its list. Every resource in its list should be unique and has only one of it. It keeps track of how many copies of a resource are being used. When the number of a resource being use drop to zero the resource is then deleted. If the list containing resources size is zero that list is deleted. For this implementation of a resource manager, there are 5 main classes to the whole system. 
  1. Manager - the manager class is used to destroy a manager.
  2. Resource - a data structure use as a container for an asset and its name. This binds a name to an asset. Each resource must have a unique name so that the correct asset can be fetch when queried.
  3. ResLoader - are used to load a specific resource into the manager it is attached to. The ResourceLoader is the only class leave for the programmer to implement. Loaders are added to ResourceManagers so that a manager can load a specific file. One ResourceManager can contain multiple loaders, giving it the capability to load multiple files.
  4. ResMgr - ResourceManagers is the class that manages the Resources and Loaders.
  5. CoreResMgr - CoreResourceManagers will contain and manage all the ResourceManagers ever create in a program lifetime. CoreResourceManagers is use to create new ResourceManager automatically and retrieve ResourceManager. 
Included Article Links:


Popular posts from this blog

Resource Manager - (Game Resource Management)

Resource Manager - (Game Development Resource Management)

#include "ResLoader.cpp"

Definition: MANAGER:

Manager member variables:
ds::astring name;
nameis the name of the  resource manager.


Resource - (Game Resource Management)

Resource - (Game Development Resource Management)

#include “dlist.hpp” #include “charstr.hpp”

Definition: RESOURCE:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46template<classAsset>classResMgr;template<classAsset>classResource{friendres::ResMgr<Asset>;public:Asset*object;voidSetLoaded(boolvalue){isloaded=value;}boolGetLoaded()const{returnisloaded;}ds::astringconst&GetName()const{returnisloaded;}intGetReferenceCount()const{returnreference_counter;}private:Resource(ds::astringconst&name):object(nullptr),reference_counter(0),name(name),isloaded(false){}~Resource(){}private:intreference_counter;ds::astringname;boolisloaded;};
Resource member variables details.
Asset* object;
is the asset that is to be manages. Asset is made to be a pointer to allow the adding of an asset to the manager. With out the uses of a pointer the asset will have to be copied each time an asset is added to…