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

68 行
1.4 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. //
  11. // The TileSet class
  12. // -----------------
  13. // A TileSet is a collection of tiles stored in a texture. Texture uploading
  14. // and freeing is done in the render tick method. When the refcount drops to
  15. // zero, the texture is freed.
  16. //
  17. #if !defined __LOL_TILESET_H__
  18. #define __LOL_TILESET_H__
  19. #include <stdint.h>
  20. #include "entity.h"
  21. namespace lol
  22. {
  23. class TileSetData;
  24. class TileSet : public Entity
  25. {
  26. public:
  27. TileSet(char const *path);
  28. virtual ~TileSet();
  29. /* Old style: path to PNG file */
  30. TileSet(char const *path, ivec2 size, ivec2 count);
  31. protected:
  32. /* Inherited from Entity */
  33. virtual char const *GetName();
  34. virtual void TickDraw(float seconds);
  35. public:
  36. /* New methods */
  37. int AddTile(ibox2 rect);
  38. int GetTileCount() const;
  39. ivec2 GetTileSize(int tileid) const;
  40. ivec2 GetTextureSize() const;
  41. ShaderTexture GetTexture() const;
  42. void Bind();
  43. void Unbind();
  44. void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale,
  45. float *vertex, float *texture);
  46. private:
  47. void Init(char const *path);
  48. TileSetData *m_data;
  49. };
  50. } /* namespace lol */
  51. #endif // __LOL_TILESET_H__