ruby2d 0.10.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (387) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/SDL2/SDL.h +108 -14
  3. data/assets/include/SDL2/SDL_assert.h +81 -50
  4. data/assets/include/SDL2/SDL_atomic.h +135 -35
  5. data/assets/include/SDL2/SDL_audio.h +960 -355
  6. data/assets/include/SDL2/SDL_bits.h +11 -6
  7. data/assets/include/SDL2/SDL_blendmode.h +91 -14
  8. data/assets/include/SDL2/SDL_clipboard.h +30 -7
  9. data/assets/include/SDL2/SDL_config.h +3 -1
  10. data/assets/include/SDL2/SDL_config_android.h +11 -1
  11. data/assets/include/SDL2/SDL_config_emscripten.h +216 -0
  12. data/assets/include/SDL2/SDL_config_iphoneos.h +9 -1
  13. data/assets/include/SDL2/SDL_config_macosx.h +16 -2
  14. data/assets/include/SDL2/SDL_config_minimal.h +4 -1
  15. data/assets/include/SDL2/SDL_config_os2.h +37 -20
  16. data/assets/include/SDL2/SDL_config_pandora.h +6 -1
  17. data/assets/include/SDL2/SDL_config_psp.h +8 -8
  18. data/assets/include/SDL2/SDL_config_windows.h +39 -22
  19. data/assets/include/SDL2/SDL_config_winrt.h +23 -8
  20. data/assets/include/SDL2/SDL_config_wiz.h +6 -1
  21. data/assets/include/SDL2/SDL_copying.h +1 -1
  22. data/assets/include/SDL2/SDL_cpuinfo.h +331 -71
  23. data/assets/include/SDL2/SDL_egl.h +906 -280
  24. data/assets/include/SDL2/SDL_endian.h +101 -47
  25. data/assets/include/SDL2/SDL_error.h +70 -19
  26. data/assets/include/SDL2/SDL_events.h +387 -79
  27. data/assets/include/SDL2/SDL_filesystem.h +73 -64
  28. data/assets/include/SDL2/SDL_gamecontroller.h +585 -125
  29. data/assets/include/SDL2/SDL_gesture.h +36 -6
  30. data/assets/include/SDL2/SDL_haptic.h +304 -210
  31. data/assets/include/SDL2/SDL_hidapi.h +451 -0
  32. data/assets/include/SDL2/SDL_hints.h +1286 -897
  33. data/assets/include/SDL2/SDL_joystick.h +577 -130
  34. data/assets/include/SDL2/SDL_keyboard.h +162 -63
  35. data/assets/include/SDL2/SDL_keycode.h +7 -5
  36. data/assets/include/SDL2/SDL_loadso.h +42 -8
  37. data/assets/include/SDL2/SDL_locale.h +34 -32
  38. data/assets/include/SDL2/SDL_log.h +212 -19
  39. data/assets/include/SDL2/SDL_main.h +72 -17
  40. data/assets/include/SDL2/SDL_messagebox.h +70 -23
  41. data/assets/include/SDL2/SDL_metal.h +27 -32
  42. data/assets/include/SDL2/SDL_misc.h +19 -15
  43. data/assets/include/SDL2/SDL_mouse.h +262 -110
  44. data/assets/include/SDL2/SDL_mutex.h +286 -66
  45. data/assets/include/SDL2/SDL_name.h +1 -1
  46. data/assets/include/SDL2/SDL_opengl.h +1 -1
  47. data/assets/include/SDL2/SDL_opengles.h +1 -1
  48. data/assets/include/SDL2/SDL_opengles2.h +2 -2
  49. data/assets/include/SDL2/SDL_pixels.h +199 -34
  50. data/assets/include/SDL2/SDL_platform.h +39 -2
  51. data/assets/include/SDL2/SDL_power.h +23 -10
  52. data/assets/include/SDL2/SDL_quit.h +1 -1
  53. data/assets/include/SDL2/SDL_rect.h +78 -28
  54. data/assets/include/SDL2/SDL_render.h +1204 -472
  55. data/assets/include/SDL2/SDL_revision.h +2 -2
  56. data/assets/include/SDL2/SDL_rwops.h +605 -33
  57. data/assets/include/SDL2/SDL_scancode.h +1 -1
  58. data/assets/include/SDL2/SDL_sensor.h +76 -42
  59. data/assets/include/SDL2/SDL_shape.h +38 -27
  60. data/assets/include/SDL2/SDL_stdinc.h +96 -24
  61. data/assets/include/SDL2/SDL_surface.h +571 -139
  62. data/assets/include/SDL2/SDL_system.h +339 -101
  63. data/assets/include/SDL2/SDL_syswm.h +50 -20
  64. data/assets/include/SDL2/SDL_test.h +1 -1
  65. data/assets/include/SDL2/SDL_test_assert.h +2 -2
  66. data/assets/include/SDL2/SDL_test_common.h +23 -6
  67. data/assets/include/SDL2/SDL_test_compare.h +1 -1
  68. data/assets/include/SDL2/SDL_test_crc32.h +1 -1
  69. data/assets/include/SDL2/SDL_test_font.h +3 -3
  70. data/assets/include/SDL2/SDL_test_fuzzer.h +28 -26
  71. data/assets/include/SDL2/SDL_test_harness.h +6 -6
  72. data/assets/include/SDL2/SDL_test_images.h +1 -1
  73. data/assets/include/SDL2/SDL_test_log.h +1 -1
  74. data/assets/include/SDL2/SDL_test_md5.h +1 -1
  75. data/assets/include/SDL2/SDL_test_memory.h +1 -1
  76. data/assets/include/SDL2/SDL_test_random.h +2 -2
  77. data/assets/include/SDL2/SDL_thread.h +226 -128
  78. data/assets/include/SDL2/SDL_timer.h +129 -22
  79. data/assets/include/SDL2/SDL_touch.h +48 -8
  80. data/assets/include/SDL2/SDL_ttf.h +102 -9
  81. data/assets/include/SDL2/SDL_types.h +1 -1
  82. data/assets/include/SDL2/SDL_version.h +72 -46
  83. data/assets/include/SDL2/SDL_video.h +1266 -460
  84. data/assets/include/SDL2/SDL_vulkan.h +100 -161
  85. data/assets/include/SDL2/begin_code.h +22 -1
  86. data/assets/include/SDL2/close_code.h +1 -1
  87. data/assets/include/mrbconf.h +234 -0
  88. data/assets/include/mruby/array.h +317 -0
  89. data/assets/include/mruby/boxing_nan.h +130 -0
  90. data/assets/include/mruby/boxing_no.h +58 -0
  91. data/assets/include/mruby/boxing_word.h +205 -0
  92. data/assets/include/mruby/class.h +108 -0
  93. data/assets/include/mruby/common.h +92 -0
  94. data/assets/include/mruby/compile.h +210 -0
  95. data/assets/include/mruby/data.h +76 -0
  96. data/assets/include/mruby/debug.h +66 -0
  97. data/assets/include/mruby/dump.h +158 -0
  98. data/assets/include/mruby/endian.h +44 -0
  99. data/assets/include/mruby/error.h +137 -0
  100. data/assets/include/mruby/gc.h +92 -0
  101. data/assets/include/mruby/hash.h +242 -0
  102. data/assets/include/mruby/irep.h +147 -0
  103. data/assets/include/mruby/istruct.h +50 -0
  104. data/assets/include/mruby/khash.h +284 -0
  105. data/assets/include/mruby/numeric.h +169 -0
  106. data/assets/include/mruby/object.h +43 -0
  107. data/assets/include/mruby/opcode.h +43 -0
  108. data/assets/include/mruby/ops.h +122 -0
  109. data/assets/include/mruby/presym/disable.h +70 -0
  110. data/assets/include/mruby/presym/enable.h +37 -0
  111. data/assets/include/mruby/presym/scanning.h +73 -0
  112. data/assets/include/mruby/presym.h +40 -0
  113. data/assets/include/mruby/proc.h +209 -0
  114. data/assets/include/mruby/range.h +79 -0
  115. data/assets/include/mruby/re.h +16 -0
  116. data/assets/include/mruby/string.h +469 -0
  117. data/assets/include/mruby/throw.h +66 -0
  118. data/assets/include/mruby/value.h +400 -0
  119. data/assets/include/mruby/variable.h +140 -0
  120. data/assets/include/mruby/version.h +143 -0
  121. data/assets/include/mruby.h +1444 -0
  122. data/assets/macos/universal/bin/mrbc +0 -0
  123. data/assets/macos/universal/lib/libFLAC.a +0 -0
  124. data/assets/macos/universal/lib/libSDL2.a +0 -0
  125. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  126. data/assets/macos/{lib → universal/lib}/libSDL2_mixer.a +0 -0
  127. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  128. data/assets/macos/universal/lib/libfreetype.a +0 -0
  129. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  130. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  131. data/assets/macos/universal/lib/libjpeg.a +0 -0
  132. data/assets/macos/universal/lib/libmodplug.a +0 -0
  133. data/assets/macos/{lib → universal/lib}/libmpg123.a +0 -0
  134. data/assets/{mingw/lib/libSDL2.a → macos/universal/lib/libmruby.a} +0 -0
  135. data/assets/macos/{lib → universal/lib}/libogg.a +0 -0
  136. data/assets/macos/universal/lib/libpng16.a +0 -0
  137. data/assets/macos/universal/lib/libtiff.a +0 -0
  138. data/assets/macos/universal/lib/libvorbis.a +0 -0
  139. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  140. data/assets/macos/universal/lib/libwebp.a +0 -0
  141. data/assets/test_media/README.md +3 -0
  142. data/assets/test_media/bitstream_vera/COPYRIGHT.txt +124 -0
  143. data/assets/test_media/bitstream_vera/vera.ttf +0 -0
  144. data/assets/test_media/boom.png +0 -0
  145. data/assets/test_media/coin.png +0 -0
  146. data/assets/test_media/colors.png +0 -0
  147. data/assets/test_media/controller.png +0 -0
  148. data/assets/test_media/dial.wav +0 -0
  149. data/assets/test_media/hero.png +0 -0
  150. data/assets/test_media/image.bmp +0 -0
  151. data/assets/test_media/image.jpg +0 -0
  152. data/assets/test_media/image.png +0 -0
  153. data/assets/test_media/music.flac +0 -0
  154. data/assets/test_media/music.mp3 +0 -0
  155. data/assets/test_media/music.ogg +0 -0
  156. data/assets/test_media/music.wav +0 -0
  157. data/assets/test_media/originals/boom.pxm +0 -0
  158. data/assets/test_media/originals/coin.pxm +0 -0
  159. data/assets/test_media/originals/controller.sketch +0 -0
  160. data/assets/test_media/originals/hero.pxm +0 -0
  161. data/assets/test_media/originals/image.pxm +0 -0
  162. data/assets/test_media/originals/music.caf +0 -0
  163. data/assets/test_media/originals/texture_atlas.pxm +0 -0
  164. data/assets/test_media/rondo_alla_turka.ogg +0 -0
  165. data/assets/test_media/sound.flac +0 -0
  166. data/assets/test_media/sound.mp3 +0 -0
  167. data/assets/test_media/sound.ogg +0 -0
  168. data/assets/test_media/sound.wav +0 -0
  169. data/assets/test_media/sprite_sheet.png +0 -0
  170. data/assets/test_media/texture_atlas.png +0 -0
  171. data/assets/wasm/build_config.rb +13 -0
  172. data/assets/wasm/libmruby.a +0 -0
  173. data/assets/wasm/template.html +17 -0
  174. data/assets/windows/glew/README.md +10 -0
  175. data/assets/windows/glew/glew.h +23686 -0
  176. data/assets/{mingw/lib → windows/glew}/libglew32.a +0 -0
  177. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  178. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  179. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  180. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  181. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  182. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  183. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  184. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  185. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  186. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  187. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  188. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  189. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  190. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  191. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  192. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  193. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  194. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  195. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  196. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  197. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  198. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  199. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  200. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  201. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  202. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  203. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  204. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  205. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  206. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  207. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  208. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  209. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  210. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  211. data/assets/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
  212. data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
  213. data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
  214. data/assets/{ios → xcode/ios}/Info.plist +0 -0
  215. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
  216. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
  217. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  218. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  219. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  220. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
  221. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
  222. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
  223. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
  224. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
  225. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
  226. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
  227. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
  228. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
  229. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
  230. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  231. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
  232. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  233. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
  234. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  235. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
  236. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
  237. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
  238. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
  239. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
  240. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
  241. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
  242. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
  243. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
  244. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
  245. data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
  246. data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
  247. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
  248. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  249. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  250. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  251. data/assets/{ios → xcode/ios}/main.c +0 -0
  252. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  253. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
  254. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
  255. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  256. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
  257. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  258. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  259. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  260. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
  261. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
  262. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  263. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
  264. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  265. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  266. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
  267. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
  268. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
  269. data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
  270. data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
  271. data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
  272. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
  273. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
  274. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  275. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  276. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  277. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
  278. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
  279. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
  280. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
  281. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
  282. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
  283. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
  284. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
  285. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
  286. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
  287. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  288. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
  289. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  290. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
  291. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  292. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
  293. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
  294. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
  295. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
  296. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
  297. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
  298. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
  299. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
  300. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
  301. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
  302. data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
  303. data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
  304. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
  305. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  306. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  307. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  308. data/assets/{tvos → xcode/tvos}/main.c +0 -0
  309. data/bin/ruby2d +3 -4
  310. data/ext/ruby2d/extconf.rb +68 -46
  311. data/ext/ruby2d/font.c +35 -0
  312. data/ext/ruby2d/gl.c +9 -58
  313. data/ext/ruby2d/gl2.c +8 -83
  314. data/ext/ruby2d/gl3.c +57 -116
  315. data/ext/ruby2d/gles.c +130 -151
  316. data/ext/ruby2d/image.c +16 -96
  317. data/ext/ruby2d/ruby2d.c +265 -298
  318. data/ext/ruby2d/ruby2d.h +69 -159
  319. data/ext/ruby2d/sound.c +1 -1
  320. data/ext/ruby2d/text.c +20 -114
  321. data/ext/ruby2d/window.c +257 -219
  322. data/lib/ruby2d/circle.rb +3 -1
  323. data/lib/ruby2d/cli/build.rb +239 -59
  324. data/lib/ruby2d/cli/colorize.rb +5 -4
  325. data/lib/ruby2d/cli/platform.rb +17 -0
  326. data/lib/ruby2d/font.rb +26 -1
  327. data/lib/ruby2d/image.rb +22 -17
  328. data/lib/ruby2d/line.rb +3 -1
  329. data/lib/ruby2d/quad.rb +3 -1
  330. data/lib/ruby2d/rectangle.rb +1 -1
  331. data/lib/ruby2d/renderable.rb +0 -12
  332. data/lib/ruby2d/sound.rb +25 -0
  333. data/lib/ruby2d/sprite.rb +44 -89
  334. data/lib/ruby2d/square.rb +1 -1
  335. data/lib/ruby2d/text.rb +40 -20
  336. data/lib/ruby2d/texture.rb +28 -0
  337. data/lib/ruby2d/tileset.rb +47 -28
  338. data/lib/ruby2d/triangle.rb +3 -1
  339. data/lib/ruby2d/version.rb +1 -1
  340. data/lib/ruby2d/vertices.rb +89 -0
  341. data/lib/ruby2d/window.rb +13 -3
  342. data/lib/ruby2d.rb +16 -20
  343. metadata +249 -153
  344. data/assets/README.md +0 -22
  345. data/assets/Rakefile +0 -85
  346. data/assets/macos/lib/libFLAC.a +0 -0
  347. data/assets/macos/lib/libSDL2.a +0 -0
  348. data/assets/macos/lib/libSDL2_image.a +0 -0
  349. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  350. data/assets/macos/lib/libfreetype.a +0 -0
  351. data/assets/macos/lib/libjpeg.a +0 -0
  352. data/assets/macos/lib/libpng16.a +0 -0
  353. data/assets/macos/lib/libtiff.a +0 -0
  354. data/assets/macos/lib/libvorbis.a +0 -0
  355. data/assets/macos/lib/libvorbisfile.a +0 -0
  356. data/assets/macos/lib/libwebp.a +0 -0
  357. data/assets/mingw/bin/SDL2.dll +0 -0
  358. data/assets/mingw/bin/SDL2_image.dll +0 -0
  359. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  360. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  361. data/assets/mingw/bin/glew32.dll +0 -0
  362. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  363. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  364. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  365. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  366. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  367. data/assets/mingw/bin/libogg-0.dll +0 -0
  368. data/assets/mingw/bin/libopus-0.dll +0 -0
  369. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  370. data/assets/mingw/bin/libpng16-16.dll +0 -0
  371. data/assets/mingw/bin/libtiff-5.dll +0 -0
  372. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  373. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  374. data/assets/mingw/bin/libwebp-7.dll +0 -0
  375. data/assets/mingw/bin/zlib1.dll +0 -0
  376. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  377. data/assets/mingw/lib/libSDL2_image.a +0 -0
  378. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  379. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  380. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  381. data/assets/mingw/lib/libSDL2_test.a +0 -0
  382. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  383. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  384. data/assets/mingw/lib/libSDL2main.a +0 -0
  385. data/assets/mingw/lib/libglew32.dll.a +0 -0
  386. data/ext/ruby2d/sprite.c +0 -147
  387. data/ext/ruby2d/tileset.c +0 -30
