#pragma once

#include <frostbite2D/graphics/shader.h>
#include <frostbite2D/types/type_alias.h>
#include <string>
#include <unordered_map>

namespace frostbite2D {

class Renderer;

class ShaderManager {
public:
  static ShaderManager& get();
  
  bool init(const std::string& shadersDir);
  void shutdown();
  
  Shader* getShader(const std::string& name);
  bool hasShader(const std::string& name) const;
  const std::unordered_map<std::string, Ptr<Shader>>& getLoadedShaders() const {
    return shaders_;
  }

  ~ShaderManager() = default;

  ShaderManager() = default;

private:
  
  std::unordered_map<std::string, Ptr<Shader>> shaders_;
  std::string shadersDir_;
  
  bool loadShadersFromConfig(const std::string& configPath);
  bool loadShader(const std::string& name, const std::string& vertPath, 
                  const std::string& fragPath);
  
  ShaderManager(const ShaderManager&) = delete;
  ShaderManager& operator=(const ShaderManager&) = delete;
};

}
