gosu 1.4.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +2 -1
  3. data/dependencies/SDL/include/SDL3/SDL.h +91 -0
  4. data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
  5. data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
  6. data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
  7. data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
  8. data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
  9. data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
  10. data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
  11. data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
  12. data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
  13. data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
  14. data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
  15. data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
  16. data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
  17. data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
  18. data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
  19. data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
  20. data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
  21. data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
  22. data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
  23. data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
  24. data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
  25. data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
  26. data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
  27. data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
  28. data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
  29. data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
  30. data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
  31. data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
  32. data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
  33. data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
  34. data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
  35. data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
  36. data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
  37. data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
  38. data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
  39. data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
  40. data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
  41. data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
  42. data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
  43. data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
  44. data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
  45. data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
  46. data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
  47. data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
  48. data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
  49. data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
  50. data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
  51. data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
  52. data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
  53. data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
  54. data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
  55. data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
  56. data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
  57. data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
  58. data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
  59. data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
  60. data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
  61. data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
  62. data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
  63. data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
  64. data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
  65. data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
  66. data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
  67. data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
  68. data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
  69. data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
  70. data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
  71. data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
  72. data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
  73. data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
  74. data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
  75. data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
  76. data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
  77. data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
  78. data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
  79. data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
  80. data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
  81. data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
  82. data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
  83. data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
  84. data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
  85. data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
  88. data/dependencies/SDL_sound/SDL_sound.c +136 -215
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
  90. data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
  101. data/dependencies/SDL_sound/dr_flac.h +1890 -1301
  102. data/dependencies/SDL_sound/dr_mp3.h +1098 -660
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
  105. data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
  106. data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
  107. data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
  108. data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
  109. data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
  110. data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
  111. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
  112. data/dependencies/SDL_sound/stb_vorbis.h +397 -342
  113. data/dependencies/mojoAL/AL/alc.h +2 -2
  114. data/dependencies/mojoAL/mojoal.c +2120 -1885
  115. data/dependencies/stb/stb_image.h +1190 -1379
  116. data/dependencies/stb/stb_image_write.h +329 -129
  117. data/dependencies/stb/stb_truetype.h +304 -60
  118. data/dependencies/utf8proc/utf8proc.c +133 -75
  119. data/dependencies/utf8proc/utf8proc.h +131 -50
  120. data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
  121. data/ext/gosu-ffi/extconf.rb +103 -0
  122. data/ext/gosu-ffi/gosu-ffi.def +467 -0
  123. data/ffi/Gosu.cpp +330 -0
  124. data/ffi/Gosu.h +84 -0
  125. data/ffi/Gosu_Channel.cpp +62 -0
  126. data/ffi/Gosu_Channel.h +17 -0
  127. data/ffi/Gosu_Color.cpp +176 -0
  128. data/ffi/Gosu_Color.h +31 -0
  129. data/ffi/Gosu_Constants.cpp +334 -0
  130. data/ffi/Gosu_FFI.h +34 -0
  131. data/ffi/Gosu_FFI_internal.h +160 -0
  132. data/ffi/Gosu_Font.cpp +97 -0
  133. data/ffi/Gosu_Font.h +32 -0
  134. data/ffi/Gosu_Image.cpp +239 -0
  135. data/ffi/Gosu_Image.h +71 -0
  136. data/ffi/Gosu_Sample.cpp +29 -0
  137. data/ffi/Gosu_Sample.h +14 -0
  138. data/ffi/Gosu_Song.cpp +69 -0
  139. data/ffi/Gosu_Song.h +18 -0
  140. data/ffi/Gosu_TextInput.cpp +94 -0
  141. data/ffi/Gosu_TextInput.h +25 -0
  142. data/ffi/Gosu_Window.cpp +314 -0
  143. data/ffi/Gosu_Window.h +78 -0
  144. data/include/Gosu/Audio.hpp +6 -11
  145. data/include/Gosu/Bitmap.hpp +38 -53
  146. data/include/Gosu/Buffer.hpp +54 -0
  147. data/include/Gosu/Color.hpp +29 -36
  148. data/include/Gosu/Directories.hpp +25 -28
  149. data/include/Gosu/Drawable.hpp +58 -0
  150. data/include/Gosu/Font.hpp +6 -5
  151. data/include/Gosu/Fwd.hpp +4 -6
  152. data/include/Gosu/Gosu.hpp +5 -5
  153. data/include/Gosu/Graphics.hpp +53 -61
  154. data/include/Gosu/GraphicsBase.hpp +1 -11
  155. data/include/Gosu/Image.hpp +12 -15
  156. data/include/Gosu/Math.hpp +50 -72
  157. data/include/Gosu/Transform.hpp +32 -0
  158. data/include/Gosu/Utility.hpp +77 -1
  159. data/include/Gosu/Version.hpp +2 -2
  160. data/include/Gosu/Window.hpp +15 -9
  161. data/lib/SDL3.dll +0 -0
  162. data/lib/gosu/channel.rb +50 -0
  163. data/lib/gosu/color.rb +173 -0
  164. data/lib/gosu/compat.rb +130 -17
  165. data/lib/gosu/constants.rb +386 -0
  166. data/lib/gosu/ffi.rb +269 -0
  167. data/lib/gosu/font.rb +62 -0
  168. data/lib/gosu/gl_tex_info.rb +33 -0
  169. data/lib/gosu/gosu.rb +250 -0
  170. data/lib/gosu/image.rb +179 -0
  171. data/lib/gosu/numeric.rb +17 -0
  172. data/lib/gosu/preview.rb +6 -6
  173. data/lib/gosu/sample.rb +25 -0
  174. data/lib/gosu/song.rb +57 -0
  175. data/lib/gosu/text_input.rb +83 -0
  176. data/lib/gosu/window.rb +249 -0
  177. data/lib/gosu.rb +29 -8
  178. data/lib64/SDL3.dll +0 -0
  179. data/rdoc/gosu.rb +2 -2
  180. data/src/Audio.cpp +30 -24
  181. data/src/AudioFile.hpp +5 -4
  182. data/src/AudioFileAudioToolbox.cpp +8 -8
  183. data/src/AudioFileSDLSound.cpp +12 -15
  184. data/src/BinPacker.cpp +188 -0
  185. data/src/BinPacker.hpp +55 -0
  186. data/src/Bitmap.cpp +172 -143
  187. data/src/BitmapIO.cpp +60 -86
  188. data/src/Buffer.cpp +150 -0
  189. data/src/ClipRectStack.cpp +38 -0
  190. data/src/ClipRectStack.hpp +17 -83
  191. data/src/Color.cpp +75 -80
  192. data/src/Directories.cpp +47 -0
  193. data/src/DirectoriesUIKit.cpp +50 -0
  194. data/src/DrawOp.hpp +20 -18
  195. data/src/DrawOpQueue.hpp +27 -33
  196. data/src/Drawable.cpp +95 -0
  197. data/src/EmptyDrawable.hpp +38 -0
  198. data/src/FPS.cpp +31 -0
  199. data/src/Font.cpp +104 -74
  200. data/src/GosuGLView.cpp +13 -11
  201. data/src/GosuViewController.cpp +2 -10
  202. data/src/Graphics.cpp +86 -145
  203. data/src/GraphicsImpl.hpp +14 -68
  204. data/src/Image.cpp +41 -35
  205. data/src/Input.cpp +73 -78
  206. data/src/Macro.cpp +46 -29
  207. data/src/Macro.hpp +23 -17
  208. data/src/MarkupParser.cpp +5 -5
  209. data/src/Math.cpp +48 -22
  210. data/src/OffScreenTarget.cpp +47 -50
  211. data/src/OffScreenTarget.hpp +13 -11
  212. data/src/OpenGLContext.cpp +116 -0
  213. data/src/OpenGLContext.hpp +41 -0
  214. data/src/RenderState.hpp +49 -71
  215. data/src/Resolution.cpp +65 -53
  216. data/src/TexChunk.cpp +35 -80
  217. data/src/TexChunk.hpp +44 -35
  218. data/src/Text.cpp +1 -1
  219. data/src/TextBuilder.cpp +35 -21
  220. data/src/TextBuilder.hpp +6 -9
  221. data/src/TextInput.cpp +9 -9
  222. data/src/Texture.cpp +62 -80
  223. data/src/Texture.hpp +25 -23
  224. data/src/TiledDrawable.cpp +149 -0
  225. data/src/TiledDrawable.hpp +47 -0
  226. data/src/TimingApple.cpp +1 -1
  227. data/src/Transform.cpp +45 -50
  228. data/src/TransformStack.hpp +16 -16
  229. data/src/TrueTypeFont.cpp +59 -51
  230. data/src/TrueTypeFont.hpp +6 -7
  231. data/src/TrueTypeFontApple.cpp +28 -19
  232. data/src/TrueTypeFontUnix.cpp +39 -32
  233. data/src/TrueTypeFontWin.cpp +30 -30
  234. data/src/Utility.cpp +113 -37
  235. data/src/UtilityWin.cpp +49 -0
  236. data/src/Window.cpp +121 -151
  237. data/src/WindowUIKit.cpp +14 -14
  238. metadata +165 -118
  239. data/dependencies/SDL/include/SDL.h +0 -233
  240. data/dependencies/SDL/include/SDL_assert.h +0 -320
  241. data/dependencies/SDL/include/SDL_atomic.h +0 -415
  242. data/dependencies/SDL/include/SDL_audio.h +0 -1500
  243. data/dependencies/SDL/include/SDL_clipboard.h +0 -141
  244. data/dependencies/SDL/include/SDL_config.h +0 -331
  245. data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
  246. data/dependencies/SDL/include/SDL_endian.h +0 -348
  247. data/dependencies/SDL/include/SDL_error.h +0 -163
  248. data/dependencies/SDL/include/SDL_events.h +0 -1166
  249. data/dependencies/SDL/include/SDL_filesystem.h +0 -149
  250. data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
  251. data/dependencies/SDL/include/SDL_gesture.h +0 -117
  252. data/dependencies/SDL/include/SDL_guid.h +0 -100
  253. data/dependencies/SDL/include/SDL_haptic.h +0 -1341
  254. data/dependencies/SDL/include/SDL_hidapi.h +0 -451
  255. data/dependencies/SDL/include/SDL_hints.h +0 -2569
  256. data/dependencies/SDL/include/SDL_joystick.h +0 -1066
  257. data/dependencies/SDL/include/SDL_keyboard.h +0 -353
  258. data/dependencies/SDL/include/SDL_keycode.h +0 -358
  259. data/dependencies/SDL/include/SDL_loadso.h +0 -115
  260. data/dependencies/SDL/include/SDL_log.h +0 -404
  261. data/dependencies/SDL/include/SDL_main.h +0 -275
  262. data/dependencies/SDL/include/SDL_mouse.h +0 -465
  263. data/dependencies/SDL/include/SDL_mutex.h +0 -471
  264. data/dependencies/SDL/include/SDL_name.h +0 -33
  265. data/dependencies/SDL/include/SDL_pixels.h +0 -644
  266. data/dependencies/SDL/include/SDL_platform.h +0 -261
  267. data/dependencies/SDL/include/SDL_quit.h +0 -58
  268. data/dependencies/SDL/include/SDL_rect.h +0 -376
  269. data/dependencies/SDL/include/SDL_render.h +0 -1919
  270. data/dependencies/SDL/include/SDL_revision.h +0 -7
  271. data/dependencies/SDL/include/SDL_rwops.h +0 -841
  272. data/dependencies/SDL/include/SDL_sensor.h +0 -322
  273. data/dependencies/SDL/include/SDL_shape.h +0 -155
  274. data/dependencies/SDL/include/SDL_stdinc.h +0 -830
  275. data/dependencies/SDL/include/SDL_surface.h +0 -997
  276. data/dependencies/SDL/include/SDL_system.h +0 -623
  277. data/dependencies/SDL/include/SDL_syswm.h +0 -386
  278. data/dependencies/SDL/include/SDL_test_images.h +0 -78
  279. data/dependencies/SDL/include/SDL_test_random.h +0 -115
  280. data/dependencies/SDL/include/SDL_thread.h +0 -464
  281. data/dependencies/SDL/include/SDL_timer.h +0 -222
  282. data/dependencies/SDL/include/SDL_touch.h +0 -150
  283. data/dependencies/SDL/include/SDL_version.h +0 -204
  284. data/dependencies/SDL/include/SDL_video.h +0 -2150
  285. data/dependencies/SDL/include/SDL_vulkan.h +0 -215
  286. data/dependencies/SDL/include/begin_code.h +0 -187
  287. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  288. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  289. data/dependencies/SDL_sound/SDL_sound.h +0 -725
  290. data/ext/gosu/extconf.rb +0 -119
  291. data/include/Gosu/IO.hpp +0 -254
  292. data/include/Gosu/ImageData.hpp +0 -53
  293. data/include/Gosu/Inspection.hpp +0 -7
  294. data/lib/SDL2.dll +0 -0
  295. data/lib/gosu/patches.rb +0 -66
  296. data/lib/gosu/run.rb +0 -20
  297. data/lib/gosu/swig_patches.rb +0 -110
  298. data/lib64/SDL2.dll +0 -0
  299. data/src/BlockAllocator.cpp +0 -131
  300. data/src/BlockAllocator.hpp +0 -32
  301. data/src/DirectoriesApple.cpp +0 -69
  302. data/src/DirectoriesUnix.cpp +0 -46
  303. data/src/DirectoriesWin.cpp +0 -65
  304. data/src/EmptyImageData.hpp +0 -52
  305. data/src/FileUnix.cpp +0 -99
  306. data/src/FileWin.cpp +0 -88
  307. data/src/IO.cpp +0 -60
  308. data/src/Iconv.hpp +0 -51
  309. data/src/Inspection.cpp +0 -27
  310. data/src/LargeImageData.cpp +0 -215
  311. data/src/LargeImageData.hpp +0 -39
  312. data/src/Log.hpp +0 -19
  313. data/src/RubyGosu.cxx +0 -13100
  314. data/src/RubyGosu.h +0 -49
  315. data/src/WinUtility.cpp +0 -61
  316. data/src/WinUtility.hpp +0 -27
  317. /data/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
  318. /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
  319. /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
  320. /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
