123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef TEXTURE_H
- #define TEXTURE_H
- #include <GL/glew.h>
- #include "utils/Color.h"
- class Texture final {
- GLuint texture;
- public:
- enum Mode {
- NEAREST, LINEAR
- };
- Texture(Mode mode = NEAREST);
- ~Texture();
- Texture(const Texture& other) = delete;
- Texture(Texture&& other) = delete;
- Texture& operator=(const Texture& other) = delete;
- Texture& operator=(Texture&& other) = delete;
- void setColorData(int width, int height, const Color4* data);
- void setColorData(int width, int height, const Color3* data);
- void setColorData(int width, int height, const Color2* data);
- void setColorData(int width, int height, const Color1* data);
- void setRGBFloatData(int width, int height, const float* data);
- void bind(int index = 0) const;
- private:
- template<int N>
- void setColorData(int width, int height, int mode, const Color<N>* data) {
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, mode, width, height, 0, mode, GL_UNSIGNED_BYTE, data);
- }
- };
- #endif
|