#ifndef RESOURCE_MANAGER_CLASS #define RESOURCE_MANAGER_CLASS #include #include #include #include class Texture; class Font; class MeshData; // Owns every texture and font, so each file only loads once however many things use it. // Sounds are cached by SoundSystem, rigs and animations by CharacterManager. class ResourceManager { public: ResourceManager() {} ~ResourceManager(); // needs the GL context, delete this before the window ResourceManager(const ResourceManager&) = delete; // Returns nullptr and logs it if the file can't be loaded Texture* GetTexture(const std::string& path); Font* GetFont(const std::string& path); // Every mesh in a model file merged into one, in the file's own units. nullptr if it can't be read. const MeshData* GetMeshData(const std::string& path); // Just the meshes on the object called name in a model file, around that object's own origin rather than // where the file placed it. For pieces meant to be attached to something, like a weapon on a hand. const MeshData* GetMeshData(const std::string& path, const std::string& name); // The base color texture of the first material in a model file that has one, embedded in it or in a file // beside it. nullptr if it has none. Texture* GetModelTexture(const std::string& path); // Where the object called name sits in a model file, like an empty marking a gun's muzzle, in the same space // GetMeshData(path) puts the model in. False if the file has nothing called that. bool GetModelMarker(const std::string& path, const std::string& name, glm::mat4& transform); // Not cached, every call makes a new texture that's free to be edited Texture* CreateTexture(int width, int height); Texture* CopyTexture(const Texture& source); private: std::unordered_map textures; std::unordered_map fonts; std::unordered_map meshes; std::unordered_map> markers; // found or not, and where std::vector createdTextures; }; #endif