FileTexture.cpp 656 B

12345678910111213141516171819202122232425
  1. #include "rendering/FileTexture.h"
  2. #include "images/PNGReader.h"
  3. #include "utils/List.h"
  4. FileTexture::FileTexture(const char* path, int maxMipMaps)
  5. : texture(maxMipMaps) {
  6. PNGReader png(path);
  7. if(png.hasError()) {
  8. return;
  9. }
  10. List<ColorChannel> buffer;
  11. buffer.resize(png.getBufferSize());
  12. if(!png.readData(buffer.begin())) {
  13. texture.setFormat(TextureFormat::color8(png.getChannels()));
  14. texture.setData(png.getWidth(), png.getHeight(), buffer.begin());
  15. }
  16. }
  17. void FileTexture::bindTo(int index) const {
  18. texture.bindTo(index);
  19. }
  20. void FileTexture::setLinearFilter() {
  21. texture.setLinearFilter();
  22. }