#include "rendering/FileTexture.h"
#include "images/PNGReader.h"

Error FileTexture::load(const char* path, int maxMipMaps) {
    PNGReader png;
    Error error = png.load(path);
    if(error.has()) {
        return error;
    }
    texture.init(TextureFormat::color8(png.getChannels()), maxMipMaps);
    texture.setData(png.getWidth(), png.getHeight(), png.getData());
    return {};
}

void FileTexture::bindTo(int index) const {
    texture.bindTo(index);
}

void FileTexture::setLinearFilter() {
    texture.setLinearFilter();
}