AxiomGames / Axiom

Performance focused DX12/Vk Engine written in C++
Do What The F*ck You Want To Public License
3 stars 0 forks source link

Resource management #14

Open SamCZ opened 1 year ago

SamCZ commented 1 year ago

Create resource management system

benanil commented 1 year ago

We can also create Asset Manager and it will convert our path to project's path for example: and this manager can also hold paths and resources, for ensuring to use one asset instance (no copies)

AssetManager::GetTexture("Assets/BlaTexture.png");

HashMap<TextureHandle, String> textures;
HashMap<MeshHandle, String> meshes;
HashMap<MaterialHandle, String> materials;

TextureHandle AssetManager::GetTexture(const String& path)
{
    String projectPath = ProjectPath / path;
    // texture already imported
    if (Textures.HasKey(projectPath))
         return Textures[projectPath];
    TextureHandle texture = ResourceManager::LoadTexture(ProjectPath / path);    
    Textures.Add(texture);
    return  texture;
}