ruby2d 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/GLES2/gl2.h +656 -0
  3. data/assets/include/GLES2/gl2ext.h +3949 -0
  4. data/assets/include/GLES2/gl2ext_angle.h +701 -0
  5. data/assets/include/GLES2/gl2platform.h +27 -0
  6. data/assets/include/GLES3/gl3.h +1192 -0
  7. data/assets/include/GLES3/gl31.h +1507 -0
  8. data/assets/include/GLES3/gl32.h +1808 -0
  9. data/assets/include/GLES3/gl3platform.h +27 -0
  10. data/assets/include/KHR/khrplatform.h +290 -0
  11. data/assets/include/SDL2/SDL.h +1 -0
  12. data/assets/include/SDL2/SDL_assert.h +4 -2
  13. data/assets/include/SDL2/SDL_atomic.h +20 -0
  14. data/assets/include/SDL2/SDL_audio.h +40 -4
  15. data/assets/include/SDL2/SDL_blendmode.h +4 -6
  16. data/assets/include/SDL2/SDL_clipboard.h +47 -0
  17. data/assets/include/SDL2/SDL_config.h +6 -2
  18. data/assets/include/SDL2/SDL_config_android.h +2 -0
  19. data/assets/include/SDL2/SDL_config_emscripten.h +2 -0
  20. data/assets/include/SDL2/SDL_config_iphoneos.h +3 -1
  21. data/assets/include/SDL2/SDL_config_macosx.h +3 -6
  22. data/assets/include/SDL2/SDL_config_minimal.h +18 -11
  23. data/assets/include/SDL2/SDL_config_ngage.h +89 -0
  24. data/assets/include/SDL2/SDL_config_os2.h +5 -3
  25. data/assets/include/SDL2/SDL_config_pandora.h +1 -0
  26. data/assets/include/SDL2/SDL_config_windows.h +71 -45
  27. data/assets/include/SDL2/SDL_config_wingdk.h +253 -0
  28. data/assets/include/SDL2/SDL_config_winrt.h +11 -49
  29. data/assets/include/SDL2/SDL_config_xbox.h +235 -0
  30. data/assets/include/SDL2/SDL_cpuinfo.h +39 -4
  31. data/assets/include/SDL2/SDL_egl.h +59 -9
  32. data/assets/include/SDL2/SDL_endian.h +34 -3
  33. data/assets/include/SDL2/SDL_events.h +32 -1
  34. data/assets/include/SDL2/SDL_filesystem.h +5 -1
  35. data/assets/include/SDL2/SDL_gamecontroller.h +78 -5
  36. data/assets/include/SDL2/SDL_guid.h +100 -0
  37. data/assets/include/SDL2/SDL_hints.h +645 -43
  38. data/assets/include/SDL2/SDL_image.h +2045 -33
  39. data/assets/include/SDL2/SDL_joystick.h +127 -7
  40. data/assets/include/SDL2/SDL_keyboard.h +38 -1
  41. data/assets/include/SDL2/SDL_keycode.h +6 -1
  42. data/assets/include/SDL2/SDL_log.h +2 -2
  43. data/assets/include/SDL2/SDL_main.h +42 -2
  44. data/assets/include/SDL2/SDL_metal.h +2 -1
  45. data/assets/include/SDL2/SDL_mixer.h +2529 -396
  46. data/assets/include/SDL2/SDL_mouse.h +12 -1
  47. data/assets/include/SDL2/SDL_opengl.h +0 -51
  48. data/assets/include/SDL2/SDL_opengl_glext.h +2260 -231
  49. data/assets/include/SDL2/SDL_opengles2_gl2.h +374 -339
  50. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +3479 -1496
  51. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +6 -9
  52. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +43 -14
  53. data/assets/include/SDL2/SDL_platform.h +32 -6
  54. data/assets/include/SDL2/SDL_rect.h +154 -2
  55. data/assets/include/SDL2/SDL_render.h +46 -17
  56. data/assets/include/SDL2/SDL_revision.h +4 -0
  57. data/assets/include/SDL2/SDL_rwops.h +1 -15
  58. data/assets/include/SDL2/SDL_scancode.h +46 -21
  59. data/assets/include/SDL2/SDL_sensor.h +24 -3
  60. data/assets/include/SDL2/SDL_stdinc.h +119 -8
  61. data/assets/include/SDL2/SDL_surface.h +3 -1
  62. data/assets/include/SDL2/SDL_system.h +66 -6
  63. data/assets/include/SDL2/SDL_syswm.h +2 -0
  64. data/assets/include/SDL2/SDL_test_common.h +1 -0
  65. data/assets/include/SDL2/SDL_test_font.h +90 -3
  66. data/assets/include/SDL2/SDL_thread.h +3 -3
  67. data/assets/include/SDL2/SDL_touch.h +8 -0
  68. data/assets/include/SDL2/SDL_ttf.h +2084 -155
  69. data/assets/include/SDL2/SDL_version.h +19 -3
  70. data/assets/include/SDL2/SDL_video.h +71 -9
  71. data/assets/include/SDL2/begin_code.h +4 -4
  72. data/assets/include/mrbconf.h +15 -17
  73. data/assets/include/mruby/array.h +8 -21
  74. data/assets/include/mruby/boxing_nan.h +115 -86
  75. data/assets/include/mruby/boxing_word.h +104 -78
  76. data/assets/include/mruby/common.h +6 -0
  77. data/assets/include/mruby/compile.h +3 -4
  78. data/assets/include/mruby/debug.h +4 -2
  79. data/assets/include/mruby/dump.h +5 -2
  80. data/assets/include/mruby/error.h +12 -2
  81. data/assets/include/mruby/gc.h +2 -0
  82. data/assets/include/mruby/hash.h +1 -3
  83. data/assets/include/mruby/irep.h +4 -4
  84. data/assets/include/mruby/numeric.h +21 -13
  85. data/assets/include/mruby/opcode.h +30 -0
  86. data/assets/include/mruby/ops.h +99 -101
  87. data/assets/include/mruby/presym/scanning.h +15 -9
  88. data/assets/include/mruby/proc.h +4 -2
  89. data/assets/include/mruby/string.h +3 -24
  90. data/assets/include/mruby/value.h +80 -40
  91. data/assets/include/mruby/variable.h +0 -15
  92. data/assets/include/mruby/version.h +5 -5
  93. data/assets/include/mruby.h +86 -16
  94. data/assets/macos/universal/bin/mrbc +0 -0
  95. data/assets/macos/universal/lib/libFLAC.a +0 -0
  96. data/assets/macos/universal/lib/libSDL2.a +0 -0
  97. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  98. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  99. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  100. data/assets/macos/universal/lib/libavif.a +0 -0
  101. data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
  102. data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
  103. data/assets/macos/universal/lib/libfreetype.a +0 -0
  104. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  105. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  106. data/assets/macos/universal/lib/libhwy.a +0 -0
  107. data/assets/macos/universal/lib/libjpeg.a +0 -0
  108. data/assets/macos/universal/lib/libjxl.a +0 -0
  109. data/assets/macos/universal/lib/libmodplug.a +0 -0
  110. data/assets/macos/universal/lib/libmpg123.a +0 -0
  111. data/assets/macos/universal/lib/libmruby.a +0 -0
  112. data/assets/macos/universal/lib/libogg.a +0 -0
  113. data/assets/macos/universal/lib/libpng.a +0 -0
  114. data/assets/macos/universal/lib/libtiff.a +0 -0
  115. data/assets/macos/universal/lib/libvorbis.a +0 -0
  116. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  117. data/assets/macos/universal/lib/libwebp.a +0 -0
  118. data/assets/macos/universal/lib/libzstd.a +0 -0
  119. data/assets/wasm/libmruby.a +0 -0
  120. data/assets/wasm/template.html +52 -4
  121. data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
  122. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  123. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
  124. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  125. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
  126. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  127. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
  128. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
  129. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
  130. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
  131. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
  132. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
  133. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  134. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
  135. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
  136. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
  137. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
  138. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
  139. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
  140. data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
  141. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  142. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  143. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
  144. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  145. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  146. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  147. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
  148. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  149. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +1 -0
  150. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  151. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
  152. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  153. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  154. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
  155. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  156. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  157. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  158. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  159. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  160. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  161. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  162. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  163. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  164. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  165. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  166. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  167. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  168. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  169. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  170. data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
  171. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  172. data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
  173. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  174. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  175. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  176. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  177. data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
  178. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  179. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  180. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  181. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  182. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  183. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  184. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  185. data/ext/ruby2d/canvas.c +540 -0
  186. data/ext/ruby2d/extconf.rb +39 -21
  187. data/ext/ruby2d/gl.c +3 -3
  188. data/ext/ruby2d/image.c +7 -7
  189. data/ext/ruby2d/ruby2d.c +741 -24
  190. data/ext/ruby2d/ruby2d.h +66 -3
  191. data/ext/ruby2d/sound.c +16 -2
  192. data/lib/ruby2d/canvas.rb +315 -0
  193. data/lib/ruby2d/circle.rb +30 -15
  194. data/lib/ruby2d/cli/build.rb +11 -4
  195. data/lib/ruby2d/cli/enable_console.rb +3 -1
  196. data/lib/ruby2d/color.rb +133 -77
  197. data/lib/ruby2d/core.rb +32 -0
  198. data/lib/ruby2d/dsl.rb +38 -32
  199. data/lib/ruby2d/exceptions.rb +2 -1
  200. data/lib/ruby2d/font.rb +97 -62
  201. data/lib/ruby2d/image.rb +48 -27
  202. data/lib/ruby2d/line.rb +84 -45
  203. data/lib/ruby2d/music.rb +33 -23
  204. data/lib/ruby2d/pixel.rb +10 -9
  205. data/lib/ruby2d/pixmap.rb +39 -0
  206. data/lib/ruby2d/pixmap_atlas.rb +56 -0
  207. data/lib/ruby2d/quad.rb +98 -49
  208. data/lib/ruby2d/rectangle.rb +35 -36
  209. data/lib/ruby2d/renderable.rb +7 -6
  210. data/lib/ruby2d/sound.rb +23 -17
  211. data/lib/ruby2d/sprite.rb +181 -140
  212. data/lib/ruby2d/square.rb +21 -20
  213. data/lib/ruby2d/text.rb +47 -19
  214. data/lib/ruby2d/texture.rb +13 -3
  215. data/lib/ruby2d/tileset.rb +97 -44
  216. data/lib/ruby2d/triangle.rb +91 -42
  217. data/lib/ruby2d/version.rb +3 -1
  218. data/lib/ruby2d/vertices.rb +81 -45
  219. data/lib/ruby2d/window.rb +508 -371
  220. data/lib/ruby2d.rb +11 -29
  221. metadata +84 -16
  222. data/assets/include/SDL2/SDL_config_psp.h +0 -165
  223. data/assets/include/SDL2/SDL_config_wiz.h +0 -154
  224. data/assets/include/glew.h +0 -23686
  225. data/assets/macos/universal/lib/libpng16.a +0 -0
  226. data/assets/wasm/build_config.rb +0 -13
  227. data/assets/windows/glew/README.md +0 -10
  228. data/assets/windows/glew/glew.h +0 -23686
  229. data/assets/windows/glew/libglew32.a +0 -0
  230. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  231. data/lib/ruby2d/entity.rb +0 -17
