#include "rendering/FileTexture.h" #include "images/PNGReader.h" #include "memory/StackAllocator.h" FileTexture::FileTexture(const char* path) { PNGReader png(path); if(png.hasError()) { return; } StackAllocator::Array buffer(png.getBufferSize()); if(buffer.getLength() == png.getBufferSize() && !png.readData(buffer)) { texture.setFormat(TextureFormat::color8(png.getChannels())); texture.setData(png.getWidth(), png.getHeight(), buffer); } } void FileTexture::bindTo(int index) const { texture.bindTo(index); }