texture.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_SUPERTUX_VIDEO_TEXTURE_HPP
  17. #define HEADER_SUPERTUX_VIDEO_TEXTURE_HPP
  18. #include <string>
  19. #include <tuple>
  20. #include <optional>
  21. #include "math/rect.hpp"
  22. #include "video/flip.hpp"
  23. /** This class is a wrapper around a texture handle. It stores the
  24. texture width and height and provides convenience functions for
  25. uploading SDL_Surfaces into the texture. */
  26. class Texture
  27. {
  28. friend class TextureManager;
  29. public:
  30. /** filename, left, top, right, bottom */
  31. using Key = std::tuple<std::string, Rect>;
  32. protected:
  33. Texture();
  34. public:
  35. virtual ~Texture();
  36. virtual int get_texture_width() const = 0;
  37. virtual int get_texture_height() const = 0;
  38. virtual int get_image_width() const = 0;
  39. virtual int get_image_height() const = 0;
  40. private:
  41. std::optional<Key> m_cache_key;
  42. private:
  43. Texture(const Texture&) = delete;
  44. Texture& operator=(const Texture&) = delete;
  45. };
  46. #endif
  47. /* EOF */