@@ -225,16 +225,16 @@ typedef enum
225
225
  SDL_SCANCODE_F23 = 114,
226
226
  SDL_SCANCODE_F24 = 115,
227
227
  SDL_SCANCODE_EXECUTE = 116,
228
- SDL_SCANCODE_HELP = 117,
229
- SDL_SCANCODE_MENU = 118,
228
+ SDL_SCANCODE_HELP = 117, /**< AL Integrated Help Center */
229
+ SDL_SCANCODE_MENU = 118, /**< Menu (show menu) */
230
230
  SDL_SCANCODE_SELECT = 119,
231
- SDL_SCANCODE_STOP = 120,
232
- SDL_SCANCODE_AGAIN = 121, /**< redo */
233
- SDL_SCANCODE_UNDO = 122,
234
- SDL_SCANCODE_CUT = 123,
235
- SDL_SCANCODE_COPY = 124,
236
- SDL_SCANCODE_PASTE = 125,
237
- SDL_SCANCODE_FIND = 126,
231
+ SDL_SCANCODE_STOP = 120, /**< AC Stop */
232
+ SDL_SCANCODE_AGAIN = 121, /**< AC Redo/Repeat */
233
+ SDL_SCANCODE_UNDO = 122, /**< AC Undo */
234
+ SDL_SCANCODE_CUT = 123, /**< AC Cut */
235
+ SDL_SCANCODE_COPY = 124, /**< AC Copy */
236
+ SDL_SCANCODE_PASTE = 125, /**< AC Paste */
237
+ SDL_SCANCODE_FIND = 126, /**< AC Find */
238
238
  SDL_SCANCODE_MUTE = 127,
