123456789101112131415161718192021222324252627282930 |
- #ifndef FILE_TEXTURE_H
- #define FILE_TEXTURE_H
- #include <iostream>
- #include "client/rendering/wrapper/Texture.h"
- #include "gaming-core/images/PNGReader.h"
- class FileTexture final {
- Texture texture;
- public:
- FileTexture(const char* path);
- void bind(int index) 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
|