ruby2d 0.10.0 → 0.11.2

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 (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
@@ -1,58 +1,45 @@
1
- # Build a Ruby 2D app natively and for the web
1
+ # Build a compiled Ruby 2D app with mruby
2
2
 
3
+ require 'ruby2d'
3
4
  require 'fileutils'
5
+ require 'ruby2d/cli/colorize'
6
+ require 'ruby2d/cli/platform'
4
7
 
5
- # The installed gem directory
6
- @gem_dir = "#{Gem::Specification.find_by_name('ruby2d').gem_dir}"
7
8
 
8
9
  # The Ruby 2D library files
9
- @lib_files = [
10
+ @ruby2d_lib_files = [
10
11
  'cli/colorize',
11
12
  'exceptions',
12
13
  'renderable',
13
14
  'color',
14
15
  'window',
15
16
  'dsl',
17
+ 'entity',
16
18
  'quad',
17
19
  'line',
18
20
  'circle',
19
21
  'rectangle',
20
22
  'square',
21
23
  'triangle',
24
+ 'pixel',
22
25
  'image',
23
26
  'sprite',
27
+ 'tileset',
24
28
  'font',
25
29
  'text',
26
30
  'sound',
27
31
  'music',
32
+ 'texture',
33
+ 'vertices',
28
34
  '../ruby2d'
29
35
  ]
30
36
 
31
37
 
32
- # Check if source file provided is good
33
- def check_build_src_file(rb_file)
34
- if !rb_file
35
- puts "Please provide a Ruby file to build"
36
- exit
37
- elsif !File.exist? rb_file
38
- puts "Can't find file: #{rb_file}"
39
- exit
40
- end
41
- end
42
-
43
-
44
- # Assemble the Ruby 2D library in one `.rb` file
45
- def make_lib
46
- FileUtils.mkdir_p 'build'
47
-
48
- lib_dir = "#{@gem_dir}/lib/ruby2d/"
49
-
50
- lib = ''
51
- @lib_files.each do |f|
52
- lib << File.read("#{lib_dir + f}.rb") + "\n\n"
53
- end
38
+ # Helpers ######################################################################
54
39
 
55
- File.write('build/lib.rb', lib)
40
+ def run_cmd(cmd)
41
+ puts "#{'$'.info} #{cmd.bold}\n" if @debug
42
+ system cmd
56
43
  end
57
44
 
58
45
 
@@ -66,57 +53,251 @@ def strip_require(file)
66
53
  end
67
54
 
68
55
 
69
- # Build a native version of the provided Ruby application
70
- def build_native(rb_file)
71
- check_build_src_file(rb_file)
56
+ # Add linker flags
57
+ def add_ld_flags(ld_flags, name, type, dir = nil)
58
+ case type
59
+ when :archive
60
+ ld_flags << "#{dir}/lib#{name}.a "
61
+ when :framework
62
+ ld_flags << "-Wl,-framework,#{name} "
63
+ end
64
+ end
72
65
 
73
- # Check if MRuby exists; if not, quit
74
- if `which mruby`.empty?
75
- puts "#{'Error:'.error} Can't find MRuby, which is needed to build native Ruby 2D applications.\n"
66
+
67
+ # Build Tasks ##################################################################
68
+
69
+ # Build the user's application
70
+ def build(target, ruby2d_app)
71
+
72
+ # Check if source file provided is good
73
+ if !ruby2d_app
74
+ puts "Please provide a Ruby file to build"
75
+ exit
76
+ elsif !File.exist? ruby2d_app
77
+ puts "Can't find file: #{ruby2d_app}"
76
78
  exit
77
79
  end
78
80
 
79
81
  # Add debugging information to produce backtrace
80
82
  if @debug then debug_flag = '-g' end
81
83
 
82
- # Assemble the Ruby 2D library in one `.rb` file and compile to bytecode
83
- make_lib
84
- `mrbc #{debug_flag} -Bruby2d_lib -obuild/lib.c build/lib.rb`
84
+ # Create build directory
85
+ FileUtils.mkdir_p 'build'
85
86
 
86
- # Read the provided Ruby source file, copy to build dir and compile to bytecode
87
- File.open('build/src.rb', 'w') { |file| file << strip_require(rb_file) }
88
- `mrbc #{debug_flag} -Bruby2d_app -obuild/src.c build/src.rb`
87
+ # Assemble Ruby 2D library files into one '.rb' file
88
+
89
+ ruby2d_lib_dir = "#{Ruby2D.gem_dir}/lib/ruby2d/"
90
+
91
+ ruby2d_lib = ''
92
+ @ruby2d_lib_files.each do |f|
93
+ ruby2d_lib << File.read("#{ruby2d_lib_dir + f}.rb") + "\n\n"
94
+ end
95
+
96
+ File.write('build/ruby2d_lib.rb', ruby2d_lib)
97
+
98
+ # Assemble the Ruby 2D C extension files into one '.c' file
99
+
100
+ ruby2d_ext_dir = "#{Ruby2D.gem_dir}/ext/ruby2d/"
101
+
102
+ ruby2d_ext = "#define MRUBY 1" << "\n\n"
103
+ Dir["#{ruby2d_ext_dir}*.c"].each do |c_file|
104
+ ruby2d_ext << File.read(c_file)
105
+ end
106
+
107
+ File.write('build/ruby2d_ext.c', ruby2d_ext)
108
+
109
+ # Select `mrbc` executable based on platform
110
+ case $RUBY2D_PLATFORM
111
+ when :macos
112
+ mrbc = "#{Ruby2D.assets}/macos/universal/bin/mrbc"
113
+ when :windows
114
+ mrbc = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/bin/mrbc.exe"
115
+ else
116
+ mrbc = 'mrbc'
117
+ end
118
+
119
+ # Compile the Ruby 2D lib (`.rb` files) to mruby bytecode
120
+ run_cmd "#{mrbc} #{debug_flag} -Bruby2d_lib -obuild/ruby2d_lib.c build/ruby2d_lib.rb"
121
+
122
+ # Read the user's provided Ruby source file, copy to build dir and compile to bytecode
123
+ File.open('build/ruby2d_app.rb', 'w') { |f| f << strip_require(ruby2d_app) }
124
+ run_cmd "#{mrbc} #{debug_flag} -Bruby2d_app -obuild/ruby2d_app.c build/ruby2d_app.rb"
89
125
 
90
126
  # Combine contents of C source files and bytecode into one file
91
127
  open('build/app.c', 'w') do |f|
92
- f << "#define MRUBY 1" << "\n\n"
93
- f << File.read("build/lib.c") << "\n\n"
94
- f << File.read("build/src.c") << "\n\n"
95
- f << File.read("#{@gem_dir}/ext/ruby2d/ruby2d.c")
128
+ ['ruby2d_app', 'ruby2d_lib', 'ruby2d_ext'].each do |c_file|
129
+ f << File.read("build/#{c_file}.c") << "\n\n"
130
+ end
96
131
  end
97
132
 
98
- # Compile to a native executable
99
- `cc build/app.c -lmruby -o build/app`
133
+ # Compile the final application based on the target platform
134
+ case target
135
+ when :native
136
+ compile_native
137
+ when :web
138
+ compile_web
139
+ end
100
140
 
101
- # Clean up
141
+ # Remove files used in the build process
102
142
  clean_up unless @debug
103
143
 
104
- # Success!
105
- puts "Native app created at `build/app`"
106
144
  end
107
145
 
108
146
 
109
- # Build a web-based version of the provided Ruby application
110
- def build_web(rb_file)
111
- puts "Warning: ".warn + "This feature is currently disabled while it's being upgraded."
147
+ # Create a native executable using the available C compiler
148
+ def compile_native
149
+
150
+ # Get include directories
151
+ incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
152
+ incl_dir_deps = "#{Ruby2D.assets}/include/"
153
+
154
+ # Add compiler flags for each platform
155
+ case $RUBY2D_PLATFORM
156
+
157
+ when :macos
158
+ ld_dir = "#{Ruby2D.assets}/macos/universal/lib"
159
+
160
+ c_flags = '-arch arm64 -arch x86_64'
161
+
162
+ ld_flags = ''
163
+ ['mruby', 'SDL2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf',
164
+ 'jpeg', 'png16', 'tiff', 'webp',
165
+ 'mpg123', 'ogg', 'FLAC', 'vorbis', 'vorbisfile', 'modplug',
166
+ 'freetype', 'harfbuzz', 'graphite2'].each do |name|
167
+ add_ld_flags(ld_flags, name, :archive, ld_dir)
168
+ end
169
+
170
+ ld_flags << "-lz -lbz2 -liconv -lstdc++ "
171
+ ['Cocoa', 'Carbon', 'CoreVideo', 'OpenGL', 'Metal', 'CoreAudio', 'AudioToolbox',
172
+ 'IOKit', 'GameController', 'ForceFeedback', 'CoreHaptics'].each do |name|
173
+ add_ld_flags(ld_flags, name, :framework)
174
+ end
175
+
176
+ when :linux, :linux_rpi, :bsd
177
+ # TODO: implement this
178
+ # ld_flags = '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm -lGL'
179
+
180
+ when :windows
181
+ ld_dir = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/lib"
182
+
183
+ ld_flags = '-static -Wl,--start-group '
184
+ ['mruby',
185
+ 'SDL2',
186
+ 'SDL2_image', 'jpeg', 'png16', 'tiff', 'webp', 'jbig', 'deflate', 'lzma', 'zstd', 'Lerc',
187
+ 'SDL2_mixer', 'mpg123', 'FLAC', 'vorbis', 'vorbisfile', 'ogg', 'modplug', 'opus', 'opusfile', 'sndfile',
188
+ 'SDL2_ttf', 'freetype', 'harfbuzz', 'graphite2', 'bz2', 'brotlicommon', 'brotlidec',
189
+ 'glew32', 'stdc++', 'z', 'ssp'
190
+ ].each do |name|
191
+ add_ld_flags(ld_flags, name, :archive, ld_dir)
192
+ end
193
+ ld_flags << '-lmingw32 -lopengl32 -lole32 -loleaut32 -limm32 -lversion -lwinmm -lrpcrt4 -mwindows -lsetupapi -ldwrite '\
194
+ '-lws2_32 -lshlwapi '
195
+ ld_flags << '-Wl,--end-group'
196
+ end
197
+
198
+ # Compile the app
199
+ run_cmd "cc #{c_flags} -I#{incl_dir_ruby2d} -I#{incl_dir_deps} build/app.c #{ld_flags} -o build/app"
200
+
201
+ create_macos_bundle if $RUBY2D_PLATFORM == :macos
112
202
  end
113
203
 
114
204
 
115
- # Build an app bundle for macOS
116
- def build_macos(rb_file)
205
+ # Create a WebAssembly executable using Emscripten
206
+ def compile_web
207
+
208
+ # Check for compiler toolchain issues
209
+ if doctor_web(:building)
210
+ puts "Fix errors before building.\n\n"
211
+ end
212
+
213
+ wasm_assets = "#{Ruby2D.assets}/wasm"
214
+
215
+ # Get include directories
216
+ incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
217
+ incl_dir_deps = "#{Ruby2D.assets}/include/"
218
+
219
+ optimize_flags = '-Os --closure 1'
220
+ ld_flags = "#{wasm_assets}/libmruby.a"
221
+
222
+ # Compile using Emscripten
223
+ run_cmd "emcc -s WASM=1 -I#{incl_dir_ruby2d} -I#{incl_dir_deps} "\
224
+ "-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 "\
225
+ "build/app.c #{ld_flags} -o build/app.html"
226
+
227
+ # TODO: Copy HTML template from gem assets to build directory
228
+ # FileUtils.cp "#{wasm_assets}/template.html", 'build/app.html'
229
+
230
+ exit(1) unless $?.success?
231
+ end
232
+
233
+
234
+ def doctor_native
235
+ # Check if MRuby exists; if not, quit
236
+ if `which mruby`.empty?
237
+ puts "#{'Error:'.error} Can't find `mruby`, which is needed to build native Ruby 2D applications.\n"
238
+ exit
239
+ end
240
+ end
241
+
242
+
243
+ # Check for problems with web build
244
+ def doctor_web(mode = nil)
245
+
246
+ errors = false
247
+ mruby_errors = false
248
+ emscripten_errors = false
249
+
250
+ puts "\nChecking for mruby"
251
+
252
+ # Check for `mrbc`
253
+ print ' mrbc...'
254
+ if `which mrbc`.empty?
255
+ puts 'not found'.error
256
+ mruby_errors = true
257
+ else
258
+ puts 'found'.success
259
+ end
117
260
 
118
- # Build native app for macOS
119
- build_native(rb_file)
261
+ puts "\nChecking for Emscripten tools"
262
+
263
+ # Check for `emcc`
264
+ print ' emcc...'
265
+ if `which emcc`.empty?
266
+ puts 'not found'.error
267
+ emscripten_errors = true
268
+ else
269
+ puts 'found'.success
270
+ end
271
+
272
+ # Check for `emar`
273
+ print ' emar...'
274
+ if `which emar`.empty?
275
+ puts 'not found'.error
276
+ emscripten_errors = true
277
+ else
278
+ puts 'found'.success
279
+ end
280
+
281
+ if mruby_errors || emscripten_errors then errors = true end
282
+
283
+ if errors
284
+ puts "\nErrors were found!\n\n"
285
+ if mruby_errors
286
+ puts "* Did you install mruby?"
287
+ end
288
+ if emscripten_errors
289
+ puts "* Did you run \`./emsdk_env.sh\` ?", " For help, check out the \"Getting Started\" guide on webassembly.org"
290
+ end
291
+ puts "\n"
292
+ exit(1)
293
+ else
294
+ puts "\n👍 Everything looks good!\n\n"
295
+ end
296
+ end
297
+
298
+
299
+ # Build an app bundle for macOS
300
+ def create_macos_bundle
120
301
 
121
302
  # Property list source for the bundle
122
303
  info_plist = %(
@@ -151,10 +332,10 @@ def build_macos(rb_file)
151
332
  # FileUtils.cp "#{@gem_dir}/assets/app.icns", 'build/App.app/Contents/Resources'
152
333
 
153
334
  # Clean up
154
- FileUtils.rm_f 'build/app' unless @debug
335
+ # FileUtils.rm_f 'build/app' unless @debug
155
336
 
156
337
  # Success!
157
- puts 'macOS app bundle created: `build/App.app`'
338
+ # puts 'macOS app bundle created: `build/App.app`'
158
339
  end
159
340
 
160
341
 
@@ -206,8 +387,7 @@ end
206
387
  # Clean up unneeded build files
207
388
  def clean_up(cmd = nil)
208
389
  FileUtils.rm(
209
- Dir.glob('build/{src,lib}.{rb,c,js}') +
210
- Dir.glob('build/app.c')
390
+ Dir.glob('build/*.{rb,c,js}')
211
391
  )
212
392
  if cmd == :all
213
393
  puts "cleaning up..."
@@ -3,8 +3,9 @@
3
3
  # Extend `String` to include some fancy colors
4
4
  class String
5
5
  def ruby2d_colorize(c); "\e[#{c}m#{self}\e[0m" end
6
- def bold; ruby2d_colorize('1') end
7
- def info; ruby2d_colorize('1;34') end
8
- def warn; ruby2d_colorize('1;33') end
9
- def error; ruby2d_colorize('1;31') end
6
+ def bold; ruby2d_colorize('1') end
7
+ def info; ruby2d_colorize('1;34') end
8
+ def warn; ruby2d_colorize('1;33') end
9
+ def success; ruby2d_colorize('1;32') end
10
+ def error; ruby2d_colorize('1;31') end
10
11
  end
@@ -0,0 +1,17 @@
1
+ # Set the OS and platform
2
+
3
+ case RUBY_PLATFORM
4
+ when /darwin/
5
+ $RUBY2D_PLATFORM = :macos
6
+ when /linux/
7
+ $RUBY2D_PLATFORM = :linux
8
+ if `cat /etc/os-release` =~ /raspbian/
9
+ $RUBY2D_PLATFORM = :linux_rpi
10
+ end
11
+ when /bsd/
12
+ $RUBY2D_PLATFORM = :bsd
13
+ when /mingw/
14
+ $RUBY2D_PLATFORM = :windows
15
+ else
16
+ $RUBY2D_PLATFORM = nil
17
+ end
data/lib/ruby2d/font.rb CHANGED
@@ -2,8 +2,28 @@
2
2
 
3
3
  module Ruby2D
4
4
  class Font
5
+ FONT_CACHE_LIMIT = 100
6
+
7
+ @@loaded_fonts = {}
8
+
9
+ attr_reader :ttf_font
10
+
11
+ def initialize(path, size, style=nil)
12
+ @ttf_font = Font.ext_load(path, size, style.to_s)
13
+ end
5
14
 
6
15
  class << self
16
+ def load(path, size, style=nil)
17
+ unless File.exist? path
18
+ raise Error, "Cannot find font file `#{path}`"
19
+ end
20
+
21
+ (@@loaded_fonts[[path, size, style]] ||= Font.new(path, size, style)).tap do |font|
22
+ if @@loaded_fonts.size > FONT_CACHE_LIMIT
23
+ @@loaded_fonts.shift
24
+ end
25
+ end
26
+ end
7
27
 
8
28
  # List all fonts, names only
9
29
  def all
@@ -50,6 +70,7 @@ module Ruby2D
50
70
  macos_font_path = '/Library/Fonts'
51
71
  linux_font_path = '/usr/share/fonts'
52
72
  windows_font_path = 'C:/Windows/Fonts'
73
+ openbsd_font_path = '/usr/X11R6/lib/X11/fonts'
53
74
 
54
75
  # If MRI and/or non-Bash shell (like cmd.exe)
55
76
  if Object.const_defined? :RUBY_PLATFORM
@@ -60,16 +81,20 @@ module Ruby2D
60
81
  linux_font_path
61
82
  when /mingw/
62
83
  windows_font_path
84
+ when /openbsd/
85
+ openbsd_font_path
63
86
  end
64
87
  # If MRuby
65
88
  else
66
89
  uname = `uname`
67
- if uname.include? 'Darwin' # macOS
90
+ if uname.include? 'Darwin' # macOS
68
91
  macos_font_path
69
92
  elsif uname.include? 'Linux'
70
93
  linux_font_path
71
94
  elsif uname.include? 'MINGW'
72
95
  windows_font_path
96
+ elsif uname.include? 'OpenBSD'
97
+ openbsd_font_path
73
98
  end
74
99
  end
75
100
  end
data/lib/ruby2d/image.rb CHANGED
@@ -7,26 +7,34 @@ module Ruby2D
7
7
  attr_reader :path
8
8
  attr_accessor :x, :y, :width, :height, :rotate, :data
9
9
 
10
- def initialize(path, opts = {})
10
+ def self.load_image(path)
11
11
  unless File.exist? path
12
12
  raise Error, "Cannot find image file `#{path}`"
13
13
  end
14
+
15
+ ext_load_image(path)
16
+ end
17
+
18
+ def initialize(path, opts = {})
14
19
  @path = path
20
+
21
+ @texture = Texture.new(*Image.load_image(@path))
22
+ @width = opts[:width] || @texture.width
23
+ @height = opts[:height] || @texture.height
24
+
15
25
  @x = opts[:x] || 0
16
26
  @y = opts[:y] || 0
17
27
  @z = opts[:z] || 0
18
- @width = opts[:width] || nil
19
- @height = opts[:height] || nil
20
28
  @rotate = opts[:rotate] || 0
21
29
  self.color = opts[:color] || 'white'
22
- self.opacity = opts[:opacity] if opts[:opacity]
23
- unless ext_init(@path)
24
- raise Error, "Image `#{@path}` cannot be created"
25
- end
30
+ self.color.opacity = opts[:opacity] if opts[:opacity]
31
+
26
32
  unless opts[:show] == false then add end
27
33
  end
28
34
 
29
35
  def draw(opts = {})
36
+ Window.render_ready_check
37
+
30
38
  opts[:width] = opts[:width] || @width
31
39
  opts[:height] = opts[:height] || @height
32
40
  opts[:rotate] = opts[:rotate] || @rotate
@@ -34,20 +42,17 @@ module Ruby2D
34
42
  opts[:color] = [1.0, 1.0, 1.0, 1.0]
35
43
  end
36
44
 
37
- self.class.ext_draw([
38
- self, opts[:x], opts[:y], opts[:width], opts[:height], opts[:rotate],
39
- opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]
40
- ])
45
+ render(x: opts[:x], y: opts[:y], width: opts[:width], height: opts[:height], color: Color.new(opts[:color]), rotate: opts[:rotate])
41
46
  end
42
47
 
43
48
  private
44
49
 
45
- def render
46
- self.class.ext_draw([
47
- self, @x, @y, @width, @height, @rotate,
48
- @color.r, @color.g, @color.b, @color.a
49
- ])
50
- end
50
+ def render(x: @x, y: @y, width: @width, height: @height, color: @color, rotate: @rotate)
51
+ vertices = Vertices.new(x, y, width, height, rotate)
51
52
 
53
+ @texture.draw(
54
+ vertices.coordinates, vertices.texture_coordinates, color
55
+ )
56
+ end
52
57
  end
53
58
  end
data/lib/ruby2d/line.rb CHANGED
@@ -14,7 +14,7 @@ module Ruby2D
14
14
  @z = opts[:z] || 0
15
15
  @width = opts[:width] || 2
16
16
  self.color = opts[:color] || 'white'
17
- self.opacity = opts[:opacity] if opts[:opacity]
17
+ self.color.opacity = opts[:opacity] if opts[:opacity]
18
18
  add
19
19
  end
20
20
 
@@ -39,6 +39,8 @@ module Ruby2D
39
39
  end
40
40
 
41
41
  def self.draw(opts = {})
42
+ Window.render_ready_check
43
+
42
44
  ext_draw([
43
45
  opts[:x1], opts[:y1], opts[:x2], opts[:y2], opts[:width],
44
46
  opts[:color][0][0], opts[:color][0][1], opts[:color][0][2], opts[:color][0][3],
data/lib/ruby2d/quad.rb CHANGED
@@ -25,7 +25,7 @@ module Ruby2D
25
25
  @y4 = opts[:y4] || 100
26
26
  @z = opts[:z] || 0
27
27
  self.color = opts[:color] || 'white'
28
- self.opacity = opts[:opacity] if opts[:opacity]
28
+ self.color.opacity = opts[:opacity] if opts[:opacity]
29
29
  add
30
30
  end
31
31
 
@@ -49,6 +49,8 @@ module Ruby2D
49
49
  end
50
50
 
51
51
  def self.draw(opts = {})
52
+ Window.render_ready_check
53
+
52
54
  ext_draw([
53
55
  opts[:x1], opts[:y1], opts[:color][0][0], opts[:color][0][1], opts[:color][0][2], opts[:color][0][3],
54
56
  opts[:x2], opts[:y2], opts[:color][1][0], opts[:color][1][1], opts[:color][1][2], opts[:color][1][3],
@@ -10,7 +10,7 @@ module Ruby2D
10
10
  @width = opts[:width] || 200
11
11
  @height = opts[:height] || 100
12
12
  self.color = opts[:color] || 'white'
13
- self.opacity = opts[:opacity] if opts[:opacity]
13
+ self.color.opacity = opts[:opacity] if opts[:opacity]
14
14
  update_coords(@x, @y, @width, @height)
15
15
  add
16
16
  end
@@ -31,18 +31,6 @@ module Ruby2D
31
31
  alias_method :colour, :color
32
32
  alias_method :colour=, :color=
33
33
 
34
- # Allow shortcuts for setting color values
35
- def r; self.color.r end
36
- def g; self.color.g end
37
- def b; self.color.b end
38
- def a; self.color.a end
39
- def r=(c); self.color.r = c end
40
- def g=(c); self.color.g = c end
41
- def b=(c); self.color.b = c end
42
- def a=(c); self.color.a = c end
43
- def opacity; self.color.opacity end
44
- def opacity=(val); self.color.opacity = val end
45
-
46
34
  # Add a contains method stub
47
35
  def contains?(x, y)
48
36
  x >= @x && x <= (@x + @width) && y >= @y && y <= (@y + @height)
data/lib/ruby2d/sound.rb CHANGED
@@ -26,5 +26,30 @@ module Ruby2D
26
26
  ext_length
27
27
  end
28
28
 
29
+ # Get the volume of the sound
30
+ def volume
31
+ ext_get_volume
32
+ end
33
+
34
+ # Set the volume of the sound
35
+ def volume=(v)
36
+ # Clamp value to between 0-100
37
+ if v < 0 then v = 0 end
38
+ if v > 100 then v = 100 end
39
+ ext_set_volume(v)
40
+ end
41
+
42
+ # Get the volume of the sound mixer
43
+ def self.mix_volume
44
+ ext_get_mix_volume
45
+ end
46
+
47
+ # Set the volume of the sound mixer
48
+ def self.mix_volume=(v)
49
+ # Clamp value to between 0-100
50
+ if v < 0 then v = 0 end
51
+ if v > 100 then v = 100 end
52
+ ext_set_mix_volume(v)
53
+ end
29
54
  end
30
55
  end