Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

77 rader
1.7 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. /*
  19. #include <lol/image/image.h>
  20. #include <lol/gpu/texture.h>
  21. #include <stdint.h>
  22. #include "engine/entity.h"
  23. */
  24. #include "textureimage.h"
  25. namespace lol
  26. {
  27. class TextureImageData;
  28. class TileSetData;
  29. class TileSet : public TextureImage
  30. {
  31. typedef TextureImage super;
  32. public:
  33. TileSet(char const *path);
  34. TileSet(char const *path, Image* image);
  35. /* Old style: path to PNG file */
  36. TileSet(char const *path, ivec2 size, ivec2 count);
  37. TileSet(char const *path, Image* image, ivec2 size, ivec2 count);
  38. virtual ~TileSet();
  39. protected:
  40. virtual void Init(char const *path, Image* image);
  41. public:
  42. /* Inherited from Entity */
  43. virtual char const *GetName();
  44. /* New methods */
  45. int AddTile(ibox2 rect);
  46. void AddTile(ivec2 count);
  47. int GetTileCount() const;
  48. ivec2 GetTileSize(int tileid) const;
  49. void SetPalette(TileSet* palette);
  50. TileSet* GetPalette();
  51. TileSet const * GetPalette() const;
  52. void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float angle,
  53. vec3 *vertex, vec2 *texture);
  54. protected:
  55. TileSetData *m_tileset_data;
  56. TileSet *m_palette;
  57. };
  58. } /* namespace lol */