data/ext/ruby2d/ruby2d.c CHANGED
@@ -1,5 +1,9 @@
1
1
  // Native C extension for Ruby and MRuby
2
2
 
3
+ #ifndef RUBY2D_IOS_TVOS
4
+ #define RUBY2D_IOS_TVOS 0
5
+ #endif
6
+
3
7
  // Ruby 2D includes
4
8
  #if RUBY2D_IOS_TVOS
5
9
  #else
@@ -59,6 +63,8 @@
59
63
  #define r_str_new(str) mrb_str_new(mrb, str, strlen(str))
60
64
  #define r_test(val) (mrb_test(val) == true)
61
65
  #define r_ary_entry(ary, pos) mrb_ary_entry(ary, pos)
66
+ #define r_ary_new() mrb_ary_new(mrb)
67
+ #define r_ary_push(self, val) mrb_ary_push(mrb, self, val)
62
68
  #define r_data_wrap_struct(name, data) mrb_obj_value(Data_Wrap_Struct(mrb, mrb->object_class, &name##_data_type, data))
63
69
  #define r_data_get_struct(self, var, mrb_type, rb_type, data) Data_Get_Struct(mrb, r_iv_get(self, var), mrb_type, data)
64
70
  #define r_define_module(name) mrb_define_module(mrb, name)
