12345678910111213141516171819202122232425262728 |
- #ifndef FILETEXTURE_H
- #define FILETEXTURE_H
- #include "gl/Texture.h"
- #include "images/PNGReader.h"
- class FileTexture final {
- Texture texture;
- public:
- FileTexture(const char* path);
- void bind(int index = 0) const;
- private:
- template<int N>
- void read(PNGReader& png) {
- Color<N>* buffer = new Color<N>[png.getBufferSize()];
- if(png.readData(buffer)) {
- return;
- }
- texture.setColorData(png.getWidth(), png.getHeight(), buffer);
- delete[] buffer;
- }
- };
- #endif
|