No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

78 líneas
1.7 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2015 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. TileSet(char const *path);
  36. TileSet(char const *path, Image* image);
  37. /* Old style: path to PNG file */
  38. TileSet(char const *path, ivec2 size, ivec2 count);
  39. TileSet(char const *path, Image* image, ivec2 size, ivec2 count);
  40. virtual ~TileSet();
  41. protected:
  42. virtual void Init(char const *path, Image* image);
  43. public:
  44. /* Inherited from Entity */
  45. virtual char const *GetName();
  46. /* New methods */
  47. int define_tile(ibox2 rect);
  48. void define_tile(ivec2 count);
  49. int GetTileCount() const;
  50. ivec2 GetTileSize(int tileid) const;
  51. void SetPalette(TileSet* palette);
  52. TileSet* GetPalette();
  53. TileSet const * GetPalette() const;
  54. void BlitTile(uint32_t id, mat4 model, vec3 *vertex, vec2 *texture);
  55. protected:
  56. TileSetData *m_tileset_data;
  57. TileSet *m_palette;
  58. };
  59. } /* namespace lol */