FileTexture.cpp 513 B

12345678910111213141516171819202122
  1. #include <iostream>
  2. #include "rendering/FileTexture.h"
  3. #include "utils/PNGReader.h"
  4. FileTexture::FileTexture(const char* path) {
  5. PNGReader reader(path);
  6. if(reader.hasError()) {
  7. return;
  8. }
  9. char* buffer = new char[reader.getBufferSize()];
  10. if(reader.readData(buffer)) {
  11. delete[] buffer;
  12. return;
  13. }
  14. texture.setColors(reader.getWidth(), reader.getHeight(), buffer, reader.getChannels());
  15. delete[] buffer;
  16. }
  17. void FileTexture::bind() const {
  18. texture.bind();
  19. }