O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Resource management

Another vital part of larger projects is an efficient way of managing resources. Since we're going to have several types of resources, such as textures, fonts, and sounds, it would make sense to have separate managers for all of them. It's time for a base class:

template<typename Derived, typename T> class ResourceManager{ public: ResourceManager(const std::string& l_pathsFile){ LoadPaths(l_pathsFile); } virtual ~ResourceManager(){ ... } T* GetResource(const std::string& l_id){ ... } std::string GetPath(const std::string& l_id){ ... } bool RequireResource(const std::string& l_id){ ... } bool ReleaseResource(const std::string& l_id){ ... } void PurgeResources(){ ... } protected: bool Load(T* l_resource, const std::string& l_path) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required