Shader* ResourceManager::OpenShader(UString filePath, ShaderType type) { UString assetPath = PathManager::ShaderPath(); assetPath += filePath; assetPath = os_path(assetPath); Shader* _shader = NULL; File* file = FileManager::OpenFile(assetPath, FileMode::ReadBinary); if (file) { //Create Renderer Specific texture type ResourceManager& _RM = ResourceManager::instance(); if (_RM.m_resourceLoader) { _shader = (Shader*)ResourceManager::AccessAsset(file->FileName()); if (!_shader) { _shader = _RM.m_resourceLoader->LoadShader(file, type); ResourceManager::MapAsset(file->FileName(), _shader); } FileManager::CloseFile(assetPath); } } return _shader; }
Material* ResourceManager::OpenMaterial(UString filePath) { UString assetPath = PathManager::MaterialPath(); assetPath += filePath; assetPath = os_path(assetPath); Material* _material = NULL; File* file = FileManager::OpenFile(assetPath, FileMode::ReadBinary); if (file) { //Create Renderer Specific model type ResourceManager& _RM = ResourceManager::instance(); if (_RM.m_resourceLoader) { _material = (Material*)ResourceManager::AccessAsset(file->FileName()); if (!_material) { //Need to load a material object into memory _material = _RM.m_resourceLoader->LoadMaterial(file); ResourceManager::MapAsset(file->FileName(), _material); } FileManager::CloseFile(file); } } return _material; }
Texture* ResourceManager::OpenTexture(UString filePath) { UString assetPath = PathManager::AssetPath() + VTEXT("Textures/"); assetPath += filePath; assetPath = os_path(assetPath); Texture* _texture = NULL; File* file = FileManager::OpenFile(assetPath, FileMode::ReadBinary); if (file) { //Create Renderer Specific texture type ResourceManager& _RM = ResourceManager::instance(); if (_RM.m_resourceLoader) { _texture = (Texture*)ResourceManager::AccessAsset(file->FileName()); if (!_texture) { _texture = _RM.m_resourceLoader->LoadTexture(file); ResourceManager::MapAsset(file->FileName(), (Asset*)_texture); } FileManager::CloseFile(file); } } return _texture; }
Font* ResourceManager::OpenFont(UString filePath) { UString assetPath = PathManager::AssetPath() + VTEXT("Fonts/"); assetPath += filePath; assetPath = os_path(assetPath); Font* _font = NULL; File* file = FileManager::OpenFile(assetPath, FileMode::ReadBinary); if (file) { //Create Renderer Specific model type ResourceManager& _RM = ResourceManager::instance(); if (_RM.m_resourceLoader) { _font = (Font*)ResourceManager::AccessAsset(file->FileName()); if (!_font) { //Need to load a font object into memory _font = _RM.m_resourceLoader->LoadFont(file); ResourceManager::MapAsset(file->FileName(), _font); } FileManager::CloseFile(file); } } return _font; }