239
239
  SDL_SCANCODE_VOLUMEUP = 128,
240
240
  SDL_SCANCODE_VOLUMEDOWN = 129,
@@ -265,9 +265,9 @@ typedef enum
265
265
  SDL_SCANCODE_LANG8 = 151, /**< reserved */
266
266
  SDL_SCANCODE_LANG9 = 152, /**< reserved */
267
267
 
268
- SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
268
+ SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
269
269
  SDL_SCANCODE_SYSREQ = 154,
270
- SDL_SCANCODE_CANCEL = 155,
270
+ SDL_SCANCODE_CANCEL = 155, /**< AC Cancel */
271
271
  SDL_SCANCODE_CLEAR = 156,
272
272
  SDL_SCANCODE_PRIOR = 157,
273
273
  SDL_SCANCODE_RETURN2 = 158,
@@ -345,6 +345,11 @@ typedef enum
345
345
  * \name Usage page 0x0C
346
346
  *
347
347
  * These values are mapped from usage page 0x0C (USB consumer page).
348
+ * See https://usb.org/sites/default/files/hut1_2.pdf
349
+ *
350
+ * There are way more keys in the spec than we can represent in the
351
+ * current scancode range, so pick the ones that commonly come up in
352
+ * real world usage.
348
353
  */
349
354
  /* @{ */
350
355
 
@@ -354,17 +359,17 @@ typedef enum
354
359
  SDL_SCANCODE_AUDIOPLAY = 261,
355
360
  SDL_SCANCODE_AUDIOMUTE = 262,
356
361
  SDL_SCANCODE_MEDIASELECT = 263,