@@ -82,6 +88,8 @@
82
88
  #define r_str_new(str) rb_str_new2(str)
83
89
  #define r_test(val) (val != Qfalse && val != Qnil)
84
90
  #define r_ary_entry(ary, pos) rb_ary_entry(ary, pos)
91
+ #define r_ary_new() rb_ary_new()
92
+ #define r_ary_push(self, val) rb_ary_push(self, val)
85
93
  #define r_data_wrap_struct(name, data) Data_Wrap_Struct(rb_cObject, NULL, (free_##name), data)
86
94
  #define r_data_get_struct(self, var, mrb_type, rb_type, data) Data_Get_Struct(r_iv_get(self, var), rb_type, data)
87
95
  #define r_define_module(name) rb_define_module(name)
@@ -103,23 +111,11 @@
103
111
  static R_VAL ruby2d_window;
104
112
 
105
113
  // Ruby 2D native window
106
- static R2D_Window *window;
114
+ static R2D_Window *ruby2d_c_window;
107
115
 
108
116
 
109
117
  // Method signatures and structures for Ruby 2D classes
110
118
  #if MRUBY
111
- static void free_image(mrb_state *mrb, void *p_);
112
- static const struct mrb_data_type image_data_type = {
113
- "image", free_image
114
- };
115
- static void free_sprite(mrb_state *mrb, void *p_);
116
- static const struct mrb_data_type sprite_data_type = {
117
- "sprite", free_sprite
118
- };
119
- static void free_text(mrb_state *mrb, void *p_);
120
- static const struct mrb_data_type text_data_type = {
121
- "text", free_text
122
- };
123
119
  static void free_sound(mrb_state *mrb, void *p_);
