#pragma once #include "StringView.hpp" #include "Vec2.hpp" #include "Color.hpp" #include "Clock.hpp" #include #include extern "C" { #include } namespace dchat { class GifLoadException : public std::runtime_error { public: GifLoadException(const std::string &errMsg) : std::runtime_error(errMsg) {} }; // Gif is in image format ARGB (32-bits in total) class Gif { public: // Throws GifLoadException on error Gif(const boost::filesystem::path &filepath); Gif(StringView fileContent); virtual ~Gif(); Vec2u getSize() const; // Throws GifLoadException on error void update(); static bool isDataGif(const StringView &data); protected: // Return false if texture creation failed virtual bool createTexture() = 0; // Size of texture data is same as the size that the texture was created with (also same size returned by @getSize function) virtual void updateTexture(void *textureData) = 0; private: void init(); private: gif_animation gif; StringView fileContent; unsigned int currentFrame; double timeElapsedCs; Clock frameTimer; bool created; }; }