357
- SDL_SCANCODE_WWW = 264,
362
+ SDL_SCANCODE_WWW = 264, /**< AL Internet Browser */
358
363
  SDL_SCANCODE_MAIL = 265,
359
- SDL_SCANCODE_CALCULATOR = 266,
364
+ SDL_SCANCODE_CALCULATOR = 266, /**< AL Calculator */
360
365
  SDL_SCANCODE_COMPUTER = 267,
361
- SDL_SCANCODE_AC_SEARCH = 268,
362
- SDL_SCANCODE_AC_HOME = 269,
363
- SDL_SCANCODE_AC_BACK = 270,
364
- SDL_SCANCODE_AC_FORWARD = 271,
365
- SDL_SCANCODE_AC_STOP = 272,
366
- SDL_SCANCODE_AC_REFRESH = 273,
367
- SDL_SCANCODE_AC_BOOKMARKS = 274,
366
+ SDL_SCANCODE_AC_SEARCH = 268, /**< AC Search */
367
+ SDL_SCANCODE_AC_HOME = 269, /**< AC Home */
368
+ SDL_SCANCODE_AC_BACK = 270, /**< AC Back */
369
+ SDL_SCANCODE_AC_FORWARD = 271, /**< AC Forward */
370
+ SDL_SCANCODE_AC_STOP = 272, /**< AC Stop */
371
+ SDL_SCANCODE_AC_REFRESH = 273, /**< AC Refresh */
372
+ SDL_SCANCODE_AC_BOOKMARKS = 274, /**< AC Bookmarks */
368
373
 
369
374
  /* @} *//* Usage page 0x0C */
370
375
 
@@ -383,7 +388,7 @@ typedef enum
383
388
  SDL_SCANCODE_KBDILLUMDOWN = 279,
384
389
  SDL_SCANCODE_KBDILLUMUP = 280,
385
390
  SDL_SCANCODE_EJECT = 281,
386
- SDL_SCANCODE_SLEEP = 282,
391
+ SDL_SCANCODE_SLEEP = 282, /**< SC System Sleep */
387
392
 
388
393
  SDL_SCANCODE_APP1 = 283,
389
394
  SDL_SCANCODE_APP2 = 284,
@@ -402,6 +407,26 @@ typedef enum
402
407
 
403
408
  /* @} *//* Usage page 0x0C (additional media keys) */
404
409
 
410
+ /**
411
+ * \name Mobile keys
412
+ *
413
+ * These are values that are often used on mobile phones.
414
+ */
415
+ /* @{ */
416
+
417
+ SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and
418
+ used as a multi-function feature key for selecting
419
+ a software defined function shown on the bottom left
420
+ of the display. */
421
+ SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
422
+ used as a multi-function feature key for selecting
423
+ a software defined function shown on the bottom right
424
+ of the display. */
425
+ SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */
426
+ SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */
427
+
428
+ /* @} *//* Mobile keys */
429
+
405
430
  /* Add any other keys here. */
406
431
 
407
432
  SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes
@@ -71,7 +71,11 @@ typedef enum
71
71
  SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */
72
72
  SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */
73
73
  SDL_SENSOR_ACCEL, /**< Accelerometer */
74
- SDL_SENSOR_GYRO /**< Gyroscope */
74
+ SDL_SENSOR_GYRO, /**< Gyroscope */
75
+ SDL_SENSOR_ACCEL_L, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */
76
+ SDL_SENSOR_GYRO_L, /**< Gyroscope for left Joy-Con controller */
77
+ SDL_SENSOR_ACCEL_R, /**< Accelerometer for right Joy-Con controller */
78
+ SDL_SENSOR_GYRO_R /**< Gyroscope for right Joy-Con controller */
75
79
  } SDL_SensorType;
76
80
 
77
81
  /**
@@ -263,7 +267,24 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
263
267
  *
264
268
  * \since This function is available since SDL 2.0.9.
265
269
  */
266
- extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values);
270
+ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values);
271
+
272
+ /**
273
+ * Get the current state of an opened sensor with the timestamp of the last
274
+ * update.
275
+ *
276
+ * The number of values and interpretation of the data is sensor dependent.
277
+ *
278
+ * \param sensor The SDL_Sensor object to query
279
+ * \param timestamp A pointer filled with the timestamp in microseconds of the
280
+ * current sensor reading if available, or 0 if not
281
+ * \param data A pointer filled with the current sensor state
282
+ * \param num_values The number of values to write to data
283
+ * \returns 0 or -1 if an error occurred.
284
+ *
285
+ * \since This function is available since SDL 2.26.0.
286
+ */
287
+ extern DECLSPEC int SDLCALL SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values);
267
288
 
268
289
  /**
269
290
  * Close a sensor previously opened with SDL_SensorOpen().
@@ -272,7 +293,7 @@ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data,
272
293
  *
273
294
  * \since This function is available since SDL 2.0.9.
274
295
  */
