FileTexture.cpp 532 B

123456789101112131415161718192021
  1. #include "rendering/FileTexture.h"
  2. #include "images/PNGReader.h"
  3. Error FileTexture::load(const char* path, int maxMipMaps) {
  4. PNGReader png;
  5. Error error = png.load(path);
  6. if(error.has()) {
  7. return error;
  8. }
  9. texture.init(TextureFormat::color8(png.getChannels()), maxMipMaps);
  10. texture.setData(png.getWidth(), png.getHeight(), png.getData());
  11. return {};
  12. }
  13. void FileTexture::bindTo(int index) const {
  14. texture.bindTo(index);
  15. }
  16. void FileTexture::setLinearFilter() {
  17. texture.setLinearFilter();
  18. }