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/window.c CHANGED
@@ -50,10 +50,249 @@ R2D_Window *R2D_CreateWindow(const char *title, int width, int height,
50
50
  }
51
51
 
52
52
 
53
+ const Uint8 *key_state;
54
+
55
+ Uint32 frames;
56
+ Uint32 frames_last_sec;
57
+ Uint32 start_ms;
58
+ Uint32 next_second_ms;
59
+ Uint32 begin_ms;
60
+ Uint32 end_ms; // Time at end of loop
61
+ Uint32 elapsed_ms; // Total elapsed time
62
+ Uint32 loop_ms; // Elapsed time of current loop
63
+ int delay_ms; // Amount of delay to achieve desired frame rate
64
+ double decay_rate;
65
+ double fps;
66
+
67
+ R2D_Window *window;
68
+
69
+
70
+
71
+
72
+
73
+ void main_loop() {
74
+
75
+ // Clear Frame /////////////////////////////////////////////////////////////
76
+
77
+ R2D_GL_Clear(window->background);
78
+
79
+ // Set FPS /////////////////////////////////////////////////////////////////
80
+
81
+ frames++;
82
+ frames_last_sec++;
83
+ end_ms = SDL_GetTicks();
84
+ elapsed_ms = end_ms - start_ms;
85
+
86
+ // Calculate the frame rate using an exponential moving average
87
+ if (next_second_ms < end_ms) {
88
+ fps = decay_rate * fps + (1.0 - decay_rate) * frames_last_sec;
89
+ frames_last_sec = 0;
90
+ next_second_ms = SDL_GetTicks() + 1000;
91
+ }
92
+
93
+ loop_ms = end_ms - begin_ms;
94
+ delay_ms = (1000 / window->fps_cap) - loop_ms;
95
+
96
+ if (delay_ms < 0) delay_ms = 0;
97
+
98
+ // Note: `loop_ms + delay_ms` should equal `1000 / fps_cap`
99
+
100
+ #ifndef __EMSCRIPTEN__
101
+ SDL_Delay(delay_ms);
102
+ #endif
103
+
104
+ begin_ms = SDL_GetTicks();
105
+
106
+ // Handle Input and Window Events //////////////////////////////////////////
107
+
108
+ int mx, my; // mouse x, y coordinates
109
+
110
+ SDL_Event e;
111
+ while (SDL_PollEvent(&e)) {
112
+ switch (e.type) {
113
+
114
+ case SDL_KEYDOWN:
115
+ if (window->on_key && e.key.repeat == 0) {
116
+ R2D_Event event = {
117
+ .type = R2D_KEY_DOWN, .key = SDL_GetScancodeName(e.key.keysym.scancode)
118
+ };
119
+ window->on_key(event);
120
+ }
121
+ break;
122
+
123
+ case SDL_KEYUP:
124
+ if (window->on_key) {
125
+ R2D_Event event = {
126
+ .type = R2D_KEY_UP, .key = SDL_GetScancodeName(e.key.keysym.scancode)
127
+ };
128
+ window->on_key(event);
129
+ }
130
+ break;
131
+
132
+ case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP:
133
+ if (window->on_mouse) {
134
+ R2D_GetMouseOnViewport(window, e.button.x, e.button.y, &mx, &my);
135
+ R2D_Event event = {
136
+ .button = e.button.button, .x = mx, .y = my
137
+ };
138
+ event.type = e.type == SDL_MOUSEBUTTONDOWN ? R2D_MOUSE_DOWN : R2D_MOUSE_UP;
139
+ event.dblclick = e.button.clicks == 2 ? true : false;
140
+ window->on_mouse(event);
141
+ }
142
+ break;
143
+
144
+ case SDL_MOUSEWHEEL:
145
+ if (window->on_mouse) {
146
+ R2D_Event event = {
147
+ .type = R2D_MOUSE_SCROLL, .direction = e.wheel.direction,
148
+ .delta_x = e.wheel.x, .delta_y = -e.wheel.y
149
+ };
150
+ window->on_mouse(event);
151
+ }
152
+ break;
153
+
154
+ case SDL_MOUSEMOTION:
155
+ if (window->on_mouse) {
156
+ R2D_GetMouseOnViewport(window, e.motion.x, e.motion.y, &mx, &my);
157
+ R2D_Event event = {
158
+ .type = R2D_MOUSE_MOVE,
159
+ .x = mx, .y = my, .delta_x = e.motion.xrel, .delta_y = e.motion.yrel
160
+ };
161
+ window->on_mouse(event);
162
+ }
163
+ break;
164
+
165
+ case SDL_CONTROLLERAXISMOTION:
166
+ if (window->on_controller) {
167
+ R2D_Event event = {
168
+ .which = e.caxis.which, .type = R2D_AXIS,
169
+ .axis = e.caxis.axis, .value = e.caxis.value
170
+ };
171
+ window->on_controller(event);
172
+ }
173
+ break;
174
+
175
+ case SDL_JOYAXISMOTION:
176
+ if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
177
+ R2D_Event event = {
178
+ .which = e.jaxis.which, .type = R2D_AXIS,
179
+ .axis = e.jaxis.axis, .value = e.jaxis.value
180
+ };
181
+ window->on_controller(event);
182
+ }
183
+ break;
184
+
185
+ case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP:
186
+ if (window->on_controller) {
187
+ R2D_Event event = {
188
+ .which = e.cbutton.which, .button = e.cbutton.button
189
+ };
190
+ event.type = e.type == SDL_CONTROLLERBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
191
+ window->on_controller(event);
192
+ }
193
+ break;
194
+
195
+ case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP:
196
+ if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
197
+ R2D_Event event = {
198
+ .which = e.jbutton.which, .button = e.jbutton.button
199
+ };
200
+ event.type = e.type == SDL_JOYBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
201
+ window->on_controller(event);
202
+ }
203
+ break;
204
+
205
+ case SDL_JOYDEVICEADDED:
206
+ R2D_Log(R2D_INFO, "Controller connected (%i total)", SDL_NumJoysticks());
207
+ R2D_OpenControllers();
208
+ break;
209
+
210
+ case SDL_JOYDEVICEREMOVED:
211
+ if (R2D_IsController(e.jdevice.which)) {
212
+ R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_GameControllerName(SDL_GameControllerFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
213
+ SDL_GameControllerClose(SDL_GameControllerFromInstanceID(e.jdevice.which));
214
+ } else {
215
+ R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_JoystickName(SDL_JoystickFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
216
+ SDL_JoystickClose(SDL_JoystickFromInstanceID(e.jdevice.which));
217
+ }
218
+ break;
219
+
220
+ case SDL_WINDOWEVENT:
221
+ switch (e.window.event) {
222
+ case SDL_WINDOWEVENT_RESIZED:
223
+ // Store new window size, set viewport
224
+ window->width = e.window.data1;
225
+ window->height = e.window.data2;
226
+ R2D_GL_SetViewport(window);
227
+ break;
228
+ }
229
+ break;
230
+
231
+ case SDL_QUIT:
232
+ R2D_Close(window);
233
+ break;
234
+ }
235
+ }
236
+
237
+ // Detect keys held down
238
+ int num_keys;
239
+ key_state = SDL_GetKeyboardState(&num_keys);
240
+
241
+ for (int i = 0; i < num_keys; i++) {
242
+ if (window->on_key) {
243
+ if (key_state[i] == 1) {
244
+ R2D_Event event = {
245
+ .type = R2D_KEY_HELD, .key = SDL_GetScancodeName(i)
246
+ };
247
+ window->on_key(event);
248
+ }
249
+ }
250
+ }
251
+
252
+ // Get and store mouse position relative to the viewport
253
+ int wx, wy; // mouse x, y coordinates relative to the window
254
+ SDL_GetMouseState(&wx, &wy);
255
+ R2D_GetMouseOnViewport(window, wx, wy, &window->mouse.x, &window->mouse.y);
256
+
257
+ // Update Window State /////////////////////////////////////////////////////
258
+
259
+ // Store new values in the window
260
+ window->frames = frames;
261
+ window->elapsed_ms = elapsed_ms;
262
+ window->loop_ms = loop_ms;
263
+ window->delay_ms = delay_ms;
264
+ window->fps = fps;
265
+
266
+ // Call update and render callbacks
267
+ if (window->update) window->update();
268
+ if (window->render) window->render();
269
+
270
+ // Draw Frame //////////////////////////////////////////////////////////////
271
+
272
+ // Render and flush all OpenGL buffers
273
+ R2D_GL_FlushBuffers();
274
+
275
+ // Swap buffers to display drawn contents in the window
276
+ SDL_GL_SwapWindow(window->sdl);
277
+ }
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
53
290
  /*
54
291
  * Show the window
55
292
  */