124
120
  static const struct mrb_data_type sound_data_type = {
125
121
  "sound", free_sound
@@ -128,12 +124,19 @@ static R2D_Window *window;
128
124
  static const struct mrb_data_type music_data_type = {
129
125
  "music", free_music
130
126
  };
127
+ static void free_font(mrb_state *mrb, void *p_);
128
+ static const struct mrb_data_type font_data_type = {
129
+ "font", free_font
130
+ };
131
+ static void free_surface(mrb_state *mrb, void *p_);
132
+ static const struct mrb_data_type surface_data_type = {
133
+ "surface", free_surface
134
+ };
131
135
  #else
132
- static void free_image(R2D_Image *img);
133
- static void free_sprite(R2D_Sprite *spr);
134
- static void free_text(R2D_Text *txt);
135
136
  static void free_sound(R2D_Sound *snd);
136
137
  static void free_music(R2D_Music *mus);
138
+ static void free_font(TTF_Font *font);
139
+ static void free_surface(SDL_Surface *surface);
137
140
  #endif
138
141
 
139
142
 
@@ -141,7 +144,7 @@ static R2D_Window *window;
141
144
  * Function pointer to free the Ruby 2D native window
142
145
  */
143
146
  static void free_window() {
144
- R2D_FreeWindow(window);
147
+ R2D_FreeWindow(ruby2d_c_window);
145
148
  }
146
149
 
147
150
 
@@ -368,350 +371,232 @@ static R_VAL ruby2d_circle_ext_draw(R_VAL self, R_VAL a) {
368
371
 
369
372
 
370
373
  /*
371
- * Ruby2D::Image#ext_init
372
- * Initialize image structure data
374
+ * Ruby2D::Image#ext_load_image
375
+ * Create an SDL surface from an image path, return the surface, width, and height
373
376
  */
374
377
  #if MRUBY
375
- static R_VAL ruby2d_image_ext_init(mrb_state* mrb, R_VAL self) {
378
+ static R_VAL ruby2d_image_ext_load_image(mrb_state* mrb, R_VAL self) {
376
379
  mrb_value path;
377
380
  mrb_get_args(mrb, "o", &path);
378
381
  #else
379
- static R_VAL ruby2d_image_ext_init(R_VAL self, R_VAL path) {
380
- #endif
381
- R2D_Image *img = R2D_CreateImage(RSTRING_PTR(path));
382
- if (!img) return R_FALSE;
383
-
384
- // Get width and height from Ruby class. If set, use it, else choose the
385
- // native dimensions of the image.
386
- R_VAL w = r_iv_get(self, "@width");
387
- R_VAL h = r_iv_get(self, "@height");
388
- r_iv_set(self, "@width" , r_test(w) ? w : INT2NUM(img->width));
389
- r_iv_set(self, "@height", r_test(h) ? h : INT2NUM(img->height));
390
- r_iv_set(self, "@data", r_data_wrap_struct(image, img));
391
-
392
- return R_TRUE;
393
- }
394
-
395
-
396
- /*
397
- * Ruby2D::Image#self.ext_draw
398
- */
399
- #if MRUBY
400
- static R_VAL ruby2d_image_ext_draw(mrb_state* mrb, R_VAL self) {
401
- mrb_value a;
402
- mrb_get_args(mrb, "o", &a);
403
- #else
404
- static R_VAL ruby2d_image_ext_draw(R_VAL self, R_VAL a) {
382
+ static R_VAL ruby2d_image_ext_load_image(R_VAL self, R_VAL path) {
405
383
  #endif
406
- // `a` is the array representing the image
407
-
408
- R2D_Image *img;
409
- r_data_get_struct(r_ary_entry(a, 0), "@data", &image_data_type, R2D_Image, img);
384
+ R2D_Init();
410
385
 
411
- img->x = NUM2DBL(r_ary_entry(a, 1));
412
- img->y = NUM2DBL(r_ary_entry(a, 2));
386
+ R_VAL result = r_ary_new();
413
387
 
414
- R_VAL w = r_ary_entry(a, 3);
415
- R_VAL h = r_ary_entry(a, 4);
416
- if (r_test(w)) img->width = NUM2INT(w);
417
- if (r_test(h)) img->height = NUM2INT(h);
388
+ SDL_Surface *surface = R2D_CreateImageSurface(RSTRING_PTR(path));
389
+ R2D_ImageConvertToRGB(surface);
418
390
 
419
- R2D_RotateImage(img, NUM2DBL(r_ary_entry(a, 5)), R2D_CENTER);
391
+ r_ary_push(result, r_data_wrap_struct(surface, surface));
392
+ r_ary_push(result, INT2NUM(surface->w));
393
+ r_ary_push(result, INT2NUM(surface->h));
420
394
 
421
- img->color.r = NUM2DBL(r_ary_entry(a, 6));
422
- img->color.g = NUM2DBL(r_ary_entry(a, 7));
423
- img->color.b = NUM2DBL(r_ary_entry(a, 8));
424
- img->color.a = NUM2DBL(r_ary_entry(a, 9));
425
-
426
- R2D_DrawImage(img);
427
- return R_NIL;
395
+ return result;
428
396
  }
429
397
 
430
398
 
431
399
  /*
432
- * Free image structure attached to Ruby 2D `Image` class
400
+ * Ruby2D::Text#ext_load_text
433
401
  */
434
402
  #if MRUBY
435
- static void free_image(mrb_state *mrb, void *p_) {
436
- R2D_Image *img = (R2D_Image *)p_;
403
+ static R_VAL ruby2d_text_ext_load_text(mrb_state* mrb, R_VAL self) {
404
+ mrb_value font, message;
405
+ mrb_get_args(mrb, "oo", &font, &message);
437
406
  #else
438
- static void free_image(R2D_Image *img) {
407
+ static R_VAL ruby2d_text_ext_load_text(R_VAL self, R_VAL font, R_VAL message) {
439
408
  #endif
440
- R2D_FreeImage(img);
441
- }
409
+ R2D_Init();
442
410
 
411
+ R_VAL result = r_ary_new();
412
+
413
+ TTF_Font *ttf_font;
443
414
 
444
- /*
445
- * Ruby2D::Sprite#ext_init
446
- * Initialize sprite structure data
447
- */
448
415
  #if MRUBY
449
- static R_VAL ruby2d_sprite_ext_init(mrb_state* mrb, R_VAL self) {
450
- mrb_value path;
451
- mrb_get_args(mrb, "o", &path);
416
+ Data_Get_Struct(mrb, font, &font_data_type, ttf_font);
452
417
  #else
453
- static R_VAL ruby2d_sprite_ext_init(R_VAL self, R_VAL path) {
418
+ Data_Get_Struct(font, TTF_Font, ttf_font);
454
419
  #endif
455
- R2D_Sprite *spr = R2D_CreateSprite(RSTRING_PTR(path));
456
- if (!spr) return R_FALSE;
457
420
 
458
- r_iv_set(self, "@img_width" , INT2NUM(spr->width));
459
- r_iv_set(self, "@img_height", INT2NUM(spr->height));
460
- r_iv_set(self, "@data", r_data_wrap_struct(sprite, spr));
421
+ SDL_Surface *surface = R2D_TextCreateSurface(ttf_font, RSTRING_PTR(message));
422
+ if (!surface) {
423
+ return result;
424
+ }
425
+
426
+ r_ary_push(result, r_data_wrap_struct(surface, surface));
427
+ r_ary_push(result, INT2NUM(surface->w));
428
+ r_ary_push(result, INT2NUM(surface->h));
461
429
 
462
- return R_TRUE;
430
+ return result;
463
431
  }
464
432
 
465
433
 
466
434
  /*
467
- * Ruby2D::Sprite#ext_draw
435
+ * Ruby2D::Texture#ext_create
468
436
  */
469
437
  #if MRUBY
470
- static R_VAL ruby2d_sprite_ext_draw(mrb_state* mrb, R_VAL self) {
471
- mrb_value a;
472
- mrb_get_args(mrb, "o", &a);
438
+ static R_VAL ruby2d_texture_ext_create(mrb_state* mrb, R_VAL self) {
439
+ mrb_value rubySurface, width, height;
440
+ mrb_get_args(mrb, "ooo", &rubySurface, &width, &height);
473
441
  #else
474
- static R_VAL ruby2d_sprite_ext_draw(R_VAL self, R_VAL a) {
442
+ static R_VAL ruby2d_texture_ext_create(R_VAL self, R_VAL rubySurface, R_VAL width, R_VAL height) {
475
443
  #endif
476
- // `a` is the array representing the sprite
477
-
478
- R2D_Sprite *spr;
479
- r_data_get_struct(r_ary_entry(a, 0), "@data", &sprite_data_type, R2D_Sprite, spr);
480
-
481
- spr->x = NUM2DBL(r_ary_entry(a, 1));
482
- spr->y = NUM2DBL(r_ary_entry(a, 2));
444
+ GLuint texture_id = 0;
445
+ SDL_Surface *surface;
483
446
 
484
- R_VAL w = r_ary_entry(a, 3);
485
- if (r_test(w)) spr->width = NUM2DBL(w);
486
-
487
- R_VAL h = r_ary_entry(a, 4);
488
- if (r_test(h)) spr->height = NUM2DBL(h);
489
-
490
- R2D_RotateSprite(spr, NUM2DBL(r_ary_entry(a, 5)), R2D_CENTER);
447
+ #if MRUBY
448
+ Data_Get_Struct(mrb, rubySurface, &surface_data_type, surface);
449
+ #else
450
+ Data_Get_Struct(rubySurface, SDL_Surface, surface);
451
+ #endif
491
452
 
492
- R2D_ClipSprite(
493
- spr,
494
- NUM2INT(r_ary_entry(a, 6)),
495
- NUM2INT(r_ary_entry(a, 7)),
496
- NUM2INT(r_ary_entry(a, 8)),
497
- NUM2INT(r_ary_entry(a, 9))
498
- );
453
+ // Detect image mode
454
+ GLint format = GL_RGB;
455
+ if (surface->format->BytesPerPixel == 4) {
456
+ format = GL_RGBA;
457
+ }
499
458
 
500
- spr->color.r = NUM2DBL(r_ary_entry(a, 10));
501
- spr->color.g = NUM2DBL(r_ary_entry(a, 11));
502
- spr->color.b = NUM2DBL(r_ary_entry(a, 12));
503
- spr->color.a = NUM2DBL(r_ary_entry(a, 13));
459
+ R2D_GL_CreateTexture(&texture_id, format,
460
+ NUM2INT(width), NUM2INT(height),
461
+ surface->pixels, GL_NEAREST);
504
462
 
505
- R2D_DrawSprite(spr);
506
- return R_NIL;
463
+ return INT2NUM(texture_id);
507
464
  }
508
465
 
509
466
 
510
467
  /*
511
- * Free sprite structure attached to Ruby 2D `Sprite` class
468
+ * Ruby2D::Texture#ext_delete
512
469
  */
513
470
  #if MRUBY
514
- static void free_sprite(mrb_state *mrb, void *p_) {
515
- R2D_Sprite *spr = (R2D_Sprite *)p_;
471
+ static R_VAL ruby2d_texture_ext_delete(mrb_state* mrb, R_VAL self) {
472
+ mrb_value rubyTexture_id;
473
+ mrb_get_args(mrb, "o", &rubyTexture_id);
516
474
  #else
517
- static void free_sprite(R2D_Sprite *spr) {
475
+ static R_VAL ruby2d_texture_ext_delete(R_VAL self, R_VAL rubyTexture_id) {
518
476
  #endif
519
- R2D_FreeSprite(spr);
520
- }
521
-
477
+ GLuint texture_id = NUM2INT(rubyTexture_id);
522
478
 
523
- /*
524
- * Ruby2D::Tileset#ext_init
525
- * Initialize tileset data
526
- */
527
- static R_VAL ruby2d_tileset_ext_init(R_VAL self, R_VAL path) {
528
- R2D_Image *img = R2D_CreateImage(RSTRING_PTR(path));
529
- if (!img) return R_FALSE;
530
-
531
- // Get width and height from Ruby class. If set, use it, else choose the
532
- // native dimensions of the image.
533
- R_VAL w = r_iv_get(self, "@width");
534
- R_VAL h = r_iv_get(self, "@height");
535
- r_iv_set(self, "@width" , r_test(w) ? w : INT2NUM(img->width));
536
- r_iv_set(self, "@height", r_test(h) ? h : INT2NUM(img->height));
537
- r_iv_set(self, "@data", r_data_wrap_struct(image, img));
479
+ R2D_GL_FreeTexture(&texture_id);
538
480
 
539
- return R_TRUE;
540
- }
541
-
542
-
543
- /*
544
- * Ruby2D::Tileset#ext_draw
545
- * Draws a single tile, will be called once per individual tile to draw
546
- */
547
- static R_VAL ruby2d_tileset_ext_draw(R_VAL self, R_VAL a) {
548
- // `a` is the array representing the tileset
549
-
550
- R2D_Image *img;
551
- r_data_get_struct(r_ary_entry(a, 0), "@data", &image_data_type, R2D_Image, img);
552
-
553
- int tw = NUM2INT(r_ary_entry(a, 1));
554
- int th = NUM2INT(r_ary_entry(a, 2));
555
- int padding = NUM2INT(r_ary_entry(a, 3));
556
- int spacing = NUM2INT(r_ary_entry(a, 4));
557
- int tx = NUM2INT(r_ary_entry(a, 5));
558
- int ty = NUM2INT(r_ary_entry(a, 6));
559
- int x = NUM2INT(r_ary_entry(a, 7));
560
- int y = NUM2INT(r_ary_entry(a, 8));
561
-
562
- R2D_DrawTile(img, tw, th, padding, spacing, tx, ty, x, y);
563
481
  return R_NIL;
564
482
  }
565
483
 
566
484
 
567
485
  /*
568
- * Ruby2D::Text#ext_init
569
- * Initialize text structure data
486
+ * Ruby2D::Sound#ext_init
487
+ * Initialize sound structure data
570
488
  */
571
489
  #if MRUBY
572
- static R_VAL ruby2d_text_ext_init(mrb_state* mrb, R_VAL self) {
490
+ static R_VAL ruby2d_sound_ext_init(mrb_state* mrb, R_VAL self) {
491
+ mrb_value path;
492
+ mrb_get_args(mrb, "o", &path);
573
493
  #else
574
- static R_VAL ruby2d_text_ext_init(R_VAL self) {
494
+ static R_VAL ruby2d_sound_ext_init(R_VAL self, R_VAL path) {
575
495
  #endif
576
- // Trim the font file string to its actual length on MRuby
577
- #if MRUBY
578
- mrb_value s = r_iv_get(self, "@font");
579
- mrb_str_resize(mrb, s, RSTRING_LEN(s));
580
- #endif
581
-
582
- R2D_Text *txt = R2D_CreateText(
583
- RSTRING_PTR(r_iv_get(self, "@font")),
584
- RSTRING_PTR(r_iv_get(self, "@text")),
585
- NUM2DBL(r_iv_get(self, "@size"))
586
- );
587
- if (!txt) return R_FALSE;
588
-
589
- r_iv_set(self, "@width", INT2NUM(txt->width));
590
- r_iv_set(self, "@height", INT2NUM(txt->height));
591
- r_iv_set(self, "@data", r_data_wrap_struct(text, txt));
592
-
496
+ R2D_Sound *snd = R2D_CreateSound(RSTRING_PTR(path));
497
+ if (!snd) return R_FALSE;
498
+ r_iv_set(self, "@data", r_data_wrap_struct(sound, snd));
593
499
  return R_TRUE;
594
500
  }
595
501
 
596
502
 
597
503
  /*
598
- * Ruby2D::Text#ext_set
504
+ * Ruby2D::Sound#ext_play
599
505
  */
600
506
  #if MRUBY
601
- static R_VAL ruby2d_text_ext_set(mrb_state* mrb, R_VAL self) {
602
- mrb_value text;
603
- mrb_get_args(mrb, "o", &text);
507
+ static R_VAL ruby2d_sound_ext_play(mrb_state* mrb, R_VAL self) {
604
508
  #else
605
- static R_VAL ruby2d_text_ext_set(R_VAL self, R_VAL text) {
509
+ static R_VAL ruby2d_sound_ext_play(R_VAL self) {
606
510
  #endif
607
- R2D_Text *txt;
608
- r_data_get_struct(self, "@data", &text_data_type, R2D_Text, txt);
609
-
610
- R2D_SetText(txt, RSTRING_PTR(text));
611
-
612
- r_iv_set(self, "@width", INT2NUM(txt->width));
613
- r_iv_set(self, "@height", INT2NUM(txt->height));
614
-
511
+ R2D_Sound *snd;
512
+ r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
513
+ R2D_PlaySound(snd);
615
514
  return R_NIL;
616
515
  }
617
516
 
618
517
 
619
518
  /*
620
- * Ruby2D::Text#self.ext_draw
519
+ * Ruby2D::Sound#ext_length
621
520
  */
622
521
  #if MRUBY
623
- static R_VAL ruby2d_text_ext_draw(mrb_state* mrb, R_VAL self) {
624
- mrb_value a;
625
- mrb_get_args(mrb, "o", &a);
522
+ static R_VAL ruby2d_sound_ext_length(mrb_state* mrb, R_VAL self) {
626
523
  #else
627
- static R_VAL ruby2d_text_ext_draw(R_VAL self, R_VAL a) {
524
+ static R_VAL ruby2d_sound_ext_length(R_VAL self) {
628
525
  #endif
629
- // `a` is the array representing the text
630
-
631
- R2D_Text *txt;
632
- r_data_get_struct(r_ary_entry(a, 0), "@data", &text_data_type, R2D_Text, txt);
633
-
634
- txt->x = NUM2DBL(r_ary_entry(a, 1));
635
- txt->y = NUM2DBL(r_ary_entry(a, 2));
636
-
637
- R2D_RotateText(txt, NUM2DBL(r_ary_entry(a, 3)), R2D_CENTER);
638
-
639
- txt->color.r = NUM2DBL(r_ary_entry(a, 4));
640
- txt->color.g = NUM2DBL(r_ary_entry(a, 5));
641
- txt->color.b = NUM2DBL(r_ary_entry(a, 6));
642
- txt->color.a = NUM2DBL(r_ary_entry(a, 7));
643
-
644
- R2D_DrawText(txt);
645
- return R_NIL;
526
+ R2D_Sound *snd;
527
+ r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
528
+ return INT2NUM(R2D_GetSoundLength(snd));
646
529
  }
647
530
 
648
531
 
649
532
  /*
650
- * Free text structure attached to Ruby 2D `Text` class
533
+ * Free sound structure attached to Ruby 2D `Sound` class
651
534
  */
652
535
  #if MRUBY
653
- static void free_text(mrb_state *mrb, void *p_) {
654
- R2D_Text *txt = (R2D_Text *)p_;
536
+ static void free_sound(mrb_state *mrb, void *p_) {
537
+ R2D_Sound *snd = (R2D_Sound *)p_;
655
538
  #else
656
- static void free_text(R2D_Text *txt) {
539
+ static void free_sound(R2D_Sound *snd) {
657
540
  #endif
658
- R2D_FreeText(txt);
541
+ R2D_FreeSound(snd);
659
542
  }
660
543
 
661
544
 
662
545
  /*
663
- * Ruby2D::Sound#ext_init
664
- * Initialize sound structure data
546
+ * Ruby2D::Sound#ext_get_volume
665
547
  */
666
548
  #if MRUBY
667
- static R_VAL ruby2d_sound_ext_init(mrb_state* mrb, R_VAL self) {
668
- mrb_value path;
669
- mrb_get_args(mrb, "o", &path);
549
+ static R_VAL ruby2d_sound_ext_get_volume(mrb_state* mrb, R_VAL self) {
670
550
  #else
671
- static R_VAL ruby2d_sound_ext_init(R_VAL self, R_VAL path) {
551
+ static R_VAL ruby2d_sound_ext_get_volume(R_VAL self) {
672
552
  #endif
673
- R2D_Sound *snd = R2D_CreateSound(RSTRING_PTR(path));
674
- if (!snd) return R_FALSE;
675
- r_iv_set(self, "@data", r_data_wrap_struct(sound, snd));
676
- return R_TRUE;
553
+ R2D_Sound *snd;
554
+ r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
555
+ return INT2NUM(ceil(Mix_VolumeChunk(snd->data, -1) * (100.0 / MIX_MAX_VOLUME)));
677
556
  }
678
557
 
679
558
 
680
559
  /*
681
- * Ruby2D::Sound#ext_play
560
+ * Ruby2D::Music#ext_set_volume
682
561
  */
683
562
  #if MRUBY
684
- static R_VAL ruby2d_sound_ext_play(mrb_state* mrb, R_VAL self) {
563
+ static R_VAL ruby2d_sound_ext_set_volume(mrb_state* mrb, R_VAL self) {
564
+ mrb_value volume;
565
+ mrb_get_args(mrb, "o", &volume);
685
566
  #else
686
- static R_VAL ruby2d_sound_ext_play(R_VAL self) {
567
+ static R_VAL ruby2d_sound_ext_set_volume(R_VAL self, R_VAL volume) {
687
568
  #endif
688
569
  R2D_Sound *snd;
689
570
  r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
690
- R2D_PlaySound(snd);
571
+ Mix_VolumeChunk(snd->data, (NUM2INT(volume) / 100.0) * MIX_MAX_VOLUME);
691
572
  return R_NIL;
692
573
  }
693
574
 
694
575
 
695
576
  /*
696
- * Ruby2D::Sound#ext_length
577
+ * Ruby2D::Sound#ext_get_mix_volume
697
578
  */
698
- static R_VAL ruby2d_sound_ext_length(R_VAL self) {
699
- R2D_Sound *snd;
700
- r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
701
- return INT2NUM(R2D_GetSoundLength(snd));
579
+ #if MRUBY
580
+ static R_VAL ruby2d_sound_ext_get_mix_volume(mrb_state* mrb, R_VAL self) {
581
+ #else
582
+ static R_VAL ruby2d_sound_ext_get_mix_volume(R_VAL self) {
583
+ #endif
584
+ return INT2NUM(ceil(Mix_Volume(-1, -1) * (100.0 / MIX_MAX_VOLUME)));
702
585
  }
703
586
 
704
587
 
705
588
  /*
706
- * Free sound structure attached to Ruby 2D `Sound` class
589
+ * Ruby2D::Music#ext_set_mix_volume
707
590
  */
708
591
  #if MRUBY
709
- static void free_sound(mrb_state *mrb, void *p_) {
710
- R2D_Sound *snd = (R2D_Sound *)p_;
592
+ static R_VAL ruby2d_sound_ext_set_mix_volume(mrb_state* mrb, R_VAL self) {
593
+ mrb_value volume;
594
+ mrb_get_args(mrb, "o", &volume);
711
595
  #else
712
- static void free_sound(R2D_Sound *snd) {
596
+ static R_VAL ruby2d_sound_ext_set_mix_volume(R_VAL self, R_VAL volume) {
713
597
  #endif
714
- R2D_FreeSound(snd);
598
+ Mix_Volume(-1, (NUM2INT(volume) / 100.0) * MIX_MAX_VOLUME);
599
+ return R_NIL;
715
600
  }
716
601
 
717
602
 
@@ -832,13 +717,88 @@ static R_VAL ruby2d_music_ext_fadeout(R_VAL self, R_VAL ms) {
832
717
  /*
833
718
  * Ruby2D::Music#ext_length
834
719
  */
720
+ #if MRUBY
721
+ static R_VAL ruby2d_music_ext_length(mrb_state* mrb, R_VAL self) {
722
+ #else
835
723
  static R_VAL ruby2d_music_ext_length(R_VAL self) {
724
+ #endif
836
725
  R2D_Music *ms;
837
726
  r_data_get_struct(self, "@data", &music_data_type, R2D_Music, ms);
838
727
  return INT2NUM(R2D_GetMusicLength(ms));
839
728
  }
840
729
 
841
730
 
731
+ /*
732
+ * Ruby2D::Font#ext_load
733
+ */
734
+ #if MRUBY
735
+ static R_VAL ruby2d_font_ext_load(mrb_state* mrb, R_VAL self) {
736
+ mrb_value path, size, style;
737
+ mrb_get_args(mrb, "ooo", &path, &size, &style);
738
+ #else
739
+ static R_VAL ruby2d_font_ext_load(R_VAL self, R_VAL path, R_VAL size, R_VAL style) {
740
+ #endif
741
+ R2D_Init();
742
+
743
+ TTF_Font *font = R2D_FontCreateTTFFont(RSTRING_PTR(path), NUM2INT(size), RSTRING_PTR(style));
744
+ if (!font) {
745
+ return R_NIL;
746
+ }
747
+
748
+ return r_data_wrap_struct(font, font);
749
+ }
750
+
751
+
752
+ /*
753
+ * Ruby2D::Texture#ext_draw
754
+ */
755
+ #if MRUBY
756
+ static R_VAL ruby2d_texture_ext_draw(mrb_state* mrb, R_VAL self) {
757
+ mrb_value ruby_coordinates, ruby_texture_coordinates, ruby_color, texture_id;
758
+ mrb_get_args(mrb, "oooo", &ruby_coordinates, &ruby_texture_coordinates, &ruby_color, &texture_id);
759
+ #else
760
+ static R_VAL ruby2d_texture_ext_draw(R_VAL self, R_VAL ruby_coordinates, R_VAL ruby_texture_coordinates, R_VAL ruby_color, R_VAL texture_id) {
761
+ #endif
762
+ GLfloat coordinates[8];
763
+ GLfloat texture_coordinates[8];
764
+ GLfloat color[4];
765
+
766
+ for(int i = 0; i < 8; i++) { coordinates[i] = NUM2DBL(r_ary_entry(ruby_coordinates, i)); }
767
+ for(int i = 0; i < 8; i++) { texture_coordinates[i] = NUM2DBL(r_ary_entry(ruby_texture_coordinates, i)); }
768
+ for(int i = 0; i < 4; i++) { color[i] = NUM2DBL(r_ary_entry(ruby_color, i)); }
769
+
770
+ R2D_GL_DrawTexture(coordinates, texture_coordinates, color, NUM2INT(texture_id));
771
+
772
+ return R_NIL;
773
+ }
774
+
775
+
776
+ /*
777
+ * Free font structure stored in the Ruby 2D `Font` class
778
+ */
779
+ #if MRUBY
780
+ static void free_font(mrb_state *mrb, void *p_) {
781
+ TTF_Font *font = (TTF_Font *)p_;
782
+ #else
783
+ static void free_font(TTF_Font *font) {
784
+ #endif
785
+ TTF_CloseFont(font);
786
+ }
787
+
788
+
789
+ /*
790
+ * Free surface structure used within the Ruby 2D `Texture` class
791
+ */
792
+ #if MRUBY
793
+ static void free_surface(mrb_state *mrb, void *p_) {
794
+ SDL_Surface *surface = (SDL_Surface *)p_;
795
+ #else
796
+ static void free_surface(SDL_Surface *surface) {
797
+ #endif
798
+ SDL_FreeSurface(surface);
799
+ }
800
+
801
+
842
802
  /*
843
803
  * Free music structure attached to Ruby 2D `Music` class
844
804
  */
@@ -1032,14 +992,14 @@ static void on_controller(R2D_Event e) {
1032
992
  static void update() {
1033
993
 
1034
994
  // Set the cursor
1035
- r_iv_set(ruby2d_window, "@mouse_x", INT2NUM(window->mouse.x));
1036
- r_iv_set(ruby2d_window, "@mouse_y", INT2NUM(window->mouse.y));
995
+ r_iv_set(ruby2d_window, "@mouse_x", INT2NUM(ruby2d_c_window->mouse.x));
996
+ r_iv_set(ruby2d_window, "@mouse_y", INT2NUM(ruby2d_c_window->mouse.y));
1037
997
 
1038
998
  // Store frames
1039
- r_iv_set(ruby2d_window, "@frames", DBL2NUM(window->frames));
999
+ r_iv_set(ruby2d_window, "@frames", DBL2NUM(ruby2d_c_window->frames));
1040
1000
 
1041
1001
  // Store frame rate
1042
- r_iv_set(ruby2d_window, "@fps", DBL2NUM(window->fps));
1002
+ r_iv_set(ruby2d_window, "@fps", DBL2NUM(ruby2d_c_window->fps));
1043
1003
 
1044
1004
  // Call update proc, `window.update`
1045
1005
  r_funcall(ruby2d_window, "update_callback", 0);
@@ -1053,10 +1013,10 @@ static void render() {
1053
1013
 
1054
1014
  // Set background color
1055
1015
  R_VAL bc = r_iv_get(ruby2d_window, "@background");
1056
- window->background.r = NUM2DBL(r_iv_get(bc, "@r"));
1057
- window->background.g = NUM2DBL(r_iv_get(bc, "@g"));
1058
- window->background.b = NUM2DBL(r_iv_get(bc, "@b"));
1059
- window->background.a = NUM2DBL(r_iv_get(bc, "@a"));
1016
+ ruby2d_c_window->background.r = NUM2DBL(r_iv_get(bc, "@r"));
1017
+ ruby2d_c_window->background.g = NUM2DBL(r_iv_get(bc, "@g"));
1018
+ ruby2d_c_window->background.b = NUM2DBL(r_iv_get(bc, "@b"));
1019
+ ruby2d_c_window->background.a = NUM2DBL(r_iv_get(bc, "@a"));
1060
1020
 
1061
1021
  // Read window objects
1062
1022
  R_VAL objects = r_iv_get(ruby2d_window, "@objects");
@@ -1170,19 +1130,19 @@ static R_VAL ruby2d_window_ext_show(R_VAL self) {
1170
1130
 
1171
1131
  // Create and show window
1172
1132
 
1173
- window = R2D_CreateWindow(
1133
+ ruby2d_c_window = R2D_CreateWindow(
1174
1134
  title, width, height, update, render, flags
1175
1135
  );
1176
1136
 
1177
- window->viewport.width = viewport_width;
1178
- window->viewport.height = viewport_height;
1179
- window->fps_cap = fps_cap;
1180
- window->icon = icon;
1181
- window->on_key = on_key;
1182
- window->on_mouse = on_mouse;
1183
- window->on_controller = on_controller;
1137
+ ruby2d_c_window->viewport.width = viewport_width;
1138
+ ruby2d_c_window->viewport.height = viewport_height;
1139
+ ruby2d_c_window->fps_cap = fps_cap;
1140
+ ruby2d_c_window->icon = icon;
1141
+ ruby2d_c_window->on_key = on_key;
1142
+ ruby2d_c_window->on_mouse = on_mouse;
1143
+ ruby2d_c_window->on_controller = on_controller;
1184
1144
 
1185
- R2D_Show(window);
1145
+ R2D_Show(ruby2d_c_window);
1186
1146
 
1187
1147
  atexit(free_window);
1188
1148
  return R_NIL;
@@ -1199,8 +1159,8 @@ static R_VAL ruby2d_ext_screenshot(mrb_state* mrb, R_VAL self) {
1199
1159
  #else
1200
1160
  static R_VAL ruby2d_ext_screenshot(R_VAL self, R_VAL path) {
1201
1161
  #endif
1202
- if (window) {
1203
- R2D_Screenshot(window, RSTRING_PTR(path));
1162
+ if (ruby2d_c_window) {
1163
+ R2D_Screenshot(ruby2d_c_window, RSTRING_PTR(path));
1204
1164
  return path;
1205
1165
  } else {
1206
1166
  return R_FALSE;
@@ -1211,8 +1171,12 @@ static R_VAL ruby2d_ext_screenshot(R_VAL self, R_VAL path) {
1211
1171
  /*
1212
1172
  * Ruby2D::Window#ext_close
1213
1173
  */
1174
+ #if MRUBY
1175
+ static R_VAL ruby2d_window_ext_close(mrb_state* mrb, R_VAL self) {
1176
+ #else
1214
1177
  static R_VAL ruby2d_window_ext_close() {
1215
- R2D_Close(window);
1178
+ #endif
1179
+ R2D_Close(ruby2d_c_window);
1216
1180
  return R_NIL;
1217
1181
  }
1218
1182
 
@@ -1275,41 +1239,14 @@ void Init_ruby2d() {
1275
1239
  // Ruby2D::Image
1276
1240
  R_CLASS ruby2d_image_class = r_define_class(ruby2d_module, "Image");
1277
1241
 
1278
- // Ruby2D::Image#ext_init
1279
- r_define_method(ruby2d_image_class, "ext_init", ruby2d_image_ext_init, r_args_req(1));
1280
-
1281
- // Ruby2D::Image#self.ext_draw
1282
- r_define_class_method(ruby2d_image_class, "ext_draw", ruby2d_image_ext_draw, r_args_req(1));
1283
-
1284
- // Ruby2D::Sprite
1285
- R_CLASS ruby2d_sprite_class = r_define_class(ruby2d_module, "Sprite");
1286
-
1287
- // Ruby2D::Sprite#ext_init
1288
- r_define_method(ruby2d_sprite_class, "ext_init", ruby2d_sprite_ext_init, r_args_req(1));
1289
-
1290
- // Ruby2D::Sprite#self.ext_draw
1291
- r_define_class_method(ruby2d_sprite_class, "ext_draw", ruby2d_sprite_ext_draw, r_args_req(1));
1292
-
1293
- // Ruby2D::Tileset
1294
- R_CLASS ruby2d_tileset_class = r_define_class(ruby2d_module, "Tileset");
1295
-
1296
- // Ruby2D::Tileset#ext_init
1297
- r_define_method(ruby2d_tileset_class, "ext_init", ruby2d_tileset_ext_init, r_args_req(1));
1298
-
1299
- // Ruby2D::Tileset#self.ext_draw
1300
- r_define_class_method(ruby2d_tileset_class, "ext_draw", ruby2d_tileset_ext_draw, r_args_req(1));
1242
+ // Ruby2D::Image#ext_load_image
1243
+ r_define_class_method(ruby2d_image_class, "ext_load_image", ruby2d_image_ext_load_image, r_args_req(1));
1301
1244
 
1302
1245
  // Ruby2D::Text
1303
1246
  R_CLASS ruby2d_text_class = r_define_class(ruby2d_module, "Text");
1304
1247
 
1305
- // Ruby2D::Text#ext_init
1306
- r_define_method(ruby2d_text_class, "ext_init", ruby2d_text_ext_init, r_args_none);
1307
-
1308
- // Ruby2D::Text#ext_set
1309
- r_define_method(ruby2d_text_class, "ext_set", ruby2d_text_ext_set, r_args_req(1));
1310
-
1311
- // Ruby2D::Text#self.ext_draw
1312
- r_define_class_method(ruby2d_text_class, "ext_draw", ruby2d_text_ext_draw, r_args_req(1));
1248
+ // Ruby2D::Text#ext_load_text
1249
+ r_define_class_method(ruby2d_text_class, "ext_load_text", ruby2d_text_ext_load_text, r_args_req(2));
1313
1250
 
1314
1251
  // Ruby2D::Sound
1315
1252
  R_CLASS ruby2d_sound_class = r_define_class(ruby2d_module, "Sound");
@@ -1319,6 +1256,18 @@ void Init_ruby2d() {
1319
1256
 
1320
1257
  // Ruby2D::Sound#ext_play
1321
1258
  r_define_method(ruby2d_sound_class, "ext_play", ruby2d_sound_ext_play, r_args_none);
1259
+
1260
+ // Ruby2D::Sound#ext_get_volume
1261
+ r_define_method(ruby2d_sound_class, "ext_get_volume", ruby2d_sound_ext_get_volume, r_args_none);
1262
+
1263
+ // Ruby2D::Sound#ext_set_volume
1264
+ r_define_method(ruby2d_sound_class, "ext_set_volume", ruby2d_sound_ext_set_volume, r_args_req(1));
1265
+
1266
+ // Ruby2D::Sound#self.ext_get_mix_volume
1267
+ r_define_class_method(ruby2d_sound_class, "ext_get_mix_volume", ruby2d_sound_ext_get_mix_volume, r_args_none);
1268
+
1269
+ // Ruby2D::Sound#self.ext_set_mix_volume
1270
+ r_define_class_method(ruby2d_sound_class, "ext_set_mix_volume", ruby2d_sound_ext_set_mix_volume, r_args_req(1));
1322
1271
 
1323
1272
  // Ruby2D::Sound#ext_length
1324
1273
  r_define_method(ruby2d_sound_class, "ext_length", ruby2d_sound_ext_length, r_args_none);
@@ -1353,6 +1302,24 @@ void Init_ruby2d() {
1353
1302
  // Ruby2D::Music#ext_length
1354
1303
  r_define_method(ruby2d_music_class, "ext_length", ruby2d_music_ext_length, r_args_none);
1355
1304
 
1305
+ // Ruby2D::Font
1306
+ R_CLASS ruby2d_font_class = r_define_class(ruby2d_module, "Font");
1307
+
1308
+ // Ruby2D::Font#ext_load
1309
+ r_define_class_method(ruby2d_font_class, "ext_load", ruby2d_font_ext_load, r_args_req(3));
1310
+
1311
+ // Ruby2D::Texture
1312
+ R_CLASS ruby2d_texture_class = r_define_class(ruby2d_module, "Texture");
1313
+
1314
+ // Ruby2D::Texture#ext_draw
1315
+ r_define_method(ruby2d_texture_class, "ext_draw", ruby2d_texture_ext_draw, r_args_req(4));
1316
+
1317
+ // Ruby2D::Texture#ext_create
1318
+ r_define_method(ruby2d_texture_class, "ext_create", ruby2d_texture_ext_create, r_args_req(3));
1319
+
1320
+ // Ruby2D::Texture#ext_delete
1321
+ r_define_method(ruby2d_texture_class, "ext_delete", ruby2d_texture_ext_delete, r_args_req(1));
1322
+
1356
1323
  // Ruby2D::Window
1357
1324
  R_CLASS ruby2d_window_class = r_define_class(ruby2d_module, "Window");
1358
1325