Skip to main content

Posts

Game Resource Management

Recent posts

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"

classFontResLoader:publickege::res::ResLoader<gfx::FontSheet>{public:gfx::FontSheet*Load(constLoaderContext&info,kege::ds::astringconst&filename);FontResLoader();};
Overriding the load method is don't like so.


gfx::FontSheet*FontResLoader::Load(constLoaderContext&amp;context,kege::ds::astringconst&amp;filename){// use the resumer member var pointer to create the new a font resource assetgfx::FontSheet*font=resmgr-&gt;Create(context.name);if(!font)returnfont;// since my font class has a load function to i use it to load the filenameif(!font-&gt;Load(filename.c_str())){resmgr-&gt;Delete(context.name);returnnullptr;}// then i use the context data to set the font namefont-&gt;SetName(context.name);font-&gt;SetSID(context.name);returnfont;}FontResLoader::FontResLoader(…

Core Resource Manager - (Game Resource Management)

Core Resource Manager - (Game Development Resource Management)

include articles:
#include "Resource.hpp"#include "ResLoader.hpp"#include "ResMgr.hpp"Definition: CORE RESOURCE MANAGER:

classCoreResMgr{staticds::dlist<res::Manager*>managers;staticshortinstances;public:template<classAsset>staticResMgr<Asset>*CreateResMgr(res::ResLoader<Asset>*loader){staticResMgr<Asset>*manager=nullptr;if(manager==nullptr){manager=newResMgr<Asset>(loader);managers.push_back(manager);}returnmanager;}template<classAsset>staticvoidDestoryResMgr(ResMgr<Asset>*mgr){for(ds::dlist<res::Manager*>::iteratori=managers.begin();i!=nullptr;i++){if(mgr==i.element()){i->Destroy();managers.erase(i);break;}}}template<classAsset>staticResMgr<Asset>*GetResMgr

Resource Manager - (Game Resource Management)

Resource Manager - (Game Development Resource Management)


#include "ResLoader.cpp"


Definition: MANAGER:

classManager{public:virtualvoidDestroy()=0;virtual~Manager(){}public:ds::astringname;};
Manager member variables:
ds::astring name;
nameis the name of the  resource manager.

Definition: RESOURCE-MANAGER:
template<classAsset>classResourceManager:publicManager{typedefbool(*DeleteAssetFuncPtr)(Asset*asset);DeleteAssetFuncPtrDeleteAssetFunc;public:typedefds::dlist<ResourceLoader<Asset>*>ResourceLoaders;typedefstd::map<ds::astring,ResourceLoaders*>ResourceLoaderMap;typedefds::dlist<Resource<Asset>*>AssetList;typedefstd::map<ds::astring,AssetList*>AssetMap;public:voidAddLoader(ResourceLoader<Asset>*resource_loader);ResourceLoader<Asset>*GetLoader(ds::astringconst&file_ext);AssetList*GetResourceList(ds::astringconst&name);Asset*A