Texture.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef TEXTURE_H
  2. #define TEXTURE_H
  3. #include "rendering/GL.h"
  4. struct Texture final {
  5. struct Format final {
  6. GL::TextureFormat format;
  7. bool linear;
  8. bool depth;
  9. static Format color8(int channels, bool linear = false);
  10. static Format float16(int channels, bool linear = false);
  11. static Format float32(int channels, bool linear = false);
  12. static Format depth16(bool linear = false);
  13. static Format depth32(bool linear = false);
  14. static Format unknown();
  15. private:
  16. Format(const GL::TextureFormat& tf, bool linear, bool depth = false);
  17. };
  18. private:
  19. Format format;
  20. GL::Texture texture;
  21. int maxMipMaps;
  22. template<int N>
  23. friend class Framebuffer;
  24. public:
  25. Texture();
  26. ~Texture();
  27. Texture(const Texture& other) = delete;
  28. Texture(Texture&& other) = delete;
  29. Texture& operator=(const Texture& other) = delete;
  30. Texture& operator=(Texture&& other) = delete;
  31. void init(const Format& format, int maxMipMaps);
  32. void setNearestFilter();
  33. void setLinearFilter();
  34. void setRepeatWrap();
  35. void setClampWrap();
  36. void setData(int width, int height, const void* data = nullptr);
  37. void bindTo(int index = 0) const;
  38. Error load(const char* path, int maxMipMaps);
  39. private:
  40. void bind() const;
  41. };
  42. #endif