選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

79 行
1.9 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #pragma once
  11. //
  12. // The TileSet class
  13. // -----------------
  14. // A TileSet is a collection of tiles stored in a texture. Texture uploading
  15. // and freeing is done in the render tick method. When the refcount drops to
  16. // zero, the texture is freed.
  17. //
  18. #include <lol/image/image.h>
  19. #include <lol/gpu/texture.h>
  20. #include <stdint.h>
  21. #include "entity.h"
  22. namespace lol
  23. {
  24. class TileSetData;
  25. class TileSet : public Entity
  26. {
  27. public:
  28. TileSet(char const *path);
  29. TileSet(char const *path, Image* image);
  30. virtual ~TileSet();
  31. /* Old style: path to PNG file */
  32. TileSet(char const *path, ivec2 size, ivec2 count);
  33. TileSet(char const *path, Image* image, ivec2 size, ivec2 count);
  34. /* Inherited from Entity */
  35. virtual char const *GetName();
  36. protected:
  37. virtual void TickDraw(float seconds, Scene &scene);
  38. public:
  39. /* New methods */
  40. ptrdiff_t AddTile(ibox2 rect);
  41. void AddTile(ivec2 count);
  42. ptrdiff_t GetTileCount() const;
  43. ivec2 GetTileSize(ptrdiff_t tileid) const;
  44. Texture * GetTexture();
  45. Texture const * GetTexture() const;
  46. Image * GetImage();
  47. Image const * GetImage() const;
  48. void SetPalette(TileSet* palette);
  49. TileSet* GetPalette();
  50. TileSet const * GetPalette() const;
  51. ivec2 GetTextureSize() const;
  52. void Bind();
  53. void Unbind();
  54. void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float angle,
  55. vec3 *vertex, vec2 *texture);
  56. private:
  57. void Init(char const *path);
  58. void Init(char const *path, Image* image);
  59. TileSetData* m_data;
  60. TileSet* m_palette;
  61. };
  62. } /* namespace lol */