56
- int R2D_Show(R2D_Window *window) {
293
+ int R2D_Show(R2D_Window *win) {
294
+
295
+ window = win;
57
296
 
58
297
  if (!window) {
59
298
  R2D_Error("R2D_Show", "Window cannot be shown (because it's NULL)");
@@ -99,19 +338,14 @@ int R2D_Show(R2D_Window *window) {
99
338
 
100
339
  // Set Main Loop Data ////////////////////////////////////////////////////////
101
340
 
102
- const Uint8 *key_state;
103
341
 
104
- Uint32 frames = 0; // Total frames since start
105
- Uint32 frames_last_sec = 0; // Frames in the last second
106
- Uint32 start_ms = SDL_GetTicks(); // Elapsed time since start
107
- Uint32 next_second_ms = SDL_GetTicks(); // The last time plus a second
108
- Uint32 begin_ms = start_ms; // Time at beginning of loop
109
- Uint32 end_ms; // Time at end of loop
110
- Uint32 elapsed_ms; // Total elapsed time
111
- Uint32 loop_ms; // Elapsed time of loop
112
- int delay_ms; // Amount of delay to achieve desired frame rate
113
- const double decay_rate = 0.5; // Determines how fast an average decays over time
114
- double fps = window->fps_cap; // Moving average of actual FPS, initial value a guess
342
+ frames = 0; // Total frames since start
343
+ frames_last_sec = 0; // Frames in the last second
344
+ start_ms = SDL_GetTicks(); // Elapsed time since start
345
+ next_second_ms = SDL_GetTicks(); // The last time plus a second
346
+ begin_ms = start_ms; // Time at beginning of loop
347
+ decay_rate = 0.5; // Determines how fast an average decays over time
348
+ fps = window->fps_cap; // Moving average of actual FPS, initial value a guess
115
349
 
116
350
  // Enable VSync
117
351
  if (window->vsync) {
@@ -124,222 +358,26 @@ int R2D_Show(R2D_Window *window) {
124
358
 
125
359
  // Main Loop /////////////////////////////////////////////////////////////////
126
360
 
127
- while (!window->close) {
128
-
129
- // Clear Frame /////////////////////////////////////////////////////////////
130
-
131
- R2D_GL_Clear(window->background);
132
-
133
- // Set FPS /////////////////////////////////////////////////////////////////
134
-
135
- frames++;
136
- frames_last_sec++;
137
- end_ms = SDL_GetTicks();
138
- elapsed_ms = end_ms - start_ms;
139
-
140
- // Calculate the frame rate using an exponential moving average
141
- if (next_second_ms < end_ms) {
142
- fps = decay_rate * fps + (1.0 - decay_rate) * frames_last_sec;
143
- frames_last_sec = 0;
144
- next_second_ms = SDL_GetTicks() + 1000;
145
- }
146
-
147
- loop_ms = end_ms - begin_ms;
148
- delay_ms = (1000 / window->fps_cap) - loop_ms;
149
-
150
- if (delay_ms < 0) delay_ms = 0;
151
-
152
- // Note: `loop_ms + delay_ms` should equal `1000 / fps_cap`
153
-
154
- SDL_Delay(delay_ms);
155
- begin_ms = SDL_GetTicks();
156
-
157
- // Handle Input and Window Events //////////////////////////////////////////
158
-
159
- int mx, my; // mouse x, y coordinates
160
-
161
- SDL_Event e;
162
- while (SDL_PollEvent(&e)) {
163
- switch (e.type) {
164
-
165
- case SDL_KEYDOWN:
166
- if (window->on_key && e.key.repeat == 0) {
167
- R2D_Event event = {
168
- .type = R2D_KEY_DOWN, .key = SDL_GetScancodeName(e.key.keysym.scancode)
169
- };
170
- window->on_key(event);
171
- }
172
- break;
173
-
174
- case SDL_KEYUP:
175
- if (window->on_key) {
176
- R2D_Event event = {
177
- .type = R2D_KEY_UP, .key = SDL_GetScancodeName(e.key.keysym.scancode)
178
- };
179
- window->on_key(event);
180
- }
181
- break;
182
-
183
- case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP:
184
- if (window->on_mouse) {
185
- R2D_GetMouseOnViewport(window, e.button.x, e.button.y, &mx, &my);
186
- R2D_Event event = {
187
- .button = e.button.button, .x = mx, .y = my
188
- };
189
- event.type = e.type == SDL_MOUSEBUTTONDOWN ? R2D_MOUSE_DOWN : R2D_MOUSE_UP;
190
- event.dblclick = e.button.clicks == 2 ? true : false;
191
- window->on_mouse(event);
192
- }
193
- break;
194
-
195
- case SDL_MOUSEWHEEL:
196
- if (window->on_mouse) {
197
- R2D_Event event = {
198
- .type = R2D_MOUSE_SCROLL, .direction = e.wheel.direction,
199
- .delta_x = e.wheel.x, .delta_y = -e.wheel.y
200
- };
201
- window->on_mouse(event);
202
- }
203
- break;
204
-
205
- case SDL_MOUSEMOTION:
206
- if (window->on_mouse) {
207
- R2D_GetMouseOnViewport(window, e.motion.x, e.motion.y, &mx, &my);
208
- R2D_Event event = {
209
- .type = R2D_MOUSE_MOVE,
210
- .x = mx, .y = my, .delta_x = e.motion.xrel, .delta_y = e.motion.yrel
211
- };
212
- window->on_mouse(event);
213
- }
214
- break;
215
-
216
- case SDL_CONTROLLERAXISMOTION:
217
- if (window->on_controller) {
218
- R2D_Event event = {
219
- .which = e.caxis.which, .type = R2D_AXIS,
220
- .axis = e.caxis.axis, .value = e.caxis.value
221
- };
222
- window->on_controller(event);
223
- }
224
- break;
225
-
226
- case SDL_JOYAXISMOTION:
227
- if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
228
- R2D_Event event = {
229
- .which = e.jaxis.which, .type = R2D_AXIS,
230
- .axis = e.jaxis.axis, .value = e.jaxis.value
231
- };
232
- window->on_controller(event);
233
- }
234
- break;
235
-
236
- case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP:
237
- if (window->on_controller) {
238
- R2D_Event event = {
239
- .which = e.cbutton.which, .button = e.cbutton.button
240
- };
241
- event.type = e.type == SDL_CONTROLLERBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
242
- window->on_controller(event);
243
- }
244
- break;
245
-
246
- case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP:
247
- if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
248
- R2D_Event event = {
249
- .which = e.jbutton.which, .button = e.jbutton.button
250
- };
251
- event.type = e.type == SDL_JOYBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
252
- window->on_controller(event);
253
- }
254
- break;
255
-
256
- case SDL_JOYDEVICEADDED:
257
- R2D_Log(R2D_INFO, "Controller connected (%i total)", SDL_NumJoysticks());
258
- R2D_OpenControllers();
259
- break;
260
-
261
- case SDL_JOYDEVICEREMOVED:
262
- if (R2D_IsController(e.jdevice.which)) {
263
- R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_GameControllerName(SDL_GameControllerFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
264
- SDL_GameControllerClose(SDL_GameControllerFromInstanceID(e.jdevice.which));
265
- } else {
266
- R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_JoystickName(SDL_JoystickFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
267
- SDL_JoystickClose(SDL_JoystickFromInstanceID(e.jdevice.which));
268
- }
269
- break;
270
-
271
- case SDL_WINDOWEVENT:
272
- switch (e.window.event) {
273
- case SDL_WINDOWEVENT_RESIZED:
274
- // Store new window size, set viewport
275
- window->width = e.window.data1;
276
- window->height = e.window.data2;
277
- R2D_GL_SetViewport(window);
278
- break;
279
- }
280
- break;
281
-
282
- case SDL_QUIT:
283
- R2D_Close(window);
284
- break;
285
- }
286
- }
287
-
288
- // Detect keys held down
289
- int num_keys;
290
- key_state = SDL_GetKeyboardState(&num_keys);
291
-
292
- for (int i = 0; i < num_keys; i++) {
293
- if (window->on_key) {
294
- if (key_state[i] == 1) {
295
- R2D_Event event = {
296
- .type = R2D_KEY_HELD, .key = SDL_GetScancodeName(i)
297
- };
298
- window->on_key(event);
299
- }
300
- }
301
- }
302
-
303
- // Get and store mouse position relative to the viewport
304
- int wx, wy; // mouse x, y coordinates relative to the window
305
- SDL_GetMouseState(&wx, &wy);
306
- R2D_GetMouseOnViewport(window, wx, wy, &window->mouse.x, &window->mouse.y);
307
-
308
- // Update Window State /////////////////////////////////////////////////////
309
-
310
- // Store new values in the window
311
- window->frames = frames;
312
- window->elapsed_ms = elapsed_ms;
313
- window->loop_ms = loop_ms;
314
- window->delay_ms = delay_ms;
315
- window->fps = fps;
316
-
317
- // Call update and render callbacks
318
- if (window->update) window->update();
319
- if (window->render) window->render();
320
-
321
- // Draw Frame //////////////////////////////////////////////////////////////
322
-
323
- // Render and flush all OpenGL buffers
324
- R2D_GL_FlushBuffers();
325
-
326
- // Swap buffers to display drawn contents in the window
327
- SDL_GL_SwapWindow(window->sdl);
328
- }
361
+ #ifdef __EMSCRIPTEN__
362
+ emscripten_set_main_loop(main_loop, 0, true);
363
+ #else
364
+ while (!window->close) main_loop();
365
+ #endif
329
366
 
330
367
  return 0;
331
368
  }
332
369
 
333
370
 
371
+
334
372
  /*
335
373
  * Set the icon for the window
336
374
  */
337
375
  void R2D_SetIcon(R2D_Window *window, const char *icon) {
338
- R2D_Image *img = R2D_CreateImage(icon);
339
- if (img) {
376
+ SDL_Surface *iconSurface = R2D_CreateImageSurface(icon);
377
+ if (iconSurface) {
340
378
  window->icon = icon;
341
- SDL_SetWindowIcon(window->sdl, img->surface);
342
- R2D_FreeImage(img);
379
+ SDL_SetWindowIcon(window->sdl, iconSurface);
380
+ SDL_FreeSurface(iconSurface);
343
381
  } else {
344
382
  R2D_Log(R2D_WARN, "Could not set window icon");
345
383
  }
data/lib/ruby2d/circle.rb CHANGED
@@ -13,7 +13,7 @@ module Ruby2D
13
13
  @radius = opts[:radius] || 50
14
14
  @sectors = opts[:sectors] || 30
15
15
  self.color = opts[:color] || 'white'
16
- self.opacity = opts[:opacity] if opts[:opacity]
16
+ self.color.opacity = opts[:opacity] if opts[:opacity]
17
17
  add
18
18
  end
19
19
 
@@ -22,6 +22,8 @@ module Ruby2D
22
22
  end
23
23
 
24
24
  def self.draw(opts = {})
25
+ Window.render_ready_check
26
+
25
27
  ext_draw([
26
28
  opts[:x], opts[:y], opts[:radius], opts[:sectors],
27
29
  opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]