#pragma once

#include <frostbite2D/graphics/types.h>
#include <frostbite2D/types/type_alias.h>
#include <frostbite2D/base/RefObject.h>
#include <string>
#include <memory>

namespace frostbite2D {

class Texture : public RefObject {
public:
  static Ptr<Texture> loadFromFile(const std::string& path);
  static Ptr<Texture> createFromMemory(const uint8* data, int width, int height, int channels);
  static Ptr<Texture> createEmpty(int width, int height);
  
  ~Texture();
  
  void bind(uint32_t slot = 0);
  void unbind();
  
  void setWrapMode(uint32_t wrapS, uint32_t wrapT);
  void setFilterMode(uint32_t minFilter, uint32_t magFilter);
  
  int getWidth() const { return width_; }
  int getHeight() const { return height_; }
  uint32_t getID() const { return textureID_; }
  const std::string& getPath() const { return path_; }
  
private:
  Texture(int width, int height, uint32_t id);
  
  uint32_t textureID_ = 0;
  int width_ = 0;
  int height_ = 0;
  int channels_ = 0;
  std::string path_;
  
  Texture() = default;
  Texture(const Texture&) = delete;
  Texture& operator=(const Texture&) = delete;
};

}