TextureProvider.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include <memory>
  3. #include <vector>
  4. #include <GL/glew.h>
  5. #include <glm/vec4.hpp>
  6. #include "WallpaperEngine/Data/Assets/Texture.h"
  7. #include "WallpaperEngine/Data/Model/Types.h"
  8. namespace WallpaperEngine::Render {
  9. using namespace WallpaperEngine::Data::Assets;
  10. /**
  11. * Base interface that describes the minimum information required for a texture
  12. * to be displayed by the engine
  13. */
  14. class TextureProvider {
  15. public:
  16. virtual ~TextureProvider () = default;
  17. /**
  18. * @param imageIndex For animated textures, the frame to get the ID of
  19. * @return The OpenGL texture to use when rendering
  20. */
  21. [[nodiscard]] virtual GLuint getTextureID (uint32_t imageIndex) const = 0;
  22. /**
  23. * @param imageIndex For animated textures, the frame to get the ID of
  24. * @return The texture's width
  25. */
  26. [[nodiscard]] virtual uint32_t getTextureWidth (uint32_t imageIndex) const = 0;
  27. /**
  28. * @param imageIndex For animated textures, the frame to get the ID of
  29. * @return The texture's height
  30. */
  31. [[nodiscard]] virtual uint32_t getTextureHeight (uint32_t imageIndex) const = 0;
  32. /**
  33. * @return The textures real width
  34. */
  35. [[nodiscard]] virtual uint32_t getRealWidth () const = 0;
  36. /**
  37. * @return The textures real height
  38. */
  39. [[nodiscard]] virtual uint32_t getRealHeight () const = 0;
  40. /**
  41. * @return The texture's memory format
  42. */
  43. [[nodiscard]] virtual TextureFormat getFormat () const = 0;
  44. /**
  45. * @return The texture's settings
  46. */
  47. [[nodiscard]] virtual uint32_t getFlags () const = 0;
  48. /**
  49. * @return The list of frames this texture has
  50. */
  51. [[nodiscard]] virtual const std::vector<FrameSharedPtr>& getFrames () const = 0;
  52. /**
  53. * @return The texture's resolution vector
  54. */
  55. [[nodiscard]] virtual const glm::vec4* getResolution () const = 0;
  56. /**
  57. * @return If the texture is animated or not
  58. */
  59. [[nodiscard]] virtual bool isAnimated () const = 0;
  60. /**
  61. * @return Number of columns in spritesheet grid (0 if not a spritesheet)
  62. */
  63. [[nodiscard]] virtual uint32_t getSpritesheetCols () const = 0;
  64. /**
  65. * @return Number of rows in spritesheet grid (0 if not a spritesheet)
  66. */
  67. [[nodiscard]] virtual uint32_t getSpritesheetRows () const = 0;
  68. /**
  69. * @return Total number of frames in spritesheet (0 if not a spritesheet)
  70. */
  71. [[nodiscard]] virtual uint32_t getSpritesheetFrames () const = 0;
  72. /**
  73. * @return Duration of spritesheet animation in seconds
  74. */
  75. [[nodiscard]] virtual float getSpritesheetDuration () const = 0;
  76. /**
  77. * Increments the usage count of the texture
  78. *
  79. * Directly controls playback for video CTextures, only started when at least one thing is using it
  80. * Initializes mpv if needed and starts playback
  81. */
  82. virtual void incrementUsageCount () const = 0;
  83. /**
  84. * Decrements the usage count of the texture
  85. *
  86. * Directly controls playback for video CTextures, only stopped when nothing is using it
  87. * De-initializes mpv if needed
  88. */
  89. virtual void decrementUsageCount () const = 0;
  90. /**
  91. * Allows the texture contents to be updated (for example, for video textures)
  92. */
  93. virtual void update () const = 0;
  94. };
  95. } // namespace WallpaperEngine::Render