275
- extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
296
+ extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor *sensor);
276
297
 
277
298
  /**
278
299
  * Update the current state of the open sensors.
@@ -80,9 +80,9 @@
80
80
  # include <ctype.h>
81
81
  #endif
82
82
  #ifdef HAVE_MATH_H
83
- # if defined(__WINRT__)
83
+ # if defined(_MSC_VER)
84
84
  /* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
85
- WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
85
+ Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
86
86
  for more information.
87
87
  */
88
88
  # define _USE_MATH_DEFINES
@@ -115,6 +115,12 @@ char *alloca();
115
115
  # endif
116
116
  #endif
117
117
 
118
+ #ifdef SIZE_MAX
119
+ # define SDL_SIZE_MAX SIZE_MAX
120
+ #else
121
+ # define SDL_SIZE_MAX ((size_t) -1)
122
+ #endif
123
+
118
124
  /**
119
125
  * Check if the compiler supports a given builtin.
120
126
  * Supported by virtually all clang versions and recent gcc. Use this
@@ -234,13 +240,26 @@ typedef uint64_t Uint64;
234
240
 
235
241
  /* @} *//* Basic data types */
236
242
 
243
+ /**
244
+ * \name Floating-point constants
245
+ */
246
+ /* @{ */
247
+
248
+ #ifdef FLT_EPSILON
249
+ #define SDL_FLT_EPSILON FLT_EPSILON
250
+ #else
251
+ #define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */
252
+ #endif
253
+
254
+ /* @} *//* Floating-point constants */
255
+
237
256
  /* Make sure we have macros for printing width-based integers.
238
257
  * <stdint.h> should define these but this is not true all platforms.
239
258
  * (for example win32) */
240
259
  #ifndef SDL_PRIs64
241
260
  #ifdef PRIs64
242
261
  #define SDL_PRIs64 PRIs64
243
- #elif defined(__WIN32__)
262
+ #elif defined(__WIN32__) || defined(__GDK__)
244
263
  #define SDL_PRIs64 "I64d"
245
264
  #elif defined(__LINUX__) && defined(__LP64__)
246
265
  #define SDL_PRIs64 "ld"
@@ -251,7 +270,7 @@ typedef uint64_t Uint64;
251
270
  #ifndef SDL_PRIu64
252
271
  #ifdef PRIu64
253
272
  #define SDL_PRIu64 PRIu64
254
- #elif defined(__WIN32__)
273
+ #elif defined(__WIN32__) || defined(__GDK__)
255
274
  #define SDL_PRIu64 "I64u"
256
275
  #elif defined(__LINUX__) && defined(__LP64__)
257
276
  #define SDL_PRIu64 "lu"
@@ -262,7 +281,7 @@ typedef uint64_t Uint64;
262
281
  #ifndef SDL_PRIx64
263
282
  #ifdef PRIx64
264
283
  #define SDL_PRIx64 PRIx64
265
- #elif defined(__WIN32__)
284
+ #elif defined(__WIN32__) || defined(__GDK__)
266
285
  #define SDL_PRIx64 "I64x"
267
286
  #elif defined(__LINUX__) && defined(__LP64__)
268
287
  #define SDL_PRIx64 "lx"
@@ -273,7 +292,7 @@ typedef uint64_t Uint64;
273
292
  #ifndef SDL_PRIX64
274
293
  #ifdef PRIX64
275
294
  #define SDL_PRIX64 PRIX64
276
- #elif defined(__WIN32__)
295
+ #elif defined(__WIN32__) || defined(__GDK__)
277
296
  #define SDL_PRIX64 "I64X"
278
297
  #elif defined(__LINUX__) && defined(__LP64__)
279
298
  #define SDL_PRIX64 "lX"
@@ -354,8 +373,22 @@ typedef uint64_t Uint64;
354
373
  #endif
355
374
  #endif /* SDL_DISABLE_ANALYZE_MACROS */
356
375
 
376
+ #ifndef SDL_COMPILE_TIME_ASSERT
377
+ #if defined(__cplusplus)
378
+ #if (__cplusplus >= 201103L)
379
+ #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
380
+ #endif
381
+ #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
382
+ #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
383
+ #endif
384
+ #endif /* !SDL_COMPILE_TIME_ASSERT */
385
+
386
+ #ifndef SDL_COMPILE_TIME_ASSERT
387
+ /* universal, but may trigger -Wunused-local-typedefs */
357
388
  #define SDL_COMPILE_TIME_ASSERT(name, x) \
358
389
  typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
390
+ #endif
391
+
359
392
  /** \cond */
360
393
  #ifndef DOXYGEN_SHOULD_IGNORE_THIS
361
394
  SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
@@ -377,7 +410,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
377
410
 
378
411
  /** \cond */
379
412
  #ifndef DOXYGEN_SHOULD_IGNORE_THIS
