Skip to main content

Using CoreResMgr and ResMgr and ResLoader - (Game Resource Management)

Using CoreResMgr and ResMgr and ResLoader

Implementing ResLoader. All that is needed to be done is inherit ResLoader and override the load method.

#include "ResourceManager"

class FontResLoader :public kege::res::ResLoader< gfx::FontSheet >
    gfx::FontSheet * Load(const LoaderContext& info, kege::ds::astring const& filename);

Overriding the load method is don't like so.

gfx::FontSheet * FontResLoader::Load(const LoaderContext&amp; context, kege::ds::astring const&amp; filename)
    // use the resumer member var pointer to create the new a font resource asset
    gfx::FontSheet * font = resmgr-&gt;Create(;
    if ( !font ) return font;

    // since my font class has a load function to i use it to load the filename
    if( !font-&gt;Load(filename.c_str()) )
        return nullptr;
    // then i use the context data to set the font name
    return font;

:   res::ResLoader&lt; gfx::FontSheet &gt;("font")
creating a resource.
CoreResMgr  cormgr;
ResMgr<Font> * resmgr  = cormgr.CreateResMgr< Font >(new res::FontResLoader);
loading a resource.
resmgr->Load(nullptr, "~/font/monaco.font");
what would happen if we load the same font more than once? 
  1. Would a new font get loaded with the same name.
  2. Will the font that already exist get return.
resmgr->Load(nullptr, "~/font/monaco.font");
resmgr->Load(nullptr, "~/font/monaco.font");

  1. the font that already exist will get returned. objects should not be loaded if it was already loaded before. this is what a resource manager suppose to do.
retrieving a resource.
Font * font = resmgr->Get(nullptr, "monaco.font");
deleting a resource.


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.


Game Resource Management

Game Resource Manager
Requirements 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. 

@Noteds::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 ob…

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…