Texture.h 923 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef TEXTURE_H
  2. #define TEXTURE_H
  3. #include <GL/glew.h>
  4. #include "gaming-core/utils/Color.h"
  5. class Texture final {
  6. GLuint texture;
  7. public:
  8. Texture();
  9. ~Texture();
  10. Texture(const Texture& other) = delete;
  11. Texture(Texture&& other) = delete;
  12. Texture& operator=(const Texture& other) = delete;
  13. Texture& operator=(Texture&& other) = delete;
  14. void setColorData(int width, int height, const Color4* data);
  15. void setColorData(int width, int height, const Color3* data);
  16. void setColorData(int width, int height, const Color2* data);
  17. void setColorData(int width, int height, const Color1* data);
  18. void bind() const;
  19. private:
  20. template<int N>
  21. void setColorData(int width, int height, int mode, const Color<N>* data) {
  22. glBindTexture(GL_TEXTURE_2D, texture);
  23. glTexImage2D(GL_TEXTURE_2D, 0, mode, width, height, 0, mode, GL_UNSIGNED_BYTE, data);
  24. }
  25. };
  26. #endif