380
- #if !defined(__ANDROID__) && !defined(__VITA__)
413
+ #if !defined(__ANDROID__) && !defined(__VITA__) && !defined(__3DS__)
381
414
  /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
382
415
  typedef enum
383
416
  {
@@ -413,6 +446,16 @@ typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
413
446
  typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
414
447
  typedef void (SDLCALL *SDL_free_func)(void *mem);
415
448
 
449
+ /**
450
+ * Get the original set of SDL memory functions
451
+ *
452
+ * \since This function is available since SDL 2.24.0.
453
+ */
454
+ extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
455
+ SDL_calloc_func *calloc_func,
456
+ SDL_realloc_func *realloc_func,
457
+ SDL_free_func *free_func);
458
+
416
459
  /**
417
460
  * Get the current set of SDL memory functions
418
461
  *
@@ -443,7 +486,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
443
486
  extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
444
487
  extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
445
488
 
446
- extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
489
+ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
490
+ extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
447
491
 
448
492
  extern DECLSPEC int SDLCALL SDL_abs(int x);
449
493
 
@@ -467,6 +511,7 @@ extern DECLSPEC int SDLCALL SDL_isgraph(int x);
467
511
  extern DECLSPEC int SDLCALL SDL_toupper(int x);
468
512
  extern DECLSPEC int SDLCALL SDL_tolower(int x);
469
513
 
514
+ extern DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
470
515
  extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
471
516
 
472
517
  extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
@@ -475,6 +520,11 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
475
520
  #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
476
521
  #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
477
522
 
523
+ #define SDL_copyp(dst, src) \
524
+ { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
525
+ SDL_memcpy((dst), (src), sizeof (*(src)))
526
+
527
+
478
528
  /* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
479
529
  SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
480
530
  {
@@ -533,8 +583,10 @@ extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
533
583
  extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
534
584
  extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
535
585
  extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
586
+ extern DECLSPEC char *SDLCALL SDL_strcasestr(const char *haystack, const char *needle);
536
587
  extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr);
537
588
  extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
589
+ extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
538
590
 
539
591
  extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
540
592
  extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
@@ -708,6 +760,65 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
708
760
  return SDL_memcpy(dst, src, dwords * 4);
709
761
  }
710
762
 
763
+ /**
764
+ * If a * b would overflow, return -1. Otherwise store a * b via ret
765
+ * and return 0.
766
+ *
767
+ * \since This function is available since SDL 2.24.0.
768
+ */
769
+ SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
770
+ size_t b,
771
+ size_t *ret)
772
+ {
773
+ if (a != 0 && b > SDL_SIZE_MAX / a) {
774
+ return -1;
775
+ }
776
+ *ret = a * b;
777
+ return 0;
778
+ }
779
+
780
+ #if _SDL_HAS_BUILTIN(__builtin_mul_overflow)
781
+ /* This needs to be wrapped in an inline rather than being a direct #define,
782
+ * because __builtin_mul_overflow() is type-generic, but we want to be
783
+ * consistent about interpreting a and b as size_t. */
784
+ SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
785
+ size_t b,
786
+ size_t *ret)
787
+ {
788
+ return __builtin_mul_overflow(a, b, ret) == 0 ? 0 : -1;
789
+ }
790
+ #define SDL_size_mul_overflow(a, b, ret) (_SDL_size_mul_overflow_builtin(a, b, ret))
791
+ #endif
792
+
793
+ /**
794
+ * If a + b would overflow, return -1. Otherwise store a + b via ret
795
+ * and return 0.
796
+ *
797
+ * \since This function is available since SDL 2.24.0.
798
+ */
799
+ SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
800
+ size_t b,
801
+ size_t *ret)
802
+ {
803
+ if (b > SDL_SIZE_MAX - a) {
804
+ return -1;
805
+ }
806
+ *ret = a + b;
807
+ return 0;
808
+ }
809
+
810
+ #if _SDL_HAS_BUILTIN(__builtin_add_overflow)
811
+ /* This needs to be wrapped in an inline rather than being a direct #define,
812
+ * the same as the call to __builtin_mul_overflow() above. */
813
+ SDL_FORCE_INLINE int _SDL_size_add_overflow_builtin (size_t a,
814
+ size_t b,
815
+ size_t *ret)
816
+ {
817
+ return __builtin_add_overflow(a, b, ret) == 0 ? 0 : -1;
818
+ }
819
+ #define SDL_size_add_overflow(a, b, ret) (_SDL_size_add_overflow_builtin(a, b, ret))
820
+ #endif
821
+
711
822
  /* Ends C function definitions when using C++ */
712
823
  #ifdef __cplusplus
713
824
  }
