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/gl.c CHANGED
@@ -20,7 +20,7 @@ static GLfloat orthoMatrix[16] =
20
20
  /*
21
21
  * Prints current GL error
22
22
  */
23
- void R2D_GL_PrintError(char *error) {
23
+ void R2D_GL_PrintError(const char *error) {
24
24
  R2D_Log(R2D_ERROR, "%s (%d)", error, glGetError());
25
25
  }
26
26
 
@@ -69,7 +69,7 @@ void R2D_GL_StoreContextInfo(R2D_Window *window) {
69
69
  * Creates a shader object, loads shader string, and compiles.
70
70
  * Returns 0 if shader could not be compiled.
71
71
  */
72
- GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName) {
72
+ GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, const char *shaderName) {
73
73
 
74
74
  // Create the shader object
75
75
  GLuint shader = glCreateShader(type);
@@ -111,7 +111,7 @@ GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName)
111
111
  /*
112
112
  * Check if shader program was linked
113
113
  */
114
- int R2D_GL_CheckLinked(GLuint program, char *name) {
114
+ int R2D_GL_CheckLinked(GLuint program, const char *name) {
115
115
 
116
116
  GLint linked;
117
117
  glGetProgramiv(program, GL_LINK_STATUS, &linked);
@@ -361,65 +361,16 @@ void R2D_GL_DrawTriangle(GLfloat x1, GLfloat y1,
361
361
 
362
362
 
363
363
  /*
364
- * Draw an image
364
+ * Draw a texture
365
365
  */
366
- void R2D_GL_DrawImage(R2D_Image *img) {
366
+ void R2D_GL_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id) {
367
367
  #if GLES
368
- R2D_GLES_DrawImage(img);
368
+ R2D_GLES_DrawTexture(coordinates, texture_coordinates, color, texture_id);
369
369
  #else
370
370
  if (R2D_GL2) {
371
- R2D_GL2_DrawImage(img);
371
+ R2D_GL2_DrawTexture(coordinates, texture_coordinates, color, texture_id);
372
372
  } else {
373
- R2D_GL3_DrawImage(img);
374
- }
375
- #endif
376
- }
377
-
378
-
379
- /*
380
- * Draw sprite
381
- */
382
- void R2D_GL_DrawSprite(R2D_Sprite *spr) {
383
- #if GLES
384
- R2D_GLES_DrawSprite(spr);
385
- #else
386
- if (R2D_GL2) {
387
- R2D_GL2_DrawSprite(spr);
388
- } else {
389
- R2D_GL3_DrawSprite(spr);
390
- }
391
- #endif
392
- }
393
-
394
-
395
- /*
396
- * Draw a tile
397
- */
398
- void R2D_GL_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
399
- GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
400
- #if GLES
401
- R2D_GLES_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
402
- #else
403
- if (R2D_GL2) {
404
- R2D_GL2_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
405
- } else {
406
- R2D_GL3_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
407
- }
408
- #endif
409
- }
410
-
411
-
412
- /*
413
- * Draw text
414
- */
415
- void R2D_GL_DrawText(R2D_Text *txt) {
416
- #if GLES
417
- R2D_GLES_DrawText(txt);
418
- #else
419
- if (R2D_GL2) {
420
- R2D_GL2_DrawText(txt);
421
- } else {
422
- R2D_GL3_DrawText(txt);
373
+ R2D_GL3_DrawTexture(coordinates, texture_coordinates, color, texture_id);
423
374
  }
424
375
  #endif
425
376
  }
@@ -431,7 +382,7 @@ void R2D_GL_DrawText(R2D_Text *txt) {
431
382
  void R2D_GL_FlushBuffers() {
432
383
  // Only implemented in our OpenGL 3.3+ and ES 2.0 renderers
433
384
  #if GLES
434
- // TODO: R2D_GLES_FlushBuffers();
385
+ R2D_GLES_FlushBuffers();
435
386
  #else
436
387
  if (!R2D_GL2) R2D_GL3_FlushBuffers();
437
388
  #endif
data/ext/ruby2d/gl2.c CHANGED
@@ -64,98 +64,23 @@ void R2D_GL2_DrawTriangle(GLfloat x1, GLfloat y1,
64
64
 
65
65
 
66
66
  /*
67
- * Draw texture
67
+ * Draw a texture (New method with vertices pre-calculated)
68
68
  */
69
- static void R2D_GL2_DrawTexture(int x, int y, int w, int h,
70
- GLfloat angle, GLfloat rx, GLfloat ry,
71
- GLfloat r, GLfloat g, GLfloat b, GLfloat a,
72
- GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
73
- GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4,
74
- GLuint texture_id) {
75
-
76
- R2D_GL_Point v1 = { .x = x, .y = y };
77
- R2D_GL_Point v2 = { .x = x + w, .y = y };
78
- R2D_GL_Point v3 = { .x = x + w, .y = y + h };
79
- R2D_GL_Point v4 = { .x = x, .y = y + h };
80
-
81
- // Rotate vertices
82
- if (angle != 0) {
83
- v1 = R2D_RotatePoint(v1, angle, rx, ry);
84
- v2 = R2D_RotatePoint(v2, angle, rx, ry);
85
- v3 = R2D_RotatePoint(v3, angle, rx, ry);
86
- v4 = R2D_RotatePoint(v4, angle, rx, ry);
87
- }
88
-
69
+ void R2D_GL2_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id) {
89
70
  glEnable(GL_TEXTURE_2D);
90
71
 
91
72
  glBindTexture(GL_TEXTURE_2D, texture_id);
92
73
 
93
74
  glBegin(GL_QUADS);
94
- glColor4f(r, g, b, a);
95
- glTexCoord2f(tx1, ty1); glVertex2f(v1.x, v1.y);
96
- glTexCoord2f(tx2, ty2); glVertex2f(v2.x, v2.y);
97
- glTexCoord2f(tx3, ty3); glVertex2f(v3.x, v3.y);
98
- glTexCoord2f(tx4, ty4); glVertex2f(v4.x, v4.y);
75
+ glColor4f(color[0], color[1], color[2], color[3]);
76
+ glTexCoord2f(texture_coordinates[0], texture_coordinates[1]); glVertex2f(coordinates[0], coordinates[1]);
77
+ glTexCoord2f(texture_coordinates[2], texture_coordinates[3]); glVertex2f(coordinates[2], coordinates[3]);
78
+ glTexCoord2f(texture_coordinates[4], texture_coordinates[5]); glVertex2f(coordinates[4], coordinates[5]);
79
+ glTexCoord2f(texture_coordinates[6], texture_coordinates[7]); glVertex2f(coordinates[6], coordinates[7]);
99
80
  glEnd();
100
81
 
101
82
  glDisable(GL_TEXTURE_2D);
102
- }
103
-
104
-
105
- /*
106
- * Draw image
107
- */
108
- void R2D_GL2_DrawImage(R2D_Image *img) {
109
- R2D_GL2_DrawTexture(
110
- img->x, img->y, img->width, img->height,
111
- img->rotate, img->rx, img->ry,
112
- img->color.r, img->color.g, img->color.b, img->color.a,
113
- 0.f, 0.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f,
114
- img->texture_id
115
- );
116
- }
117
-
118
-
119
- /*
120
- * Draw sprite
121
- */
122
- void R2D_GL2_DrawSprite(R2D_Sprite *spr) {
123
- R2D_GL2_DrawTexture(
124
- spr->x, spr->y, spr->width, spr->height,
125
- spr->rotate, spr->rx, spr->ry,
126
- spr->color.r, spr->color.g, spr->color.b, spr->color.a,
127
- spr->tx1, spr->ty1, spr->tx2, spr->ty2, spr->tx3, spr->ty3, spr->tx4, spr->ty4,
128
- spr->img->texture_id
129
- );
130
- }
131
-
83
+ };
132
84
 
133
- /*
134
- * Draw a tile
135
- */
136
- void R2D_GL2_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
137
- GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
138
- R2D_GL2_DrawTexture(
139
- x, y, tw, th,
140
- img->rotate, img->rx, img->ry,
141
- img->color.r, img->color.g, img->color.b, img->color.a,
142
- tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
143
- img->texture_id
144
- );
145
- }
146
-
147
-
148
- /*
149
- * Draw text
150
- */
151
- void R2D_GL2_DrawText(R2D_Text *txt) {
152
- R2D_GL2_DrawTexture(
153
- txt->x, txt->y, txt->width, txt->height,
154
- txt->rotate, txt->rx, txt->ry,
155
- txt->color.r, txt->color.g, txt->color.b, txt->color.a,
156
- 0.f, 0.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f,
157
- txt->texture_id
158
- );
159
- }
160
85
 
161
86
  #endif
data/ext/ruby2d/gl3.c CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  #include "ruby2d.h"
4
4
 
5
- // Skip this file if OpenGL ES
6
5
  #if !GLES
7
6
 
8
7
  static GLuint vbo; // our primary vertex buffer object (VBO)
@@ -10,12 +9,10 @@ static GLuint vboSize; // size of the VBO in bytes
10
9
  static GLfloat *vboData; // pointer to the VBO data
11
10
  static GLfloat *vboDataCurrent; // pointer to the data for the current vertices
12
11
  static GLuint vboDataIndex = 0; // index of the current object being rendered
13
- static GLuint vboObjCapacity = 2500; // number of objects the VBO can store
12
+ static GLuint vboObjCapacity = 7500; // number of objects the VBO can store
13
+ static GLuint verticesTextureIds[7500]; // store the texture_id of each vertices
14
14
  static GLuint shaderProgram; // triangle shader program
15
15
  static GLuint texShaderProgram; // texture shader program
16
- static GLuint indices[] = // indices for rendering textured quads
17
- { 0, 1, 2,
18
- 2, 3, 0 };
19
16
 
20
17
 
21
18
  /*
@@ -106,7 +103,7 @@ int R2D_GL3_Init() {
106
103
  // Create a vertex buffer object and allocate data
107
104
  glGenBuffers(1, &vbo);
108
105
  glBindBuffer(GL_ARRAY_BUFFER, vbo);
109
- vboSize = vboObjCapacity * sizeof(GLfloat) * 24;
106
+ vboSize = vboObjCapacity * sizeof(GLfloat) * 8;
110
107
  vboData = (GLfloat *) malloc(vboSize);
111
108
  vboDataCurrent = vboData;
112
109
 
@@ -207,17 +204,39 @@ int R2D_GL3_Init() {
207
204
  * Render the vertex buffer and reset it
208
205
  */
209
206
  void R2D_GL3_FlushBuffers() {
210
-
211
- // Use the triangle shader program
212
- glUseProgram(shaderProgram);
213
-
214
207
  // Bind to the vertex buffer object and update its data
215
208
  glBindBuffer(GL_ARRAY_BUFFER, vbo);
209
+
216
210
  glBufferData(GL_ARRAY_BUFFER, vboSize, NULL, GL_DYNAMIC_DRAW);
217
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * vboDataIndex * 24, vboData);
211
+ glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * vboDataIndex * 8, vboData);
212
+
213
+ GLuint verticesOffset = 0;
214
+ GLuint lastTextureId = verticesTextureIds[0];
215
+
216
+ for (GLuint i = 0; i <= vboDataIndex; i++) {
217
+ if(lastTextureId != verticesTextureIds[i] || i == vboDataIndex) {
218
+ // A texture ID of 0 represents no texture (render a triangle)
219
+ if(lastTextureId == 0) {
220
+
221
+ // Use the triangle shader program
222
+ glUseProgram(shaderProgram);
223
+
224
+ // A number other than 0 represents a texture_id
225
+ } else {
226
+
227
+ // Use the texture shader program
228
+ glUseProgram(texShaderProgram);
229
+
230
+ // Bind the texture using the provided ID
231
+ glBindTexture(GL_TEXTURE_2D, lastTextureId);
232
+ }
233
+
234
+ glDrawArrays(GL_TRIANGLES, verticesOffset, i - verticesOffset);
218
235
 
219
- // Render all the triangles in the buffer
220
- glDrawArrays(GL_TRIANGLES, 0, (GLsizei)(vboDataIndex * 3));
236
+ lastTextureId = verticesTextureIds[i];
237
+ verticesOffset = i;
238
+ }
239
+ }
221
240
 
222
241
  // Reset the buffer object index and data pointer
223
242
  vboDataIndex = 0;
@@ -236,10 +255,10 @@ void R2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
236
255
  GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3) {
237
256
 
238
257
  // If buffer is full, flush it
239
- if (vboDataIndex >= vboObjCapacity) R2D_GL3_FlushBuffers();
258
+ if (vboDataIndex + 3 >= vboObjCapacity) R2D_GL3_FlushBuffers();
240
259
 
241
260
  // Set the triangle data into a formatted array
242
- GLfloat vertices[] =
261
+ GLfloat vertices[24] =
243
262
  { x1, y1, r1, g1, b1, a1, 0, 0,
244
263
  x2, y2, r2, g2, b2, a2, 0, 0,
245
264
  x3, y3, r3, g3, b3, a3, 0, 0 };
@@ -248,116 +267,38 @@ void R2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
248
267
  memcpy(vboDataCurrent, vertices, sizeof(vertices));
249
268
 
250
269
  // Increment the buffer object index and the vertex data pointer for next use
251
- vboDataIndex++;
270
+ verticesTextureIds[vboDataIndex] = verticesTextureIds[vboDataIndex + 1] = verticesTextureIds[vboDataIndex + 2] = 0;
271
+ vboDataIndex += 3;
252
272
  vboDataCurrent = (GLfloat *)((char *)vboDataCurrent + (sizeof(GLfloat) * 24));
253
273
  }
254
274
 
255
275
 
256
276
  /*
257
- * Draw a texture
277
+ * Draw a texture (New method with vertices pre-calculated)
258
278
  */
259
- static void R2D_GL3_DrawTexture(int x, int y, int w, int h,
260
- GLfloat angle, GLfloat rx, GLfloat ry,
261
- GLfloat r, GLfloat g, GLfloat b, GLfloat a,
262
- GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
263
- GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4,
264
- GLuint texture_id) {
265
-
266
- // Currently, textures are not buffered, so we have to flush all buffers so
267
- // textures get rendered in the correct Z order
268
- R2D_GL3_FlushBuffers();
269
-
270
- // Set up the vertex points
271
- R2D_GL_Point v1 = { .x = x, .y = y };
272
- R2D_GL_Point v2 = { .x = x + w, .y = y };
273
- R2D_GL_Point v3 = { .x = x + w, .y = y + h };
274
- R2D_GL_Point v4 = { .x = x, .y = y + h };
275
-
276
- // Rotate vertices
277
- if (angle != 0) {
278
- v1 = R2D_RotatePoint(v1, angle, rx, ry);
279
- v2 = R2D_RotatePoint(v2, angle, rx, ry);
280
- v3 = R2D_RotatePoint(v3, angle, rx, ry);
281
- v4 = R2D_RotatePoint(v4, angle, rx, ry);
282
- }
283
-
284
- // Set the textured quad data into a formatted array
285
- GLfloat vertices[] =
286
- // vertex coords | colors | x, y texture coords
287
- { v1.x, v1.y, r, g, b, a, tx1, ty1, // Top-left
288
- v2.x, v2.y, r, g, b, a, tx2, ty2, // Top-right
289
- v3.x, v3.y, r, g, b, a, tx3, ty3, // Bottom-right
290
- v4.x, v4.y, r, g, b, a, tx4, ty4 }; // Bottom-left
291
-
292
- // Use the texture shader program
293
- glUseProgram(texShaderProgram);
294
-
295
- // Bind the texture using the provided ID
296
- glBindTexture(GL_TEXTURE_2D, texture_id);
297
-
298
- // Create and Initialize the vertex data and array indices
299
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
300
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
301
-
302
- // Render the textured quad
303
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
304
- }
305
-
306
-
307
- /*
308
- * Draw image
309
- */
310
- void R2D_GL3_DrawImage(R2D_Image *img) {
311
- R2D_GL3_DrawTexture(
312
- img->x, img->y, img->width, img->height,
313
- img->rotate, img->rx, img->ry,
314
- img->color.r, img->color.g, img->color.b, img->color.a,
315
- 0.f, 0.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f,
316
- img->texture_id
317
- );
318
- }
319
-
320
-
321
- /*
322
- * Draw sprite
323
- */
324
- void R2D_GL3_DrawSprite(R2D_Sprite *spr) {
325
- R2D_GL3_DrawTexture(
326
- spr->x, spr->y, spr->width, spr->height,
327
- spr->rotate, spr->rx, spr->ry,
328
- spr->color.r, spr->color.g, spr->color.b, spr->color.a,
329
- spr->tx1, spr->ty1, spr->tx2, spr->ty2, spr->tx3, spr->ty3, spr->tx4, spr->ty4,
330
- spr->img->texture_id
331
- );
332
- }
279
+ void R2D_GL3_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id) {
280
+ // If buffer is full, flush it
281
+ if (vboDataIndex + 6 >= vboObjCapacity) R2D_GL3_FlushBuffers();
282
+
283
+ // There are 6 vertices for a square as we are rendering two Triangles to make up our square:
284
+ // Triangle one: Top left, Top right, Bottom right
285
+ // Triangle two: Bottom right, Bottom left, Top left
286
+ GLfloat vertices[48] = {
287
+ coordinates[0], coordinates[1], color[0], color[1], color[2], color[3], texture_coordinates[0], texture_coordinates[1],
288
+ coordinates[2], coordinates[3], color[0], color[1], color[2], color[3], texture_coordinates[2], texture_coordinates[3],
289
+ coordinates[4], coordinates[5], color[0], color[1], color[2], color[3], texture_coordinates[4], texture_coordinates[5],
290
+ coordinates[4], coordinates[5], color[0], color[1], color[2], color[3], texture_coordinates[4], texture_coordinates[5],
291
+ coordinates[6], coordinates[7], color[0], color[1], color[2], color[3], texture_coordinates[6], texture_coordinates[7],
292
+ coordinates[0], coordinates[1], color[0], color[1], color[2], color[3], texture_coordinates[0], texture_coordinates[1],
293
+ };
333
294
 
295
+ // Copy the vertex data into the current position of the buffer
296
+ memcpy(vboDataCurrent, vertices, sizeof(vertices));
334
297
 
335
- /*
336
- * Draw a tile
337
- */
338
- void R2D_GL3_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
339
- GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
340
- R2D_GL3_DrawTexture(
341
- x, y, tw, th,
342
- img->rotate, img->rx, img->ry,
343
- img->color.r, img->color.g, img->color.b, img->color.a,
344
- tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
345
- img->texture_id
346
- );
298
+ verticesTextureIds[vboDataIndex] = verticesTextureIds[vboDataIndex + 1] = verticesTextureIds[vboDataIndex + 2] = verticesTextureIds[vboDataIndex + 3] = verticesTextureIds[vboDataIndex + 4] = verticesTextureIds[vboDataIndex + 5] = texture_id;
299
+ vboDataIndex += 6;
300
+ vboDataCurrent = (GLfloat *)((char *)vboDataCurrent + (sizeof(GLfloat) * 48));
347
301
  }
348
302
 
349
303
 
350
- /*
351
- * Draw text
352
- */
353
- void R2D_GL3_DrawText(R2D_Text *txt) {
354
- R2D_GL3_DrawTexture(
355
- txt->x, txt->y, txt->width, txt->height,
356
- txt->rotate, txt->rx, txt->ry,
357
- txt->color.r, txt->color.g, txt->color.b, txt->color.a,
358
- 0.f, 0.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f,
359
- txt->texture_id
360
- );
361
- }
362
-
363
304
  #endif