SDL_gfxPrimitives.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. SDL_gfxPrimitives.h: graphics primitives for SDL
  3. Copyright (C) 2001-2012 Andreas Schiffler
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. Andreas Schiffler -- aschiffler at ferzkopp dot net
  19. */
  20. #ifndef _SDL_gfxPrimitives_h
  21. #define _SDL_gfxPrimitives_h
  22. #include <math.h>
  23. #ifndef M_PI
  24. #define M_PI 3.1415926535897932384626433832795
  25. #endif
  26. #include "SDL.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* ----- Versioning */
  32. #define SDL_GFXPRIMITIVES_MAJOR 2
  33. #define SDL_GFXPRIMITIVES_MINOR 0
  34. #define SDL_GFXPRIMITIVES_MICRO 25
  35. /* ---- Function Prototypes */
  36. #ifdef _MSC_VER
  37. # if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
  38. # define SDL_GFXPRIMITIVES_SCOPE __declspec(dllexport)
  39. # else
  40. # ifdef LIBSDL_GFX_DLL_IMPORT
  41. # define SDL_GFXPRIMITIVES_SCOPE __declspec(dllimport)
  42. # endif
  43. # endif
  44. #endif
  45. #ifndef SDL_GFXPRIMITIVES_SCOPE
  46. # define SDL_GFXPRIMITIVES_SCOPE extern
  47. #endif
  48. /* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */
  49. /* Pixel */
  50. SDL_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color);
  51. SDL_GFXPRIMITIVES_SCOPE int pixelRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  52. /* Horizontal line */
  53. SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color);
  54. SDL_GFXPRIMITIVES_SCOPE int
  55. hlineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  56. /* Vertical line */
  57. SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color);
  58. SDL_GFXPRIMITIVES_SCOPE int
  59. vlineRGBA(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  60. /* Rectangle */
  61. SDL_GFXPRIMITIVES_SCOPE int rectangleColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
  62. SDL_GFXPRIMITIVES_SCOPE int rectangleRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1,
  63. Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  64. /* Rounded-Corner Rectangle */
  65. SDL_GFXPRIMITIVES_SCOPE int
  66. roundedRectangleColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);
  67. SDL_GFXPRIMITIVES_SCOPE int roundedRectangleRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1,
  68. Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  69. /* Filled rectangle (Box) */
  70. SDL_GFXPRIMITIVES_SCOPE int boxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
  71. SDL_GFXPRIMITIVES_SCOPE int boxRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2,
  72. Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  73. /* Rounded-Corner Filled rectangle (Box) */
  74. SDL_GFXPRIMITIVES_SCOPE int
  75. roundedBoxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);
  76. SDL_GFXPRIMITIVES_SCOPE int roundedBoxRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2,
  77. Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  78. /* Line */
  79. SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
  80. SDL_GFXPRIMITIVES_SCOPE int lineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1,
  81. Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  82. /* AA Line */
  83. SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
  84. SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1,
  85. Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  86. /* Thick Line */
  87. SDL_GFXPRIMITIVES_SCOPE int thickLineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
  88. Uint8 width, Uint32 color);
  89. SDL_GFXPRIMITIVES_SCOPE int thickLineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
  90. Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  91. /* Circle */
  92. SDL_GFXPRIMITIVES_SCOPE int circleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
  93. SDL_GFXPRIMITIVES_SCOPE int
  94. circleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  95. /* Arc */
  96. SDL_GFXPRIMITIVES_SCOPE int
  97. arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);
  98. SDL_GFXPRIMITIVES_SCOPE int arcRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end,
  99. Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  100. /* AA Circle */
  101. SDL_GFXPRIMITIVES_SCOPE int aacircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
  102. SDL_GFXPRIMITIVES_SCOPE int aacircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y,
  103. Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  104. /* Filled Circle */
  105. SDL_GFXPRIMITIVES_SCOPE int filledCircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);
  106. SDL_GFXPRIMITIVES_SCOPE int filledCircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y,
  107. Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  108. /* Ellipse */
  109. SDL_GFXPRIMITIVES_SCOPE int ellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
  110. SDL_GFXPRIMITIVES_SCOPE int ellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y,
  111. Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  112. /* AA Ellipse */
  113. SDL_GFXPRIMITIVES_SCOPE int aaellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
  114. SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y,
  115. Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  116. /* Filled Ellipse */
  117. SDL_GFXPRIMITIVES_SCOPE int
  118. filledEllipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
  119. SDL_GFXPRIMITIVES_SCOPE int filledEllipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y,
  120. Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  121. /* Pie */
  122. SDL_GFXPRIMITIVES_SCOPE int pieColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad,
  123. Sint16 start, Sint16 end, Uint32 color);
  124. SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad,
  125. Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  126. /* Filled Pie */
  127. SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad,
  128. Sint16 start, Sint16 end, Uint32 color);
  129. SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad,
  130. Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  131. /* Trigon */
  132. SDL_GFXPRIMITIVES_SCOPE int
  133. trigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
  134. SDL_GFXPRIMITIVES_SCOPE int
  135. trigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
  136. Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  137. /* AA-Trigon */
  138. SDL_GFXPRIMITIVES_SCOPE int
  139. aatrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
  140. SDL_GFXPRIMITIVES_SCOPE int
  141. aatrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
  142. Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  143. /* Filled Trigon */
  144. SDL_GFXPRIMITIVES_SCOPE int
  145. filledTrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
  146. SDL_GFXPRIMITIVES_SCOPE int
  147. filledTrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
  148. Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  149. /* Polygon */
  150. SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color);
  151. SDL_GFXPRIMITIVES_SCOPE int polygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy,
  152. int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  153. /* AA-Polygon */
  154. SDL_GFXPRIMITIVES_SCOPE int aapolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color);
  155. SDL_GFXPRIMITIVES_SCOPE int aapolygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy,
  156. int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  157. /* Filled Polygon */
  158. SDL_GFXPRIMITIVES_SCOPE int
  159. filledPolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color);
  160. SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBA(SDL_Surface *dst, const Sint16 *vx,
  161. const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  162. SDL_GFXPRIMITIVES_SCOPE int
  163. texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx,
  164. int texture_dy);
  165. /* (Note: These MT versions are required for multi-threaded operation.) */
  166. SDL_GFXPRIMITIVES_SCOPE int
  167. filledPolygonColorMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color, int **polyInts,
  168. int *polyAllocated);
  169. SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBAMT(SDL_Surface *dst, const Sint16 *vx,
  170. const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
  171. int **polyInts, int *polyAllocated);
  172. SDL_GFXPRIMITIVES_SCOPE int
  173. texturedPolygonMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx,
  174. int texture_dy, int **polyInts, int *polyAllocated);
  175. /* Bezier */
  176. SDL_GFXPRIMITIVES_SCOPE int
  177. bezierColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, int s, Uint32 color);
  178. SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy,
  179. int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  180. /* Characters/Strings */
  181. SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch);
  182. SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation);
  183. SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface *dst, Sint16 x, Sint16 y, char c, Uint32 color);
  184. SDL_GFXPRIMITIVES_SCOPE int
  185. characterRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  186. SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface *dst, Sint16 x, Sint16 y, const char *s, Uint32 color);
  187. SDL_GFXPRIMITIVES_SCOPE int
  188. stringRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  189. /* Ends C function definitions when using C++ */
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193. #endif /* _SDL_gfxPrimitives_h */