@@ -61,6 +61,8 @@ extern "C" {
61
61
  */
62
62
  #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
63
63
 
64
+ typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
65
+
64
66
  /**
65
67
  * \brief A collection of pixels used in software blitting.
66
68
  *
@@ -88,7 +90,7 @@ typedef struct SDL_Surface
88
90
  SDL_Rect clip_rect; /**< Read-only */
89
91
 
90
92
  /** info for fast blit mapping to other surfaces */
91
- struct SDL_BlitMap *map; /**< Private */
93
+ SDL_BlitMap *map; /**< Private */
92
94
 
93
95
  /** Reference count -- used when freeing surface */
94
96
  int refcount; /**< Read-mostly */
@@ -41,7 +41,7 @@ extern "C" {
41
41
 
42
42
 
43
43
  /* Platform specific functions for Windows */
44
- #ifdef __WIN32__
44
+ #if defined(__WIN32__) || defined(__GDK__)
45
45
 
46
46
  typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
47
47
 
@@ -55,6 +55,10 @@ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsi
55
55
  */
56
56
  extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
57
57
 
58
+ #endif /* defined(__WIN32__) || defined(__GDK__) */
59
+
60
+ #if defined(__WIN32__) || defined(__WINGDK__)
61
+
58
62
  /**
59
63
  * Get the D3D9 adapter index that matches the specified display index.
60
64
  *
@@ -102,6 +106,30 @@ typedef struct ID3D11Device ID3D11Device;
102
106
  */
103
107
  extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer);
104
108
 
109
+ #endif /* defined(__WIN32__) || defined(__WINGDK__) */
110
+
111
+ #if defined(__WIN32__) || defined(__GDK__)
112
+
113
+ typedef struct ID3D12Device ID3D12Device;
114
+
115
+ /**
116
+ * Get the D3D12 device associated with a renderer.
117
+ *
118
+ * Once you are done using the device, you should release it to avoid a
119
+ * resource leak.
120
+ *
121
+ * \param renderer the renderer from which to get the associated D3D12 device
122
+ * \returns the D3D12 device associated with given renderer or NULL if it is
123
+ * not a D3D12 renderer; call SDL_GetError() for more information.
124
+ *
125
+ * \since This function is available since SDL 2.24.0.
126
+ */
127
+ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* renderer);
128
+
129
+ #endif /* defined(__WIN32__) || defined(__GDK__) */
130
+
131
+ #if defined(__WIN32__) || defined(__WINGDK__)
132
+
105
133
  /**
106
134
  * Get the DXGI Adapter and Output indices for the specified display index.
107
135
  *
@@ -122,8 +150,7 @@ extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * re
122
150
  */
123
151
  extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
124
152
 
125
- #endif /* __WIN32__ */
126
-
153
+ #endif /* defined(__WIN32__) || defined(__WINGDK__) */
127
154
 
128
155
  /* Platform specific functions for Linux */
129
156
  #ifdef __LINUX__
@@ -178,7 +205,7 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
178
205
  * This function is only available on Apple iOS.
179
206
  *
180
207
  * For more information see:
181
- * [README-ios.md](https://hg.libsdl.org/SDL/file/default/docs/README-ios.md)
208
+ * https://github.com/libsdl-org/SDL/blob/main/docs/README-ios.md
182
209
  *
183
210
  * This functions is also accessible using the macro
184
211
  * SDL_iOSSetAnimationCallback() since SDL 2.0.4.
@@ -195,7 +222,7 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
195
222
  *
196
223
  * \sa SDL_iPhoneSetEventPump
197
224
  */
198
- extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
225
+ extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (SDLCALL *callback)(void*), void *callbackParam);
199
226
 
200
227
  #define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
201
228
 
@@ -425,6 +452,18 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permis
425
452
  */
426
453
  extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
427
454
 
455
+ /**
456
+ * Send a user command to SDLActivity.
457
+ *
458
+ * Override "boolean onUnhandledMessage(Message msg)" to handle the message.
459
+ *
460
+ * \param command user command that must be greater or equal to 0x8000
461
+ * \param param user parameter
462
+ *
463
+ * \since This function is available since SDL 2.0.22.
464
+ */
465
+ extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
466
+
428
467
  #endif /* __ANDROID__ */
429
468
 
430
469
  /* Platform specific functions for WinRT */
@@ -520,7 +559,7 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
520
559
  extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
521
560
 
522
561
  /**
523
- * Detects the device family of WinRT plattform at runtime.
562
+ * Detects the device family of WinRT platform at runtime.
524
563
  *
525
564
  * \returns a value from the SDL_WinRT_DeviceFamily enum.
526
565
  *
@@ -552,6 +591,27 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void);
552
591
  extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
553
592
  #endif
554
593
 
594
+ /* Functions used only by GDK */
595
+ #if defined(__GDK__)
596
+ typedef struct XTaskQueueObject * XTaskQueueHandle;
597
+
598
+ /**
599
+ * Gets a reference to the global async task queue handle for GDK,
600
+ * initializing if needed.
601
+ *
602
+ * Once you are done with the task queue, you should call
603
+ * XTaskQueueCloseHandle to reduce the reference count to avoid a resource
604
+ * leak.
605
+ *
606
+ * \param outTaskQueue a pointer to be filled in with task queue handle.
607
+ * \returns 0 if success, -1 if any error occurs.
608
+ *
609
+ * \since This function is available since SDL 2.24.0.
610
+ */
611
+ extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue);
612
+
613
+ #endif
614
+
555
615
  /* Ends C function definitions when using C++ */
