FileTexture.h 546 B

12345678910111213141516171819202122232425262728
  1. #ifndef FILE_TEXTURE_H
  2. #define FILE_TEXTURE_H
  3. #include "rendering/wrapper/Texture.h"
  4. #include "gaming-core/images/PNGReader.h"
  5. class FileTexture final {
  6. Texture texture;
  7. public:
  8. FileTexture(const char* path);
  9. void bind() const;
  10. private:
  11. template<int N>
  12. void read(PNGReader& png) {
  13. Color<N>* buffer = new Color<N>[png.getBufferSize()];
  14. if(png.readData(buffer)) {
  15. return;
  16. }
  17. texture.setColorData(png.getWidth(), png.getHeight(), buffer);
  18. delete[] buffer;
  19. }
  20. };
  21. #endif