Atlas.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /******************************************************************************
  2. * Spine Runtimes Software License
  3. * Version 2
  4. *
  5. * Copyright (c) 2013, Esoteric Software
  6. * All rights reserved.
  7. *
  8. * You are granted a perpetual, non-exclusive, non-sublicensable and
  9. * non-transferable license to install, execute and perform the Spine Runtimes
  10. * Software (the "Software") solely for internal use. Without the written
  11. * permission of Esoteric Software, you may not (a) modify, translate, adapt or
  12. * otherwise create derivative works, improvements of the Software or develop
  13. * new applications using the Software or (b) remove, delete, alter or obscure
  14. * any trademarks or any copyright, trademark, patent or other intellectual
  15. * property or proprietary rights notices on or in the Software, including
  16. * any copy thereof. Redistributions in binary or source form must include
  17. * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE
  18. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  19. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *****************************************************************************/
  28. #ifndef SPINE_ATLAS_H_
  29. #define SPINE_ATLAS_H_
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. typedef enum {
  34. ATLAS_ALPHA, ATLAS_INTENSITY, ATLAS_LUMINANCE_ALPHA, ATLAS_RGB565, ATLAS_RGBA4444, ATLAS_RGB888, ATLAS_RGBA8888
  35. } spAtlasFormat;
  36. typedef enum {
  37. ATLAS_NEAREST,
  38. ATLAS_LINEAR,
  39. ATLAS_MIPMAP,
  40. ATLAS_MIPMAP_NEAREST_NEAREST,
  41. ATLAS_MIPMAP_LINEAR_NEAREST,
  42. ATLAS_MIPMAP_NEAREST_LINEAR,
  43. ATLAS_MIPMAP_LINEAR_LINEAR
  44. } spAtlasFilter;
  45. typedef enum {
  46. ATLAS_MIRROREDREPEAT, ATLAS_CLAMPTOEDGE, ATLAS_REPEAT
  47. } spAtlasWrap;
  48. typedef struct spAtlasPage spAtlasPage;
  49. struct spAtlasPage {
  50. const char* name;
  51. spAtlasFormat format;
  52. spAtlasFilter minFilter, magFilter;
  53. spAtlasWrap uWrap, vWrap;
  54. void* rendererObject;
  55. int width, height;
  56. spAtlasPage* next;
  57. };
  58. spAtlasPage* spAtlasPage_create (const char* name);
  59. void spAtlasPage_dispose (spAtlasPage* self);
  60. #ifdef SPINE_SHORT_NAMES
  61. typedef spAtlasFormat AtlasFormat;
  62. typedef spAtlasFilter AtlasFilter;
  63. typedef spAtlasWrap AtlasWrap;
  64. typedef spAtlasPage AtlasPage;
  65. #define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__)
  66. #define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__)
  67. #endif
  68. /**/
  69. typedef struct spAtlasRegion spAtlasRegion;
  70. struct spAtlasRegion {
  71. const char* name;
  72. int x, y, width, height;
  73. float u, v, u2, v2;
  74. int offsetX, offsetY;
  75. int originalWidth, originalHeight;
  76. int index;
  77. int/*bool*/rotate;
  78. int/*bool*/flip;
  79. int* splits;
  80. int* pads;
  81. spAtlasPage* page;
  82. spAtlasRegion* next;
  83. };
  84. spAtlasRegion* spAtlasRegion_create ();
  85. void spAtlasRegion_dispose (spAtlasRegion* self);
  86. #ifdef SPINE_SHORT_NAMES
  87. typedef spAtlasRegion AtlasRegion;
  88. #define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__)
  89. #define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__)
  90. #endif
  91. /**/
  92. typedef struct {
  93. spAtlasPage* pages;
  94. spAtlasRegion* regions;
  95. } spAtlas;
  96. /* Image files referenced in the atlas file will be prefixed with dir. */
  97. spAtlas* spAtlas_readAtlas (const char* data, int length, const char* dir);
  98. /* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */
  99. spAtlas* spAtlas_readAtlasFile (const char* path);
  100. void spAtlas_dispose (spAtlas* atlas);
  101. /* Returns 0 if the region was not found. */
  102. spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name);
  103. #ifdef SPINE_SHORT_NAMES
  104. typedef spAtlas Atlas;
  105. #define Atlas_readAtlas(...) spAtlas_readAtlas(__VA_ARGS__)
  106. #define Atlas_readAtlasFile(...) spAtlas_readAtlasFile(__VA_ARGS__)
  107. #define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__)
  108. #define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__)
  109. #endif
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* SPINE_ATLAS_H_ */