556
616
  #ifdef __cplusplus
557
617
  }
@@ -298,6 +298,8 @@ struct SDL_SysWMinfo
298
298
  struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */
299
299
  struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */
300
300
  struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */
301
+ struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */
302
+ struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */
301
303
  } wl;
302
304
  #endif
303
305
  #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
@@ -50,6 +50,7 @@
50
50
  #define VERBOSE_RENDER 0x00000004
51
51
  #define VERBOSE_EVENT 0x00000008
52
52
  #define VERBOSE_AUDIO 0x00000010
53
+ #define VERBOSE_MOTION 0x00000020
53
54
 
54
55
  typedef struct
55
56
  {
@@ -38,7 +38,8 @@ extern "C" {
38
38
 
39
39
  /* Function prototypes */
40
40
 
41
- #define FONT_CHARACTER_SIZE 8
41
+ #define FONT_CHARACTER_SIZE 8
42
+ #define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2)
42
43
 
43
44
  /**
44
45
  * \brief Draw a string in the currently set font.
@@ -50,10 +51,12 @@ extern "C" {
50
51
  *
51
52
  * \returns 0 on success, -1 on failure.
52
53
  */
53
- int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c);
54
+ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c);
54
55
 
55
56
  /**
56
- * \brief Draw a string in the currently set font.
57
+ * \brief Draw a UTF-8 string in the currently set font.
58
+ *
59
+ * The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.
57
60
  *
58
61
  * \param renderer The renderer to draw on.
59
62
  * \param x The X coordinate of the upper left corner of the string.
@@ -64,6 +67,90 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c);
64
67
  */
65
68
  int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
66
69
 
70
+ /**
71
+ * \brief Data used for multi-line text output
72
+ */
73
+ typedef struct SDLTest_TextWindow
74
+ {
75
+ SDL_Rect rect;
76
+ int current;
77
+ int numlines;
78
+ char **lines;
79
+ } SDLTest_TextWindow;
80
+
81
+ /**
82
+ * \brief Create a multi-line text output window
83
+ *
84
+ * \param x The X coordinate of the upper left corner of the window.
85
+ * \param y The Y coordinate of the upper left corner of the window.
86
+ * \param w The width of the window (currently ignored)
87
+ * \param h The height of the window (currently ignored)
88
+ *
89
+ * \returns the new window, or NULL on failure.
90
+ *
91
+ * \since This function is available since SDL 2.24.0
92
+ */
93
+ SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h);
94
+
95
+ /**
96
+ * \brief Display a multi-line text output window
97
+ *
98
+ * This function should be called every frame to display the text
99
+ *
100
+ * \param textwin The text output window
101
+ * \param renderer The renderer to use for display
102
+ *
103
+ * \since This function is available since SDL 2.24.0
104
+ */
105
+ void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer);
106
+
107
+ /**
108
+ * \brief Add text to a multi-line text output window
109
+ *
110
+ * Adds UTF-8 text to the end of the current text. The newline character starts a
111
+ * new line of text. The backspace character deletes the last character or, if the
112
+ * line is empty, deletes the line and goes to the end of the previous line.
113
+ *
114
+ * \param textwin The text output window
115
+ * \param fmt A printf() style format string
116
+ * \param ... additional parameters matching % tokens in the `fmt` string, if any
117
+ *
118
+ * \since This function is available since SDL 2.24.0
119
+ */
120
+ void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
121
+
122
+ /**
123
+ * \brief Add text to a multi-line text output window
124
+ *
125
+ * Adds UTF-8 text to the end of the current text. The newline character starts a
126
+ * new line of text. The backspace character deletes the last character or, if the
127
+ * line is empty, deletes the line and goes to the end of the previous line.
128
+ *
129
+ * \param textwin The text output window
130
+ * \param text The text to add to the window
131
+ * \param len The length, in bytes, of the text to add to the window
132
+ *
133
+ * \since This function is available since SDL 2.24.0
134
+ */
135
+ void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len);
136
+
137
+ /**
138
+ * \brief Clear the text in a multi-line text output window
139
+ *
140
+ * \param textwin The text output window
141
+ *
142
+ * \since This function is available since SDL 2.24.0
143
+ */
144
+ void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin);
145
+
146
+ /**
147
+ * \brief Free the storage associated with a multi-line text output window
148
+ *
149
+ * \param textwin The text output window
150
+ *
151
+ * \since This function is available since SDL 2.24.0
152
+ */
153
+ void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin);
67
154
 
68
155
  /**
69
156
  * \brief Cleanup textures used by font drawing functions.