You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.7 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #pragma once
  13. //
  14. // The TileSet class
  15. // -----------------
  16. // A TileSet is a collection of tiles stored in a texture. Texture uploading
  17. // and freeing is done in the render tick method. When the refcount drops to
  18. // zero, the texture is freed.
  19. //
  20. #include <lol/image/resource.h>
  21. #include <lol/image/image.h>
  22. #include <lol/gpu/texture.h>
  23. #include <stdint.h>
  24. #include "engine/entity.h"
  25. namespace lol
  26. {
  27. class TextureImageData;
  28. class TextureImage : public Entity
  29. {
  30. typedef Entity super;
  31. protected:
  32. virtual TextureImageData* GetNewData();
  33. public:
  34. TextureImage(std::string const &path);
  35. TextureImage(std::string const &path, image* img);
  36. virtual ~TextureImage();
  37. protected:
  38. void Init(std::string const &path);
  39. virtual void Init(std::string const &path, ResourceCodecData* loaded_data);
  40. virtual void Init(std::string const &path, image* img);
  41. protected:
  42. virtual void tick_draw(float seconds, Scene &scene);
  43. public:
  44. /* Inherited from Entity */
  45. virtual std::string GetName() const;
  46. void UpdateTexture(image* img);
  47. Texture * GetTexture();
  48. Texture const * GetTexture() const;
  49. image * GetImage();
  50. image const * GetImage() const;
  51. ivec2 GetImageSize() const;
  52. ivec2 GetTextureSize() const;
  53. void Bind();
  54. void Unbind();
  55. protected:
  56. TextureImageData* m_data = nullptr;
  57. };
  58. } /* namespace lol */