123456789101112131415161718192021 |
- #include "rendering/FileTexture.h"
- #include "images/PNGReader.h"
- #include "utils/List.h"
- FileTexture::FileTexture(const char* path, int maxMipMaps, bool linear)
- : texture(maxMipMaps) {
- PNGReader png(path);
- if(png.hasError()) {
- return;
- }
- List<ColorChannel> buffer;
- buffer.resize(png.getBufferSize());
- if(!png.readData(buffer.begin())) {
- texture.setFormat(TextureFormat::color8(png.getChannels(), linear));
- texture.setData(png.getWidth(), png.getHeight(), buffer.begin());
- }
- }
- void FileTexture::bindTo(int index) const {
- texture.bindTo(index);
- }
|