sdl_gfx.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. unit sdl_gfx;
  2. {
  3. $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
  4. }
  5. {
  6. $Log: sdl_gfx.pas,v $
  7. Revision 1.3 2007/05/29 21:31:04 savage
  8. Changes as suggested by Almindor for 64bit compatibility.
  9. Revision 1.2 2007/05/20 20:30:18 savage
  10. Initial Changes to Handle 64 Bits
  11. Revision 1.1 2005/01/03 19:08:32 savage
  12. Header for the SDL_Gfx library.
  13. }
  14. {$I jedi-sdl.inc}
  15. interface
  16. uses
  17. sdl;
  18. const
  19. {$IFDEF WINDOWS}
  20. SDLgfxLibName = 'SDL_gfx.dll';
  21. {$ENDIF}
  22. {$IFDEF UNIX}
  23. {$IFDEF DARWIN}
  24. SDLgfxLibName = 'libSDL_gfx.dylib';
  25. {$ELSE}
  26. SDLgfxLibName = 'libSDL_gfx.so';
  27. {$ENDIF}
  28. {$ENDIF}
  29. {$IFDEF MACOS}
  30. SDLgfxLibName = 'SDL_gfx';
  31. {$ENDIF}
  32. // Some rates in Hz
  33. FPS_UPPER_LIMIT = 200;
  34. FPS_LOWER_LIMIT = 1;
  35. FPS_DEFAULT = 30;
  36. // ---- Defines
  37. SMOOTHING_OFF = 0;
  38. SMOOTHING_ON = 1;
  39. type
  40. PFPSmanager = ^TFPSmanager;
  41. TFPSmanager = packed record
  42. framecount : Uint32;
  43. rateticks : single;
  44. lastticks : Uint32;
  45. rate : Uint32;
  46. end;
  47. // ---- Structures
  48. PColorRGBA = ^TColorRGBA;
  49. TColorRGBA = packed record
  50. r : Uint8;
  51. g : Uint8;
  52. b : Uint8;
  53. a : Uint8;
  54. end;
  55. PColorY = ^TColorY;
  56. TColorY = packed record
  57. y : Uint8;
  58. end;
  59. {
  60. SDL_framerate: framerate manager
  61. LGPL (c) A. Schiffler
  62. }
  63. procedure SDL_initFramerate( manager : PFPSmanager );
  64. cdecl; external {$IFDEF __GPC__}name 'SDL_initFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  65. {$EXTERNALSYM SDL_initFramerate}
  66. function SDL_setFramerate( manager : PFPSmanager; rate : integer ) : integer;
  67. cdecl; external {$IFDEF __GPC__}name 'SDL_setFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  68. {$EXTERNALSYM SDL_setFramerate}
  69. function SDL_getFramerate( manager : PFPSmanager ) : integer;
  70. cdecl; external {$IFDEF __GPC__}name 'SDL_getFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  71. {$EXTERNALSYM SDL_getFramerate}
  72. procedure SDL_framerateDelay( manager : PFPSmanager );
  73. cdecl; external {$IFDEF __GPC__}name 'SDL_framerateDelay'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  74. {$EXTERNALSYM SDL_framerateDelay}
  75. {
  76. SDL_gfxPrimitives: graphics primitives for SDL
  77. LGPL (c) A. Schiffler
  78. }
  79. // Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
  80. // Pixel
  81. function pixelColor( dst : PSDL_Surface; x : Sint16; y : Sint16; color : Uint32 ) : integer;
  82. cdecl; external {$IFDEF __GPC__}name 'pixelColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  83. {$EXTERNALSYM pixelColor}
  84. function pixelRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  85. cdecl; external {$IFDEF __GPC__}name 'pixelRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  86. {$EXTERNALSYM pixelRGBA}
  87. // Horizontal line
  88. function hlineColor( dst : PSDL_Surface; x1: Sint16; x2 : Sint16; y : Sint16; color : Uint32 ) : integer;
  89. cdecl; external {$IFDEF __GPC__}name 'hlineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  90. {$EXTERNALSYM hlineColor}
  91. function hlineRGBA( dst : PSDL_Surface; x1: Sint16; x2 : Sint16; y : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  92. cdecl; external {$IFDEF __GPC__}name 'hlineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  93. {$EXTERNALSYM hlineRGBA}
  94. // Vertical line
  95. function vlineColor( dst : PSDL_Surface; x : Sint16; y1 : Sint16; y2 : Sint16; color : Uint32 ) : integer;
  96. cdecl; external {$IFDEF __GPC__}name 'vlineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  97. {$EXTERNALSYM vlineColor}
  98. function vlineRGBA( dst : PSDL_Surface; x : Sint16; y1 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  99. cdecl; external {$IFDEF __GPC__}name 'vlineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  100. {$EXTERNALSYM vlineRGBA}
  101. // Rectangle
  102. function rectangleColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer;
  103. cdecl; external {$IFDEF __GPC__}name 'rectangleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  104. {$EXTERNALSYM rectangleColor}
  105. function rectangleRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16;
  106. x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  107. cdecl; external {$IFDEF __GPC__}name 'rectangleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  108. {$EXTERNALSYM rectangleRGBA}
  109. // Filled rectangle (Box)
  110. function boxColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer;
  111. cdecl; external {$IFDEF __GPC__}name 'boxColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  112. {$EXTERNALSYM boxColor}
  113. function boxRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16;
  114. y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  115. cdecl; external {$IFDEF __GPC__}name 'boxRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  116. {$EXTERNALSYM boxRGBA}
  117. // Line
  118. function lineColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer;
  119. cdecl; external {$IFDEF __GPC__}name 'lineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  120. {$EXTERNALSYM lineColor}
  121. function lineRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16;
  122. x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  123. cdecl; external {$IFDEF __GPC__}name 'lineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  124. {$EXTERNALSYM lineRGBA}
  125. // AA Line
  126. function aalineColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer;
  127. cdecl; external {$IFDEF __GPC__}name 'aalineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  128. {$EXTERNALSYM aalineColor}
  129. function aalineRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16;
  130. x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  131. cdecl; external {$IFDEF __GPC__}name 'aalineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  132. {$EXTERNALSYM aalineRGBA}
  133. // Circle
  134. function circleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer;
  135. cdecl; external {$IFDEF __GPC__}name 'circleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  136. {$EXTERNALSYM circleColor}
  137. function circleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  138. cdecl; external {$IFDEF __GPC__}name 'circleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  139. {$EXTERNALSYM circleRGBA}
  140. // AA Circle
  141. function aacircleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer;
  142. cdecl; external {$IFDEF __GPC__}name 'aacircleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  143. {$EXTERNALSYM aacircleColor}
  144. function aacircleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16;
  145. rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  146. cdecl; external {$IFDEF __GPC__}name 'aacircleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  147. {$EXTERNALSYM aacircleRGBA}
  148. // Filled Circle
  149. function filledCircleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer;
  150. cdecl; external {$IFDEF __GPC__}name 'filledCircleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  151. {$EXTERNALSYM filledCircleColor}
  152. function filledCircleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16;
  153. rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  154. cdecl; external {$IFDEF __GPC__}name 'filledCircleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  155. {$EXTERNALSYM filledCircleRGBA}
  156. // Ellipse
  157. function ellipseColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer;
  158. cdecl; external {$IFDEF __GPC__}name 'ellipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  159. {$EXTERNALSYM ellipseColor}
  160. function ellipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16;
  161. rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  162. cdecl; external {$IFDEF __GPC__}name 'ellipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  163. {$EXTERNALSYM ellipseRGBA}
  164. // AA Ellipse
  165. function aaellipseColor( dst : PSDL_Surface; xc : Sint16; yc : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer;
  166. cdecl; external {$IFDEF __GPC__}name 'aaellipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  167. {$EXTERNALSYM aaellipseColor}
  168. function aaellipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16;
  169. rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  170. cdecl; external {$IFDEF __GPC__}name 'aaellipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  171. {$EXTERNALSYM aaellipseRGBA}
  172. // Filled Ellipse
  173. function filledEllipseColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer;
  174. cdecl; external {$IFDEF __GPC__}name 'filledEllipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  175. {$EXTERNALSYM filledEllipseColor}
  176. function filledEllipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16;
  177. rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  178. cdecl; external {$IFDEF __GPC__}name 'filledEllipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  179. {$EXTERNALSYM filledEllipseRGBA}
  180. // Pie
  181. function pieColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16;
  182. start : Sint16; finish : Sint16; color : Uint32 ) : integer;
  183. cdecl; external {$IFDEF __GPC__}name 'pieColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  184. {$EXTERNALSYM pieColor}
  185. function pieRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16;
  186. start : Sint16; finish : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  187. cdecl; external {$IFDEF __GPC__}name 'pieRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  188. {$EXTERNALSYM pieRGBA}
  189. // Filled Pie
  190. function filledPieColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16;
  191. start : Sint16; finish : Sint16; color : Uint32 ) : integer;
  192. cdecl; external {$IFDEF __GPC__}name 'filledPieColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  193. {$EXTERNALSYM filledPieColor}
  194. function filledPieRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16;
  195. start : Sint16; finish : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  196. cdecl; external {$IFDEF __GPC__}name 'filledPieRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  197. {$EXTERNALSYM filledPieRGBA}
  198. // Trigon
  199. function trigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer;
  200. cdecl; external {$IFDEF __GPC__}name 'trigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  201. {$EXTERNALSYM trigonColor}
  202. function trigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16;
  203. r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  204. cdecl; external {$IFDEF __GPC__}name 'trigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  205. {$EXTERNALSYM trigonRGBA}
  206. // AA-Trigon
  207. function aatrigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer;
  208. cdecl; external {$IFDEF __GPC__}name 'aatrigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  209. {$EXTERNALSYM aatrigonColor}
  210. function aatrigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16;
  211. r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  212. cdecl; external {$IFDEF __GPC__}name 'aatrigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  213. {$EXTERNALSYM aatrigonRGBA}
  214. // Filled Trigon
  215. function filledTrigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer;
  216. cdecl; external {$IFDEF __GPC__}name 'filledTrigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  217. {$EXTERNALSYM filledTrigonColor}
  218. function filledTrigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16;
  219. r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  220. cdecl; external {$IFDEF __GPC__}name 'filledTrigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  221. {$EXTERNALSYM filledTrigonRGBA}
  222. // Polygon
  223. function polygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer;
  224. cdecl; external {$IFDEF __GPC__}name 'polygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  225. {$EXTERNALSYM polygonColor}
  226. function polygonRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16;
  227. n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  228. cdecl; external {$IFDEF __GPC__}name 'polygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  229. {$EXTERNALSYM polygonRGBA}
  230. // AA-Polygon
  231. function aapolygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer;
  232. cdecl; external {$IFDEF __GPC__}name 'aapolygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  233. {$EXTERNALSYM aapolygonColor}
  234. function aapolygonRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16;
  235. n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  236. cdecl; external {$IFDEF __GPC__}name 'aapolygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  237. {$EXTERNALSYM aapolygonRGBA}
  238. // Filled Polygon
  239. function filledPolygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer;
  240. cdecl; external {$IFDEF __GPC__}name 'filledPolygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  241. {$EXTERNALSYM filledPolygonColor}
  242. function filledPolygonRGBA( dst : PSDL_Surface; const vx : PSint16;
  243. const vy : PSint16; n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  244. cdecl; external {$IFDEF __GPC__}name 'filledPolygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  245. {$EXTERNALSYM filledPolygonRGBA}
  246. // Bezier
  247. // s = number of steps
  248. function bezierColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; s : integer; color : Uint32 ) : integer;
  249. cdecl; external {$IFDEF __GPC__}name 'bezierColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  250. {$EXTERNALSYM bezierColor}
  251. function bezierRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16;
  252. n : integer; s : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  253. cdecl; external {$IFDEF __GPC__}name 'bezierRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  254. {$EXTERNALSYM bezierRGBA}
  255. // Characters/Strings
  256. function characterColor( dst : PSDL_Surface; x : Sint16; y : Sint16; c : char; color : Uint32 ) : integer;
  257. cdecl; external {$IFDEF __GPC__}name 'characterColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  258. {$EXTERNALSYM characterColor}
  259. function characterRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; c : char; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  260. cdecl; external {$IFDEF __GPC__}name 'characterRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  261. {$EXTERNALSYM characterRGBA}
  262. function stringColor( dst : PSDL_Surface; x : Sint16; y : Sint16; const c : PChar; color : Uint32 ) : integer;
  263. cdecl; external {$IFDEF __GPC__}name 'stringColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  264. {$EXTERNALSYM stringColor}
  265. function stringRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; const c : PChar; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer;
  266. cdecl; external {$IFDEF __GPC__}name 'stringRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  267. {$EXTERNALSYM stringRGBA}
  268. procedure gfxPrimitivesSetFont(const fontdata : Pointer; cw : integer; ch : integer );
  269. cdecl; external {$IFDEF __GPC__}name 'gfxPrimitivesSetFont'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  270. {$EXTERNALSYM gfxPrimitivesSetFont}
  271. {
  272. SDL_imageFilter - bytes-image "filter" routines
  273. (uses inline x86 MMX optimizations if available)
  274. LGPL (c) A. Schiffler
  275. }
  276. { Comments: }
  277. { 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. }
  278. { 2.) Data that is not within an 8 byte boundary is processed using the C routine. }
  279. { 3.) Convolution routines do not have C routines at this time. }
  280. // Detect MMX capability in CPU
  281. function SDL_imageFilterMMXdetect : integer;
  282. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXdetect'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  283. {$EXTERNALSYM SDL_imageFilterMMXdetect}
  284. // Force use of MMX off (or turn possible use back on)
  285. procedure SDL_imageFilterMMXoff;
  286. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXoff'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  287. {$EXTERNALSYM SDL_imageFilterMMXoff}
  288. procedure SDL_imageFilterMMXon;
  289. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXon'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  290. {$EXTERNALSYM SDL_imageFilterMMXon}
  291. //
  292. // All routines return:
  293. // 0 OK
  294. // -1 Error (internal error, parameter error)
  295. //
  296. // SDL_imageFilterAdd: D = saturation255(S1 + S2)
  297. function SDL_imageFilterAdd(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  298. cdecl; external {$IFDEF __GPC__}name 'SDL_imaSDL_imageFilterAddgeFilterMMXon'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  299. {$EXTERNALSYM SDL_imageFilterAdd}
  300. // SDL_imageFilterMean: D = S1/2 + S2/2
  301. function SDL_imageFilterMean(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  302. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMean'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  303. {$EXTERNALSYM SDL_imageFilterMean}
  304. // SDL_imageFilterSub: D = saturation0(S1 - S2)
  305. function SDL_imageFilterSub(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  306. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSub'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  307. {$EXTERNALSYM SDL_imageFilterSub}
  308. // SDL_imageFilterAbsDiff: D = | S1 - S2 |
  309. function SDL_imageFilterAbsDiff(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  310. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAbsDiff'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  311. {$EXTERNALSYM SDL_imageFilterAbsDiff}
  312. // SDL_imageFilterMult: D = saturation(S1 * S2)
  313. function SDL_imageFilterMult(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  314. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMult'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  315. {$EXTERNALSYM SDL_imageFilterMult}
  316. // SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
  317. function SDL_imageFilterMultNor(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  318. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultNor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  319. {$EXTERNALSYM SDL_imageFilterMultNor}
  320. // SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
  321. function SDL_imageFilterMultDivby2(Src1 : PChar; Src2 : PChar; Dest : PChar;
  322. length : integer ) : integer;
  323. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultDivby2'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  324. {$EXTERNALSYM SDL_imageFilterMultDivby2}
  325. // SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
  326. function SDL_imageFilterMultDivby4(Src1 : PChar; Src2 : PChar; Dest : PChar;
  327. length : integer ) : integer;
  328. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultDivby4'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  329. {$EXTERNALSYM SDL_imageFilterMultDivby4}
  330. // SDL_imageFilterBitAnd: D = S1 & S2
  331. function SDL_imageFilterBitAnd(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  332. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitAnd'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  333. {$EXTERNALSYM SDL_imageFilterBitAnd}
  334. // SDL_imageFilterBitOr: D = S1 | S2
  335. function SDL_imageFilterBitOr(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  336. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitOr'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  337. {$EXTERNALSYM SDL_imageFilterBitOr}
  338. // SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
  339. function SDL_imageFilterDiv(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer;
  340. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterDiv'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  341. {$EXTERNALSYM SDL_imageFilterDiv}
  342. // SDL_imageFilterBitNegation: D = !S
  343. function SDL_imageFilterBitNegation(Src1 : PChar; Dest : PChar; length : integer ) : integer;
  344. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitNegation'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  345. {$EXTERNALSYM SDL_imageFilterBitNegation}
  346. // SDL_imageFilterAddByte: D = saturation255(S + C)
  347. function SDL_imageFilterAddByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer;
  348. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  349. {$EXTERNALSYM SDL_imageFilterAddByte}
  350. // SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
  351. function SDL_imageFilterAddUint(Src1 : PChar; Dest : PChar; length : integer; C : Cardinal ) : integer;
  352. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  353. {$EXTERNALSYM SDL_imageFilterAddUint}
  354. // SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
  355. function SDL_imageFilterAddByteToHalf(Src1 : PChar; Dest : PChar; length : integer;
  356. C : char ) : integer;
  357. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddByteToHalf'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  358. {$EXTERNALSYM SDL_imageFilterAddByteToHalf}
  359. // SDL_imageFilterSubByte: D = saturation0(S - C)
  360. function SDL_imageFilterSubByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer;
  361. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSubByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  362. {$EXTERNALSYM SDL_imageFilterSubByte}
  363. // SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
  364. function SDL_imageFilterSubUint(Src1 : PChar; Dest : PChar; length : integer; C : Cardinal ) : integer;
  365. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSubUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  366. {$EXTERNALSYM SDL_imageFilterSubUint}
  367. // SDL_imageFilterShiftRight: D = saturation0(S >> N)
  368. function SDL_imageFilterShiftRight(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer;
  369. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  370. {$EXTERNALSYM SDL_imageFilterShiftRight}
  371. // SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
  372. function SDL_imageFilterShiftRightUint(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer;
  373. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  374. {$EXTERNALSYM SDL_imageFilterShiftRightUint}
  375. // SDL_imageFilterMultByByte: D = saturation255(S * C)
  376. function SDL_imageFilterMultByByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer;
  377. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  378. {$EXTERNALSYM SDL_imageFilterMultByByte}
  379. // SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
  380. function SDL_imageFilterShiftRightAndMultByByte(Src1 : PChar; Dest : PChar; length : integer;
  381. N : char; C : char ) : integer;
  382. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightAndMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  383. {$EXTERNALSYM SDL_imageFilterShiftRightAndMultByByte}
  384. // SDL_imageFilterShiftLeftByte: D = (S << N)
  385. function SDL_imageFilterShiftLeftByte(Src1 : PChar; Dest : PChar; length : integer;
  386. N : char ) : integer;
  387. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  388. {$EXTERNALSYM SDL_imageFilterShiftLeftByte}
  389. // SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
  390. function SDL_imageFilterShiftLeftUint(Src1 : PChar; Dest : PChar; length : integer;
  391. N : char ) : integer;
  392. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  393. {$EXTERNALSYM SDL_imageFilterShiftLeftUint}
  394. // SDL_imageFilterShiftLeft: D = saturation255(S << N)
  395. function SDL_imageFilterShiftLeft(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer;
  396. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeft'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  397. {$EXTERNALSYM SDL_imageFilterShiftLeft}
  398. // SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
  399. function SDL_imageFilterBinarizeUsingThreshold(Src1 : PChar; Dest : PChar; length : integer;
  400. T : char ) : integer;
  401. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBinarizeUsingThreshold'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  402. {$EXTERNALSYM SDL_imageFilterBinarizeUsingThreshold}
  403. // SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
  404. function SDL_imageFilterClipToRange(Src1 : PChar; Dest : PChar; length : integer;
  405. Tmin : Byte; Tmax : Byte ) : integer;
  406. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  407. {$EXTERNALSYM SDL_imageFilterClipToRange}
  408. // SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
  409. function SDL_imageFilterNormalizeLinear(Src1 : PChar; Dest : PChar; length : integer; Cmin : integer;
  410. Cmax : integer; Nmin : integer; Nmax : integer ) : integer;
  411. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  412. {$EXTERNALSYM SDL_imageFilterClipToRange}
  413. { !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! }
  414. // SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
  415. function SDL_imageFilterConvolveKernel3x3Divide(Src : PChar; Dest : PChar; rows : integer;
  416. columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer;
  417. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  418. {$EXTERNALSYM SDL_imageFilterConvolveKernel3x3Divide}
  419. // SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
  420. function SDL_imageFilterConvolveKernel5x5Divide(Src : PChar; Dest : PChar; rows : integer;
  421. columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer;
  422. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  423. {$EXTERNALSYM SDL_imageFilterConvolveKernel5x5Divide}
  424. // SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
  425. function SDL_imageFilterConvolveKernel7x7Divide(Src : PChar; Dest : PChar; rows : integer;
  426. columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer;
  427. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  428. {$EXTERNALSYM SDL_imageFilterConvolveKernel7x7Divide}
  429. // SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
  430. function SDL_imageFilterConvolveKernel9x9Divide(Src : PChar; Dest : PChar; rows : integer;
  431. columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer;
  432. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  433. {$EXTERNALSYM SDL_imageFilterConvolveKernel9x9Divide}
  434. // SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
  435. function SDL_imageFilterConvolveKernel3x3ShiftRight(Src : PChar; Dest : PChar; rows : integer;
  436. columns : integer; Kernel : PShortInt;
  437. NRightShift : char ) : integer;
  438. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  439. {$EXTERNALSYM SDL_imageFilterConvolveKernel3x3ShiftRight}
  440. // SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
  441. function SDL_imageFilterConvolveKernel5x5ShiftRight(Src : PChar; Dest : PChar; rows : integer;
  442. columns : integer; Kernel : PShortInt;
  443. NRightShift : char ) : integer;
  444. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  445. {$EXTERNALSYM SDL_imageFilterConvolveKernel5x5ShiftRight}
  446. // SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
  447. function SDL_imageFilterConvolveKernel7x7ShiftRight(Src : PChar; Dest : PChar; rows : integer;
  448. columns : integer; Kernel : PShortInt;
  449. NRightShift : char ) : integer;
  450. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  451. {$EXTERNALSYM SDL_imageFilterConvolveKernel7x7ShiftRight}
  452. // SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
  453. function SDL_imageFilterConvolveKernel9x9ShiftRight(Src : PChar; Dest : PChar; rows : integer;
  454. columns : integer; Kernel : PShortInt;
  455. NRightShift : char ) : integer;
  456. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  457. {$EXTERNALSYM SDL_imageFilterConvolveKernel9x9ShiftRight}
  458. // SDL_imageFilterSobelX: Dij = saturation255( ... )
  459. function SDL_imageFilterSobelX(Src : PChar; Dest : PChar; rows : integer; columns : integer ) : integer;
  460. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelX'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  461. {$EXTERNALSYM SDL_imageFilterSobelX}
  462. // SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
  463. function SDL_imageFilterSobelXShiftRight(Src : PChar; Dest : PChar; rows : integer; columns : integer;
  464. NRightShift : char ) : integer;
  465. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelXShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  466. {$EXTERNALSYM SDL_imageFilterSobelXShiftRight}
  467. // Align/restore stack to 32 byte boundary -- Functionality untested! --
  468. procedure SDL_imageFilterAlignStack;
  469. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAlignStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  470. {$EXTERNALSYM SDL_imageFilterAlignStack}
  471. procedure SDL_imageFilterRestoreStack;
  472. cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterRestoreStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  473. {$EXTERNALSYM SDL_imageFilterRestoreStack}
  474. {
  475. SDL_rotozoom - rotozoomer
  476. LGPL (c) A. Schiffler
  477. }
  478. {
  479. rotozoomSurface()
  480. Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  481. 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
  482. then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  483. or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  484. }
  485. function rotozoomSurface( src : PSDL_Surface; angle : double; zoom : double; smooth : integer ) : PSDL_Surface;
  486. cdecl; external {$IFDEF __GPC__}name 'rotozoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  487. {$EXTERNALSYM rotozoomSurface}
  488. function rotozoomSurfaceXY( src : PSDL_Surface; angle : double; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface;
  489. cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  490. {$EXTERNALSYM rotozoomSurfaceXY}
  491. { Returns the size of the target surface for a rotozoomSurface() call }
  492. procedure rotozoomSurfaceSize( width : integer; height : integer; angle : double; zoom : double; var dstwidth : integer;
  493. var dstheight : integer );
  494. cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  495. {$EXTERNALSYM rotozoomSurfaceSize}
  496. procedure rotozoomSurfaceSizeXY
  497. ( width : integer; height : integer; angle : double; zoomx : double; zoomy : double;
  498. var dstwidth : integer; var dstheight : integer );
  499. cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSizeXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  500. {$EXTERNALSYM rotozoomSurfaceSizeXY}
  501. {
  502. zoomSurface()
  503. Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  504. 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
  505. then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  506. or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  507. }
  508. function zoomSurface(src : PSDL_Surface; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface;
  509. cdecl; external {$IFDEF __GPC__}name 'zoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  510. {$EXTERNALSYM zoomSurface}
  511. { Returns the size of the target surface for a zoomSurface() call }
  512. procedure zoomSurfaceSize( width : integer; height : integer; zoomx : double; zoomy : double; var dstwidth : integer; var dstheight : integer );
  513. cdecl; external {$IFDEF __GPC__}name 'zoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__};
  514. {$EXTERNALSYM zoomSurfaceSize}
  515. implementation
  516. end.