#ifndef ASSET_MANAGER_H
#define ASSET_MANAGER_H

#include <string>
#include <unordered_map>
#include <vector>
#include <map>
#include <GL/glew.h>
#include <glm/glm.hpp>
class SubMesh;

// Structure holding raw model data (geometry and material information) without OpenGL buffers.
struct ModelAsset {
    std::vector<SubMesh> meshes;
    std::string modelPath;
};

class AssetManager {
public:
    // Get the singleton instance.
    static AssetManager& Get();

    // Loads a model from file and caches the raw geometry and material data.
    // Returns true if successful, populating outAsset.
    bool LoadModel(const std::string &filepath, ModelAsset &outAsset);

    // Loads a texture from file and caches it.
    // textureID will be set to the loaded texture's OpenGL ID.
    bool LoadTexture(const std::string &filepath, GLuint &textureID);

    // Clears caches. (Optionally delete textures via glDeleteTextures if needed.)
    void Clear();

private:
    // Private constructor for singleton.
    AssetManager() {}

    // Disable copy constructor and assignment operator.
    AssetManager(const AssetManager&) = delete;
    AssetManager& operator=(const AssetManager&) = delete;

    // Caches.
    std::unordered_map<std::string, ModelAsset> modelCache;
    std::unordered_map<std::string, GLuint> textureCache;
};

#endif // ASSET_MANAGER_H