ITexture.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #pragma once
  2. #include <GL/glew.h>
  3. #include <glm/vec4.hpp>
  4. #include <vector>
  5. namespace WallpaperEngine::Assets
  6. {
  7. /**
  8. * Base interface that describes the minimum information required for a texture
  9. * to be displayed by the engine
  10. */
  11. class ITexture
  12. {
  13. public:
  14. /**
  15. * Texture frame information for animated textures
  16. */
  17. class TextureFrame
  18. {
  19. public:
  20. TextureFrame();
  21. ~TextureFrame();
  22. /** The image index of this frame */
  23. uint32_t frameNumber;
  24. /** The amount of time this frame spends being displayed */
  25. float frametime;
  26. /** The x position of the frame in the texture */
  27. float x;
  28. /** The y position of the frame in the texture */
  29. float y;
  30. /** The width of the frame in the texture */
  31. float width1;
  32. float width2;
  33. float height2;
  34. /** The height of the frame in the texture */
  35. float height1;
  36. };
  37. /**
  38. * Data formats for textures in memory
  39. */
  40. enum TextureFormat : uint32_t
  41. {
  42. UNKNOWN = 0xFFFFFFFF,
  43. ARGB8888 = 0,
  44. RGB888 = 1,
  45. RGB565 = 2,
  46. DXT5 = 4,
  47. DXT3 = 6,
  48. DXT1 = 7,
  49. RG88 = 8,
  50. R8 = 9,
  51. RG1616f = 10,
  52. R16f = 11,
  53. BC7 = 12,
  54. RGBa1010102 = 13,
  55. RGBA16161616f = 14,
  56. RGB161616f = 15,
  57. };
  58. /**
  59. * Different settings of the textures
  60. */
  61. enum TextureFlags : uint32_t
  62. {
  63. NoFlags = 0,
  64. NoInterpolation = 1,
  65. ClampUVs = 2,
  66. IsGif = 4,
  67. ClampUVsBorder = 8,
  68. };
  69. /**
  70. * @param imageIndex For animated textures, the frame to get the ID of
  71. * @return The OpenGL texture to use when rendering
  72. */
  73. [[nodiscard]] virtual const GLuint getTextureID (uint32_t imageIndex = 0) const = 0;
  74. /**
  75. * @param imageIndex For animated textures, the frame to get the ID of
  76. * @return The texture's width
  77. */
  78. [[nodiscard]] virtual const uint32_t getTextureWidth (uint32_t imageIndex = 0) const = 0;
  79. /**
  80. * @param imageIndex For animated textures, the frame to get the ID of
  81. * @return The texture's height
  82. */
  83. [[nodiscard]] virtual const uint32_t getTextureHeight (uint32_t imageIndex = 0) const = 0;
  84. /**
  85. * @return The textures real width
  86. */
  87. [[nodiscard]] virtual const uint32_t getRealWidth () const = 0;
  88. /**
  89. * @return The textures real height
  90. */
  91. [[nodiscard]] virtual const uint32_t getRealHeight () const = 0;
  92. /**
  93. * @return The texture's memory format
  94. */
  95. [[nodiscard]] virtual const TextureFormat getFormat () const = 0;
  96. /**
  97. * @return The texture's settings
  98. */
  99. [[nodiscard]] virtual const TextureFlags getFlags () const = 0;
  100. /**
  101. * @return The list of frames this texture has
  102. */
  103. [[nodiscard]] virtual const std::vector<TextureFrame*>& getFrames () const = 0;
  104. /**
  105. * @return The texture's resolution vector
  106. */
  107. [[nodiscard]] virtual const glm::vec4* getResolution () const = 0;
  108. /**
  109. * @return If the texture is animated or not
  110. */
  111. [[nodiscard]] virtual const bool isAnimated () const = 0;
  112. };
  113. }