#ifndef GLIMAGE_H
#define GLIMAGE_H

#include <string>
#include <memory>
#include "GLTexture/GLTexture.h"

class GLImage {
public:
    GLImage();
    ~GLImage(){};
    GLImage(const std::string& src, const int width, const int height);
    void setSrc(const std::string& src, const int width, const int height, std::vector<unsigned char> data);
    void setSize(const int width, const int height);
    void setPixels(std::vector<unsigned char> data);
    std::shared_ptr<GLTexture> getTexture();
    void reloadImage();
    bool isPathByFilesystem(const std::string& str);
    bool isUrl(const std::string& str);
    void verticalFlip(unsigned char* data, int width, int height, int channels);
    void verticalFlip(std::vector<unsigned char>& data, int width, int height, int channels);

private:
    int width = 0;
    int height = 0;
    std::string src;
    std::shared_ptr<GLTexture> texture;
    std::vector<unsigned char> pixels;
    void onLoad(const std::string& src);
};

class ImageData {
public:
    int width = 0;
    int height = 0;
    std::string path;
    std::vector<unsigned char> data;
    
    ImageData();
    ~ImageData(){};
    ImageData(const int width, const int height, const std::string& path, const std::vector<unsigned char> data)
        :width(width), height(height), data(data), path(path) {}
};

#endif