#include "rendering/FileTexture.h" #include "images/ImageReader.h" Error FileTexture::load(const char* path, int maxMipMaps) { ImageReader::Image image; Error error = ImageReader::load(image, path); if(error.has()) { return error; } if(image.channels < 1 || image.channels > 4) { Error error = {"'"}; error.message.append(path) .append("' has unsupported number of channels: ") .append(image.channels); return error; } else if(image.bitdepth != 8) { Error error = {"bit depth of '"}; error.message.append(path).append("' is not 8"); return error; } texture.init(TextureFormat::color8(image.channels), maxMipMaps); texture.setData(image.width, image.height, image.data); return {}; } void FileTexture::bindTo(int index) const { texture.bindTo(index); } void FileTexture::setLinearFilter() { texture.setLinearFilter(); }