Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

91 rinda
2.3 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2019 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. namespace lol
  28. {
  29. class TextureImageData;
  30. class TileSetData;
  31. class TileSet : public TextureImage
  32. {
  33. typedef TextureImage super;
  34. public:
  35. static TileSet *create(std::string const &path);
  36. static TileSet *create(std::string const &path, image* img);
  37. static TileSet *create(std::string const &path, image* img, array<ivec2, ivec2>& tiles);
  38. /* Old style: path to PNG file */
  39. static TileSet *create(std::string const &path, ivec2 size, ivec2 count);
  40. static TileSet *create(std::string const &path, image* img, ivec2 size, ivec2 count);
  41. static void destroy(TileSet *);
  42. virtual ~TileSet();
  43. private:
  44. TileSet(std::string const &path);
  45. TileSet(std::string const &path, image *img);
  46. protected:
  47. virtual void Init(std::string const &path, ResourceCodecData* loaded_data);
  48. virtual void Init(std::string const &path, image* img);
  49. public:
  50. /* Inherited from entity */
  51. virtual std::string GetName() const;
  52. /* New methods */
  53. void clear_all();
  54. int define_tile(ibox2 rect);
  55. void define_tile(ivec2 count);
  56. void define_tile(array<ibox2>& tiles);
  57. void define_tile(array<ivec2, ivec2>& 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 */