Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

10 роки тому
7 роки тому
7 роки тому
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2020 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. /*
  21. #include <lol/image/image.h>
  22. #include <lol/gpu/texture.h>
  23. #include <stdint.h>
  24. #include "engine/entity.h"
  25. */
  26. #include "textureimage.h"
  27. #include <vector> // std::vector
  28. namespace lol
  29. {
  30. class TextureImageData;
  31. class TileSetData;
  32. class TileSet : public TextureImage
  33. {
  34. typedef TextureImage super;
  35. public:
  36. static TileSet *create(std::string const &path);
  37. static TileSet *create(std::string const &path, image* img);
  38. static TileSet *create(std::string const &path, image* img, std::vector<ibox2>& tiles);
  39. /* Old style: path to PNG file */
  40. static TileSet *create(std::string const &path, ivec2 size, ivec2 count);
  41. static TileSet *create(std::string const &path, image* img, ivec2 size, ivec2 count);
  42. static void destroy(TileSet *);
  43. virtual ~TileSet();
  44. private:
  45. TileSet(std::string const &path);
  46. TileSet(std::string const &path, image *img);
  47. protected:
  48. virtual void Init(std::string const &path, ResourceCodecData* loaded_data);
  49. virtual void Init(std::string const &path, image* img);
  50. public:
  51. /* Inherited from entity */
  52. virtual std::string GetName() const;
  53. /* New methods */
  54. void clear_all();
  55. int define_tile(ibox2 rect);
  56. void define_tile(ivec2 count);
  57. void define_tiles_by_box(std::vector<ibox2>& tiles);
  58. int GetTileCount() const;
  59. ivec2 GetTileSize(int tileid) const;
  60. ibox2 GetTilePixel(int tileid) const;
  61. box2 GetTileTexel(int tileid) const;
  62. void SetPalette(TileSet* palette);
  63. TileSet* GetPalette();
  64. TileSet const * GetPalette() const;
  65. void BlitTile(uint32_t id, mat4 model, vec3 *vertex, vec2 *texture);
  66. protected:
  67. TileSetData *m_tileset_data;
  68. TileSet *m_palette;
  69. };
  70. } /* namespace lol */