@@ -0,0 +1,239 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create(const char* filename, unsigned image_flags)
4
+ {
5
+ return Gosu_translate_exceptions([=] { //
6
+ return new Gosu_Image(Gosu::Image(filename, image_flags));
7
+ });
8
+ }
9
+
10
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_rect(const char* filename, //
11
+ int x, int y, int width, int height,
12
+ unsigned image_flags)
13
+ {
14
+ return Gosu_translate_exceptions([=] {
15
+ return new Gosu_Image(
16
+ Gosu::Image(filename, Gosu::Rect::xywh(x, y, width, height), image_flags));
17
+ });
18
+ }
19
+
20
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_markup(const char* markup, const char* font,
21
+ double font_height, int width,
22
+ double spacing, unsigned align,
23
+ unsigned font_flags, unsigned image_flags)
24
+ {
25
+ return Gosu_translate_exceptions([=] {
26
+ Gosu::Bitmap bitmap = Gosu::layout_markup(markup, font, font_height, spacing, width,
27
+ static_cast<Gosu::Alignment>(align), font_flags);
28
+ return new Gosu_Image(Gosu::Image(bitmap, image_flags));
29
+ });
30
+ }
31
+
32
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_text(const char* text, const char* font,
33
+ double font_height, int width, double spacing,
34
+ unsigned align, unsigned font_flags,
35
+ unsigned image_flags)
36
+ {
37
+ return Gosu_translate_exceptions([=] {
38
+ Gosu::Bitmap bitmap = Gosu::layout_text(text, font, font_height, spacing, width,
39
+ static_cast<Gosu::Alignment>(align), font_flags);
40
+ return new Gosu_Image(Gosu::Image(bitmap, image_flags));
41
+ });
42
+ }
43
+
44
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_blob(void* blob, size_t byte_count, //
45
+ int columns, int rows, //
46
+ int x, int y, int width, int height,
47
+ unsigned image_flags)
48
+ {
49
+ return Gosu_translate_exceptions([=] {
50
+ const int values = columns * rows * 4;
51
+ Gosu::Bitmap bitmap;
52
+
53
+ if (byte_count == values) {
54
+ // 32 bit per pixel, assume R8G8B8A8
55
+ bitmap = Gosu::Bitmap(columns, rows, Gosu::Buffer(blob, byte_count, nullptr));
56
+ }
57
+ else if (byte_count == values * sizeof(float)) {
58
+ bitmap.resize(columns, rows);
59
+ // 128 bit per channel, assume float/float/float/float RGBA - for Texplay compatibility.
60
+ const float* in = static_cast<const float*>(blob);
61
+ Gosu::Color::Channel* out = reinterpret_cast<Gosu::Color::Channel*>(bitmap.data());
62
+ for (int i = 0; i < values; ++i) {
63
+ out[i] = static_cast<Gosu::Color::Channel>(in[i] * 255);
64
+ }
65
+ }
66
+ else {
67
+ throw std::invalid_argument("Invalid byte_count " + std::to_string(byte_count)
68
+ + " for image of size " + std::to_string(columns) + "x"
69
+ + std::to_string(rows));
70
+ }
71
+
72
+ return new Gosu_Image(
73
+ Gosu::Image(bitmap, Gosu::Rect::xywh(x, y, width, height), image_flags));
74
+ });
75
+ }
76
+
77
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_subimage(Gosu_Image* image, int left, int top,
78
+ int width, int height)
79
+ {
80
+ return Gosu_translate_exceptions([=]() -> Gosu_Image* {
81
+ std::unique_ptr<Gosu::Drawable> drawable
82
+ = image->image.drawable().subimage(Gosu::Rect::xywh(left, top, width, height));
83
+
84
+ if (!drawable) {
85
+ return nullptr;
86
+ }
87
+
88
+ return new Gosu_Image(Gosu::Image(std::move(drawable)));
89
+ });
90
+ }
91
+
92
+ GOSU_FFI_API void Gosu_Image_create_from_tiles(const char* source, int tile_width, int tile_height,
93
+ void function(void*, Gosu_Image*), void* data,
94
+ unsigned image_flags)
95
+ {
96
+ Gosu_translate_exceptions([=] {
97
+ std::vector<Gosu::Image> gosu_images
98
+ = Gosu::load_tiles(source, tile_width, tile_height, image_flags);
99
+
100
+ for (Gosu::Image& img : gosu_images) {
101
+ function(data, new Gosu_Image(img));
102
+ }
103
+ });
104
+ }
105
+
106
+ GOSU_FFI_API void Gosu_Image_create_tiles_from_image(Gosu_Image* image, int tile_width,
107
+ int tile_height,
108
+ void function(void*, Gosu_Image*), void* data,
109
+ unsigned image_flags)
110
+ {
111
+ Gosu_translate_exceptions([=] {
112
+ std::vector<Gosu::Image> gosu_images = Gosu::load_tiles(
113
+ image->image.drawable().to_bitmap(), tile_width, tile_height, image_flags);
114
+
115
+ for (Gosu::Image& img : gosu_images) {
116
+ function(data, new Gosu_Image(img));
117
+ }
118
+ });
119
+ }
120
+
121
+ GOSU_FFI_API void Gosu_Image_destroy(Gosu_Image* image)
122
+ {
123
+ delete image;
124
+ }
125
+
126
+ // Properties
127
+
128
+ GOSU_FFI_API unsigned Gosu_Image_width(Gosu_Image* image)
129
+ {
130
+ return Gosu_translate_exceptions([=] {
131
+ return image->image.width();
132
+ });
133
+ }
134
+
135
+ GOSU_FFI_API unsigned Gosu_Image_height(Gosu_Image* image)
136
+ {
137
+ return Gosu_translate_exceptions([=] {
138
+ return image->image.height();
139
+ });
140
+ }
141
+
142
+ GOSU_FFI_API Gosu_GLTexInfo* Gosu_Image_gl_tex_info_create(Gosu_Image* image)
143
+ {
144
+ return Gosu_translate_exceptions([=]() -> Gosu_GLTexInfo* {
145
+ const Gosu::GLTexInfo* info = image->image.drawable().gl_tex_info();
146
+ if (!info) {
147
+ return nullptr;
148
+ }
149
+ return new Gosu_GLTexInfo {
150
+ .tex_name = info->tex_name,
151
+ .left = info->left,
152
+ .right = info->right,
153
+ .top = info->top,
154
+ .bottom = info->bottom,
155
+ };
156
+ });
157
+ }
158
+
159
+ GOSU_FFI_API void Gosu_Image_gl_tex_info_destroy(Gosu_GLTexInfo* gl_tex_info)
160
+ {
161
+ delete gl_tex_info;
162
+ }
163
+
164
+ // Rendering
165
+
166
+ GOSU_FFI_API bool Gosu_Image_draw(Gosu_Image* image, double x, double y, double z, double scale_x,
167
+ double scale_y, unsigned color, unsigned mode)
168
+ {
169
+ return Gosu_translate_exceptions([=] {
170
+ image->image.draw(x, y, z, scale_x, scale_y, color, static_cast<Gosu::BlendMode>(mode));
171
+ return true;
172
+ });
173
+ }
174
+
175
+ GOSU_FFI_API bool Gosu_Image_draw_quick(Gosu_Image* image, double x, double y, double z)
176
+ {
177
+ return Gosu_translate_exceptions([=] {
178
+ image->image.draw(x, y, z);
179
+ return true;
180
+ });
181
+ }
182
+
183
+ GOSU_FFI_API bool Gosu_Image_draw_rot(Gosu_Image* image, double x, double y, double z, double angle,
184
+ double center_x, double center_y, double scale_x,
185
+ double scale_y, unsigned color, unsigned mode)
186
+ {
187
+ return Gosu_translate_exceptions([=] {
188
+ image->image.draw_rot(x, y, z, angle, center_x, center_y, scale_x, scale_y, color,
189
+ static_cast<Gosu::BlendMode>(mode));
190
+ return true;
191
+ });
192
+ }
193
+
194
+ GOSU_FFI_API bool Gosu_Image_draw_rot_quick(Gosu_Image* image, double x, double y, double z,
195
+ double angle)
196
+ {
197
+ return Gosu_translate_exceptions([=] {
198
+ image->image.draw_rot(x, y, z, angle);
199
+ return true;
200
+ });
201
+ }
202
+
203
+ GOSU_FFI_API bool Gosu_Image_draw_as_quad(Gosu_Image* image, double x1, double y1, unsigned color1,
204
+ double x2, double y2, unsigned color2, double x3,
205
+ double y3, unsigned color3, double x4, double y4,
206
+ unsigned color4, double z, unsigned mode)
207
+ {
208
+ return Gosu_translate_exceptions([=] {
209
+ image->image.drawable().draw(x1, y1, color1, x2, y2, color2, x3, y3, color3, x4, y4, color4,
210
+ z, static_cast<Gosu::BlendMode>(mode));
211
+ return true;
212
+ });
213
+ }
214
+
215
+ // Image operations
216
+
217
+ GOSU_FFI_API void Gosu_Image_insert(Gosu_Image* image, Gosu_Image* source, int x, int y)
218
+ {
219
+ Gosu_translate_exceptions([=] {
220
+ Gosu::Bitmap bitmap = source->image.drawable().to_bitmap();
221
+ image->image.drawable().insert(bitmap, x, y);
222
+ });
223
+ }
224
+
225
+ GOSU_FFI_API uint8_t* Gosu_Image_to_blob(Gosu_Image* image)
226
+ {
227
+ thread_local Gosu::Bitmap bitmap;
228
+ return Gosu_translate_exceptions([=] {
229
+ bitmap = image->image.drawable().to_bitmap();
230
+ return reinterpret_cast<uint8_t*>(bitmap.data());
231
+ });
232
+ }
233
+
234
+ GOSU_FFI_API void Gosu_Image_save(Gosu_Image* image, const char* filename)
235
+ {
236
+ Gosu_translate_exceptions([=] {
237
+ Gosu::save_image_file(image->image.drawable().to_bitmap(), filename);
238
+ });
239
+ }
data/ffi/Gosu_Image.h ADDED
@@ -0,0 +1,71 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_FFI.h"
4
+ #include <stddef.h> // for size_t
5
+ #include <stdint.h>
6
+
7
+ typedef struct Gosu_Image Gosu_Image;
8
+
9
+ typedef struct Gosu_GLTexInfo
10
+ {
11
+ uint32_t tex_name;
12
+ double left, right, top, bottom;
13
+ } Gosu_GLTexInfo;
14
+
15
+ // Constructor
16
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create(const char* filename, unsigned image_flags);
17
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_rect(const char* filename, //
18
+ int x, int y, int width, int height,
19
+ unsigned image_flags);
20
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_blob(void* blob, size_t byte_count, //
21
+ int columns, int rows, //
22
+ int x, int y, int width, int height,
23
+ unsigned image_flags);
24
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_markup(const char* markup, const char* font,
25
+ double font_height, int width,
26
+ double spacing, unsigned align,
27
+ unsigned font_flags, unsigned image_flags);
28
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_text(const char* text, const char* font,
29
+ double font_height, int width, double spacing,
30
+ unsigned align, unsigned font_flags,
31
+ unsigned image_flags);
32
+ GOSU_FFI_API Gosu_Image* Gosu_Image_create_from_subimage(Gosu_Image* source, int left, int top,
33
+ int width, int height);
34
+
35
+ GOSU_FFI_API void Gosu_Image_create_from_tiles(const char* source, int tile_width, int tile_height,
36
+ void function(void* data, Gosu_Image* image),
37
+ void* data, unsigned image_flags);
38
+ GOSU_FFI_API void Gosu_Image_create_tiles_from_image(Gosu_Image* image, int tile_width,
39
+ int tile_height,
40
+ void function(void* data, Gosu_Image* image),
41
+ void* data, unsigned image_flags);
42
+
43
+ // Destructor
44
+ GOSU_FFI_API void Gosu_Image_destroy(Gosu_Image* image);
45
+
46
+ // Image properties
47
+ GOSU_FFI_API unsigned Gosu_Image_width(Gosu_Image* image);
48
+ GOSU_FFI_API unsigned Gosu_Image_height(Gosu_Image* image);
49
+
50
+ // Rendering
51
+ GOSU_FFI_API bool Gosu_Image_draw(Gosu_Image* image, double x, double y, double z, double scale_x,
52
+ double scale_y, unsigned color, unsigned mode);
53
+ // FFI only: this is a fast-path variant of Gosu_Image_draw with default arguments.
54
+ GOSU_FFI_API bool Gosu_Image_draw_quick(Gosu_Image* image, double x, double y, double z);
55
+ GOSU_FFI_API bool Gosu_Image_draw_rot(Gosu_Image* image, double x, double y, double z, double angle,
56
+ double center_x, double center_y, double scale_x,
57
+ double scale_y, unsigned color, unsigned mode);
58
+ // FFI only: this is a fast-path variant of Gosu_Image_draw_rot with default arguments.
59
+ GOSU_FFI_API bool Gosu_Image_draw_rot_quick(Gosu_Image* image, double x, double y, double z,
60
+ double angle);
61
+ GOSU_FFI_API bool Gosu_Image_draw_as_quad(Gosu_Image* image, double x1, double y1, unsigned color1,
62
+ double x2, double y2, unsigned color2, double x3,
63
+ double y3, unsigned color3, double x4, double y4,
64
+ unsigned color4, double z, unsigned mode);
65
+
66
+ // Operations
67
+ GOSU_FFI_API void Gosu_Image_insert(Gosu_Image* image, Gosu_Image* source, int x, int y);
68
+ GOSU_FFI_API void Gosu_Image_save(Gosu_Image* image, const char* filename);
69
+ GOSU_FFI_API uint8_t* Gosu_Image_to_blob(Gosu_Image* image);
70
+ GOSU_FFI_API Gosu_GLTexInfo* Gosu_Image_gl_tex_info_create(Gosu_Image* image);
71
+ GOSU_FFI_API void Gosu_Image_gl_tex_info_destroy(Gosu_GLTexInfo* tex_info);
@@ -0,0 +1,29 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API Gosu_Sample* Gosu_Sample_create(const char* filename)
4
+ {
5
+ return Gosu_translate_exceptions([=] {
6
+ return new Gosu_Sample{Gosu::Sample{filename}};
7
+ });
8
+ }
9
+
10
+ GOSU_FFI_API void Gosu_Sample_destroy(Gosu_Sample* sample)
11
+ {
12
+ delete sample;
13
+ }
14
+
15
+ GOSU_FFI_API Gosu_Channel* Gosu_Sample_play(Gosu_Sample* sample, double volume, double speed,
16
+ bool looping)
17
+ {
18
+ return Gosu_translate_exceptions([=] {
19
+ return new Gosu_Channel{sample->sample.play(volume, speed, looping)};
20
+ });
21
+ }
22
+
23
+ GOSU_FFI_API Gosu_Channel* Gosu_Sample_play_pan(Gosu_Sample* sample, double pan, double volume,
24
+ double speed, bool looping)
25
+ {
26
+ return Gosu_translate_exceptions([=] {
27
+ return new Gosu_Channel{sample->sample.play_pan(pan, volume, speed, looping)};
28
+ });
29
+ }
data/ffi/Gosu_Sample.h ADDED
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_Channel.h"
4
+ #include "Gosu_FFI.h"
5
+
6
+ typedef struct Gosu_Sample Gosu_Sample;
7
+
8
+ GOSU_FFI_API Gosu_Sample* Gosu_Sample_create(const char* filename);
9
+ GOSU_FFI_API void Gosu_Sample_destroy(Gosu_Sample* sample);
10
+
11
+ GOSU_FFI_API Gosu_Channel* Gosu_Sample_play(Gosu_Sample* sample, double volume, double speed,
12
+ bool looping);
13
+ GOSU_FFI_API Gosu_Channel* Gosu_Sample_play_pan(Gosu_Sample* sample, double pan, double volume,
14
+ double speed, bool looping);
data/ffi/Gosu_Song.cpp ADDED
@@ -0,0 +1,69 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API Gosu_Song* Gosu_Song_create(const char* filename)
4
+ {
5
+ return Gosu_translate_exceptions([=] {
6
+ return new Gosu_Song{filename};
7
+ });
8
+ }
9
+
10
+ GOSU_FFI_API void Gosu_Song_destroy(Gosu_Song* song)
11
+ {
12
+ delete song;
13
+ }
14
+
15
+ GOSU_FFI_API void Gosu_Song_play(Gosu_Song* song, bool looping)
16
+ {
17
+ Gosu_translate_exceptions([=] {
18
+ song->play(looping);
19
+ });
20
+ }
21
+
22
+ GOSU_FFI_API bool Gosu_Song_playing(Gosu_Song* song)
23
+ {
24
+ return Gosu_translate_exceptions([=] {
25
+ return song->playing();
26
+ });
27
+ }
28
+
29
+ GOSU_FFI_API void Gosu_Song_pause(Gosu_Song* song)
30
+ {
31
+ Gosu_translate_exceptions([=] {
32
+ song->pause();
33
+ });
34
+ }
35
+
36
+ GOSU_FFI_API bool Gosu_Song_paused(Gosu_Song* song)
37
+ {
38
+ return Gosu_translate_exceptions([=] {
39
+ return song->paused();
40
+ });
41
+ }
42
+
43
+ GOSU_FFI_API void Gosu_Song_stop(Gosu_Song* song)
44
+ {
45
+ Gosu_translate_exceptions([=] {
46
+ song->stop();
47
+ });
48
+ }
49
+
50
+ GOSU_FFI_API double Gosu_Song_volume(Gosu_Song* song)
51
+ {
52
+ return Gosu_translate_exceptions([=] {
53
+ return song->volume();
54
+ });
55
+ }
56
+
57
+ GOSU_FFI_API void Gosu_Song_set_volume(Gosu_Song* song, double volume)
58
+ {
59
+ Gosu_translate_exceptions([=] {
60
+ return song->set_volume(volume);
61
+ });
62
+ }
63
+
64
+ GOSU_FFI_API Gosu_Song* Gosu_Song_current_song(void)
65
+ {
66
+ return Gosu_translate_exceptions([=] {
67
+ return reinterpret_cast<Gosu_Song*>(Gosu::Song::current_song());
68
+ });
69
+ }
data/ffi/Gosu_Song.h ADDED
@@ -0,0 +1,18 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_FFI.h"
4
+
5
+ typedef struct Gosu_Song Gosu_Song;
6
+
7
+ GOSU_FFI_API Gosu_Song* Gosu_Song_create(const char* filename);
8
+ GOSU_FFI_API void Gosu_Song_destroy(Gosu_Song* song);
9
+
10
+ GOSU_FFI_API void Gosu_Song_pause(Gosu_Song* song);
11
+ GOSU_FFI_API bool Gosu_Song_paused(Gosu_Song* song);
12
+ GOSU_FFI_API void Gosu_Song_play(Gosu_Song* song, bool looping);
13
+ GOSU_FFI_API bool Gosu_Song_playing(Gosu_Song* song);
14
+ GOSU_FFI_API void Gosu_Song_stop(Gosu_Song* song);
15
+ GOSU_FFI_API double Gosu_Song_volume(Gosu_Song* song);
16
+ GOSU_FFI_API void Gosu_Song_set_volume(Gosu_Song* song, double volume);
17
+
18
+ GOSU_FFI_API Gosu_Song* Gosu_Song_current_song(void);
@@ -0,0 +1,94 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API Gosu_TextInput* Gosu_TextInput_create()
4
+ {
5
+ return Gosu_translate_exceptions([=] {
6
+ return new Gosu_TextInput{};
7
+ });
8
+ }
9
+
10
+ GOSU_FFI_API void Gosu_TextInput_destroy(Gosu_TextInput* text_input)
11
+ {
12
+ delete text_input;
13
+ }
14
+
15
+ GOSU_FFI_API const char* Gosu_TextInput_text(Gosu_TextInput* text_input)
16
+ {
17
+ static thread_local std::string text;
18
+
19
+ return Gosu_translate_exceptions([=] {
20
+ text = text_input->text();
21
+ return text.c_str();
22
+ });
23
+ }
24
+
25
+ GOSU_FFI_API void Gosu_TextInput_set_text(Gosu_TextInput* text_input, const char* text)
26
+ {
27
+ Gosu_translate_exceptions([=] {
28
+ text_input->set_text(text);
29
+ });
30
+ }
31
+
32
+ GOSU_FFI_API int Gosu_TextInput_caret_pos(Gosu_TextInput* text_input)
33
+ {
34
+ return Gosu_translate_exceptions([=] {
35
+ return text_input->caret_pos();
36
+ });
37
+ }
38
+
39
+ GOSU_FFI_API void Gosu_TextInput_set_caret_pos(Gosu_TextInput* text_input, int pos)
40
+ {
41
+ Gosu_translate_exceptions([=] {
42
+ text_input->set_caret_pos(pos);
43
+ });
44
+ }
45
+
46
+ GOSU_FFI_API int Gosu_TextInput_selection_start(Gosu_TextInput* text_input)
47
+ {
48
+ return Gosu_translate_exceptions([=] {
49
+ return text_input->selection_start();
50
+ });
51
+ }
52
+
53
+ GOSU_FFI_API void Gosu_TextInput_set_selection_start(Gosu_TextInput* text_input, int pos)
54
+ {
55
+ Gosu_translate_exceptions([=] {
56
+ text_input->set_selection_start(pos);
57
+ });
58
+ }
59
+
60
+ GOSU_FFI_API void Gosu_TextInput_set_filter(Gosu_TextInput* text_input,
61
+ void function(void*, const char*), void* data)
62
+ {
63
+ Gosu_translate_exceptions([=] {
64
+ text_input->filter_callback = [=](const char* text) { function(data, text); };
65
+ });
66
+ }
67
+
68
+ GOSU_FFI_API void Gosu_TextInput_set_filter_result(Gosu_TextInput* text_input, const char* result)
69
+ {
70
+ Gosu_translate_exceptions([=] {
71
+ text_input->filter_result = result;
72
+ });
73
+ }
74
+
75
+ GOSU_FFI_API void Gosu_TextInput_insert_text(Gosu_TextInput* text_input, const char* text)
76
+ {
77
+ Gosu_translate_exceptions([=] {
78
+ text_input->insert_text(text);
79
+ });
80
+ }
81
+
82
+ GOSU_FFI_API void Gosu_TextInput_delete_backward(Gosu_TextInput* text_input)
83
+ {
84
+ Gosu_translate_exceptions([=] {
85
+ text_input->delete_backward();
86
+ });
87
+ }
88
+
89
+ GOSU_FFI_API void Gosu_TextInput_delete_forward(Gosu_TextInput* text_input)
90
+ {
91
+ Gosu_translate_exceptions([=] {
92
+ text_input->delete_forward();
93
+ });
94
+ }
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_FFI.h"
4
+
5
+ typedef struct Gosu_TextInput Gosu_TextInput;
6
+
7
+ GOSU_FFI_API Gosu_TextInput* Gosu_TextInput_create(void);
8
+ GOSU_FFI_API void Gosu_TextInput_destroy(Gosu_TextInput* text_input);
9
+
10
+ GOSU_FFI_API const char* Gosu_TextInput_text(Gosu_TextInput* text_input);
11
+ GOSU_FFI_API void Gosu_TextInput_set_text(Gosu_TextInput* text_input, const char* text);
12
+
13
+ GOSU_FFI_API int Gosu_TextInput_caret_pos(Gosu_TextInput* text_input);
14
+ GOSU_FFI_API void Gosu_TextInput_set_caret_pos(Gosu_TextInput* text_input, int pos);
15
+
16
+ GOSU_FFI_API int Gosu_TextInput_selection_start(Gosu_TextInput* text_input);
17
+ GOSU_FFI_API void Gosu_TextInput_set_selection_start(Gosu_TextInput* text_input, int pos);
18
+
19
+ GOSU_FFI_API void Gosu_TextInput_set_filter(Gosu_TextInput* text_input,
20
+ void function(void* data, const char* text),
21
+ void* data);
22
+ GOSU_FFI_API void Gosu_TextInput_set_filter_result(Gosu_TextInput* text_input, const char* result);
23
+ GOSU_FFI_API void Gosu_TextInput_insert_text(Gosu_TextInput* text_input, const char* text);
24
+ GOSU_FFI_API void Gosu_TextInput_delete_backward(Gosu_TextInput* text_input);
25
+ GOSU_FFI_API void Gosu_TextInput_delete_forward(Gosu_TextInput* text_input);