ruby2d 0.12.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (620) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +7 -0
  3. data/README.md +141 -0
  4. data/USAGE.md +2435 -0
  5. data/assets/Rakefile +637 -0
  6. data/assets/build_support/CMakeLists.txt +94 -0
  7. data/assets/build_support/mruby/build_config.rb +34 -0
  8. data/assets/build_support/mruby/build_config_wasm.rb +30 -0
  9. data/assets/build_support/sdl_test.c +174 -0
  10. data/assets/deps.yaml +16 -0
  11. data/assets/platform/include/SDL3/SDL.h +91 -0
  12. data/assets/platform/include/SDL3/SDL_assert.h +705 -0
  13. data/assets/platform/include/SDL3/SDL_asyncio.h +550 -0
  14. data/assets/platform/include/SDL3/SDL_atomic.h +692 -0
  15. data/assets/platform/include/SDL3/SDL_audio.h +2370 -0
  16. data/assets/platform/include/SDL3/SDL_begin_code.h +553 -0
  17. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_bits.h +47 -27
  18. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_blendmode.h +59 -55
  19. data/assets/platform/include/SDL3/SDL_camera.h +535 -0
  20. data/assets/platform/include/SDL3/SDL_clipboard.h +331 -0
  21. data/assets/{include/SDL2/close_code.h → platform/include/SDL3/SDL_close_code.h} +9 -8
  22. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_copying.h +3 -1
  23. data/assets/platform/include/SDL3/SDL_cpuinfo.h +374 -0
  24. data/assets/platform/include/SDL3/SDL_dialog.h +343 -0
  25. data/assets/platform/include/SDL3/SDL_dlopennote.h +234 -0
  26. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_egl.h +11 -8
  27. data/assets/platform/include/SDL3/SDL_endian.h +645 -0
  28. data/assets/platform/include/SDL3/SDL_error.h +226 -0
  29. data/assets/platform/include/SDL3/SDL_events.h +1645 -0
  30. data/assets/platform/include/SDL3/SDL_filesystem.h +537 -0
  31. data/assets/platform/include/SDL3/SDL_gamepad.h +1656 -0
  32. data/assets/platform/include/SDL3/SDL_gpu.h +4608 -0
  33. data/assets/platform/include/SDL3/SDL_guid.h +106 -0
  34. data/assets/platform/include/SDL3/SDL_haptic.h +1461 -0
  35. data/assets/platform/include/SDL3/SDL_hidapi.h +571 -0
  36. data/assets/platform/include/SDL3/SDL_hints.h +5001 -0
  37. data/assets/platform/include/SDL3/SDL_init.h +507 -0
  38. data/assets/platform/include/SDL3/SDL_intrin.h +410 -0
  39. data/assets/platform/include/SDL3/SDL_iostream.h +1379 -0
  40. data/assets/platform/include/SDL3/SDL_joystick.h +1385 -0
  41. data/assets/platform/include/SDL3/SDL_keyboard.h +608 -0
  42. data/assets/platform/include/SDL3/SDL_keycode.h +347 -0
  43. data/assets/platform/include/SDL3/SDL_loadso.h +145 -0
  44. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_locale.h +40 -24
  45. data/assets/platform/include/SDL3/SDL_log.h +541 -0
  46. data/assets/platform/include/SDL3/SDL_main.h +704 -0
  47. data/assets/platform/include/SDL3/SDL_main_impl.h +151 -0
  48. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_messagebox.h +85 -48
  49. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_metal.h +29 -29
  50. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_misc.h +13 -12
  51. data/assets/platform/include/SDL3/SDL_mouse.h +813 -0
  52. data/assets/platform/include/SDL3/SDL_mutex.h +1117 -0
  53. data/assets/platform/include/SDL3/SDL_oldnames.h +1339 -0
  54. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl.h +1247 -278
  55. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl_glext.h +5 -1
  56. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles.h +6 -7
  57. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2.h +10 -11
  58. data/assets/platform/include/SDL3/SDL_pen.h +198 -0
  59. data/assets/platform/include/SDL3/SDL_pixels.h +1441 -0
  60. data/assets/{include/SDL2/SDL_test_log.h → platform/include/SDL3/SDL_platform.h} +25 -26
  61. data/assets/platform/include/SDL3/SDL_platform_defines.h +497 -0
  62. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_power.h +40 -20
  63. data/assets/platform/include/SDL3/SDL_process.h +441 -0
  64. data/assets/platform/include/SDL3/SDL_properties.h +572 -0
  65. data/assets/platform/include/SDL3/SDL_rect.h +528 -0
  66. data/assets/platform/include/SDL3/SDL_render.h +3028 -0
  67. data/assets/platform/include/SDL3/SDL_revision.h +59 -0
  68. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_scancode.h +59 -68
  69. data/assets/platform/include/SDL3/SDL_sensor.h +321 -0
  70. data/assets/platform/include/SDL3/SDL_stdinc.h +6186 -0
  71. data/assets/platform/include/SDL3/SDL_storage.h +686 -0
  72. data/assets/platform/include/SDL3/SDL_surface.h +1769 -0
  73. data/assets/platform/include/SDL3/SDL_system.h +840 -0
  74. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test.h +16 -22
  75. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_assert.h +27 -34
  76. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_common.h +109 -52
  77. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_compare.h +22 -14
  78. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_crc32.h +27 -30
  79. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_font.h +50 -49
  80. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_fuzzer.h +64 -79
  81. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_harness.h +47 -30
  82. data/assets/platform/include/SDL3/SDL_test_log.h +83 -0
  83. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_md5.h +21 -28
  84. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_memory.h +19 -16
  85. data/assets/platform/include/SDL3/SDL_thread.h +602 -0
  86. data/assets/platform/include/SDL3/SDL_time.h +249 -0
  87. data/assets/platform/include/SDL3/SDL_timer.h +454 -0
  88. data/assets/platform/include/SDL3/SDL_touch.h +184 -0
  89. data/assets/platform/include/SDL3/SDL_tray.h +544 -0
  90. data/assets/platform/include/SDL3/SDL_version.h +198 -0
  91. data/assets/platform/include/SDL3/SDL_video.h +3497 -0
  92. data/assets/platform/include/SDL3/SDL_vulkan.h +287 -0
  93. data/assets/platform/include/SDL3_image/SDL_image.h +3328 -0
  94. data/assets/platform/include/SDL3_mixer/SDL_mixer.h +3369 -0
  95. data/assets/platform/include/SDL3_ttf/SDL_textengine.h +181 -0
  96. data/assets/platform/include/SDL3_ttf/SDL_ttf.h +2833 -0
  97. data/assets/{include → platform/include}/mrbconf.h +42 -31
  98. data/assets/{include → platform/include}/mruby/array.h +3 -4
  99. data/assets/{include → platform/include}/mruby/boxing_nan.h +10 -0
  100. data/assets/platform/include/mruby/boxing_no.h +59 -0
  101. data/assets/{include → platform/include}/mruby/boxing_word.h +72 -26
  102. data/assets/platform/include/mruby/class.h +157 -0
  103. data/assets/{include → platform/include}/mruby/common.h +30 -1
  104. data/assets/{include → platform/include}/mruby/compile.h +52 -74
  105. data/assets/{include → platform/include}/mruby/data.h +2 -2
  106. data/assets/{include → platform/include}/mruby/debug.h +12 -5
  107. data/assets/{include → platform/include}/mruby/dump.h +7 -9
  108. data/assets/{include → platform/include}/mruby/endian.h +1 -1
  109. data/assets/platform/include/mruby/error.h +173 -0
  110. data/assets/platform/include/mruby/gc.h +79 -0
  111. data/assets/{include → platform/include}/mruby/hash.h +1 -7
  112. data/assets/platform/include/mruby/internal.h +282 -0
  113. data/assets/platform/include/mruby/irep.h +143 -0
  114. data/assets/{include → platform/include}/mruby/istruct.h +1 -1
  115. data/assets/platform/include/mruby/khash.h +455 -0
  116. data/assets/platform/include/mruby/mempool.h +19 -0
  117. data/assets/{include → platform/include}/mruby/numeric.h +7 -10
  118. data/assets/platform/include/mruby/object.h +51 -0
  119. data/assets/{include → platform/include}/mruby/opcode.h +5 -5
  120. data/assets/{include → platform/include}/mruby/ops.h +19 -6
  121. data/assets/platform/include/mruby/presym/id.h +1447 -0
  122. data/assets/{include → platform/include}/mruby/presym/scanning.h +10 -7
  123. data/assets/platform/include/mruby/presym/table.h +2893 -0
  124. data/assets/platform/include/mruby/presym.h +65 -0
  125. data/assets/platform/include/mruby/proc.h +184 -0
  126. data/assets/{include → platform/include}/mruby/range.h +0 -2
  127. data/assets/{include → platform/include}/mruby/string.h +33 -53
  128. data/assets/platform/include/mruby/throw.h +81 -0
  129. data/assets/{include → platform/include}/mruby/value.h +64 -29
  130. data/assets/{include → platform/include}/mruby/variable.h +6 -23
  131. data/assets/{include → platform/include}/mruby/version.h +7 -7
  132. data/assets/{include → platform/include}/mruby.h +238 -116
  133. data/assets/platform/macos-arm64/bin/mrbc +0 -0
  134. data/assets/platform/macos-arm64/lib/libSDL3.a +0 -0
  135. data/assets/platform/macos-arm64/lib/libSDL3_image.a +0 -0
  136. data/assets/platform/macos-arm64/lib/libSDL3_mixer.a +0 -0
  137. data/assets/platform/macos-arm64/lib/libSDL3_ttf.a +0 -0
  138. data/assets/platform/macos-arm64/lib/libmruby.a +0 -0
  139. data/assets/platform/wasm/lib/libFLAC.a +0 -0
  140. data/assets/platform/wasm/lib/libSDL3.a +0 -0
  141. data/assets/platform/wasm/lib/libSDL3_image.a +0 -0
  142. data/assets/platform/wasm/lib/libSDL3_mixer.a +0 -0
  143. data/assets/platform/wasm/lib/libSDL3_ttf.a +0 -0
  144. data/assets/platform/wasm/lib/libfreetype.a +0 -0
  145. data/assets/platform/wasm/lib/libharfbuzz.a +0 -0
  146. data/assets/platform/wasm/lib/libmruby.a +0 -0
  147. data/assets/platform/wasm/lib/libogg.a +0 -0
  148. data/assets/platform/wasm/lib/libplutosvg.a +0 -0
  149. data/assets/platform/wasm/lib/libplutovg.a +0 -0
  150. data/assets/platform/wasm/lib/libpng.a +0 -0
  151. data/assets/platform/wasm/lib/libpng16.a +0 -0
  152. data/assets/platform/wasm/lib/libvorbis.a +0 -0
  153. data/assets/platform/wasm/lib/libvorbisfile.a +0 -0
  154. data/assets/platform/wasm/lib/libzlibstatic.a +0 -0
  155. data/assets/platform/windows-arm64-mingw-ucrt/bin/mrbc.exe +0 -0
  156. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3.a +0 -0
  157. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_image.a +0 -0
  158. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
  159. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
  160. data/assets/platform/windows-arm64-mingw-ucrt/lib/libmruby.a +0 -0
  161. data/assets/platform/windows-x86_64-mingw-ucrt/bin/mrbc.exe +0 -0
  162. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3.a +0 -0
  163. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_image.a +0 -0
  164. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
  165. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
  166. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libmruby.a +0 -0
  167. data/assets/resources/fonts/outfit/OFL.txt +93 -0
  168. data/assets/resources/fonts/outfit/outfit.ttf +0 -0
  169. data/assets/resources/fonts/roboto_mono/OFL.txt +91 -0
  170. data/assets/resources/fonts/roboto_mono/roboto_mono.ttf +0 -0
  171. data/assets/resources/icons/icon.icns +0 -0
  172. data/assets/resources/icons/icon.png +0 -0
  173. data/assets/resources/spritesheets/License.txt +28 -0
  174. data/assets/resources/spritesheets/spritesheet-backgrounds.png +0 -0
  175. data/assets/resources/spritesheets/spritesheet-backgrounds.xml +16 -0
  176. data/assets/resources/spritesheets/spritesheet-characters.png +0 -0
  177. data/assets/resources/spritesheets/spritesheet-characters.xml +47 -0
  178. data/assets/resources/spritesheets/spritesheet-enemies.png +0 -0
  179. data/assets/resources/spritesheets/spritesheet-enemies.xml +62 -0
  180. data/assets/resources/spritesheets/spritesheet-tiles.png +0 -0
  181. data/assets/resources/spritesheets/spritesheet-tiles.xml +316 -0
  182. data/assets/{wasm → resources/web}/template.html +1 -1
  183. data/assets/target.rb +131 -0
  184. data/bin/ruby2d +281 -82
  185. data/examples/astar.rb +269 -0
  186. data/examples/asteroids.rb +403 -0
  187. data/examples/bezier_editor.rb +96 -0
  188. data/examples/boids.rb +191 -0
  189. data/examples/bouncing_balls.rb +119 -0
  190. data/examples/breakout.rb +186 -0
  191. data/examples/constellations.rb +100 -0
  192. data/examples/dashboard.rb +133 -0
  193. data/examples/double_pendulum.rb +254 -0
  194. data/examples/falling_sand.rb +291 -0
  195. data/examples/fireworks.rb +110 -0
  196. data/examples/fluid_dynamics.rb +340 -0
  197. data/examples/fourier_epicycles.rb +142 -0
  198. data/examples/fractal_tree.rb +326 -0
  199. data/examples/game_of_life.rb +148 -0
  200. data/examples/gamepads.rb +333 -0
  201. data/examples/hill_driver.rb +613 -0
  202. data/examples/logo_animation.rb +251 -0
  203. data/examples/lorenz_attractor.rb +115 -0
  204. data/examples/mandelbrot.rb +207 -0
  205. data/examples/marching_squares.rb +200 -0
  206. data/examples/maze.rb +323 -0
  207. data/examples/nbody.rb +338 -0
  208. data/examples/outrun.rb +391 -0
  209. data/examples/pixel_paint.rb +313 -0
  210. data/examples/platformer.rb +335 -0
  211. data/examples/ray_casting_maze.rb +175 -0
  212. data/examples/shadow_casting.rb +151 -0
  213. data/examples/shape_recognizer.rb +908 -0
  214. data/examples/snake.rb +144 -0
  215. data/examples/sprite_sheets.rb +246 -0
  216. data/examples/swarm.rb +206 -0
  217. data/examples/tsp_annealing.rb +104 -0
  218. data/examples/ui_controls.rb +163 -0
  219. data/examples/wireframe_3d.rb +139 -0
  220. data/ext/ruby2d/audio.c +324 -0
  221. data/ext/ruby2d/canvas.c +1715 -494
  222. data/ext/ruby2d/ext.c +541 -0
  223. data/ext/ruby2d/extconf.rb +122 -145
  224. data/ext/ruby2d/font.c +566 -20
  225. data/ext/ruby2d/fps.c +92 -0
  226. data/ext/ruby2d/image.c +466 -41
  227. data/ext/ruby2d/ruby2d.c +374 -1890
  228. data/ext/ruby2d/ruby2d.h +840 -460
  229. data/ext/ruby2d/shapes.c +931 -101
  230. data/ext/ruby2d/text.c +586 -21
  231. data/ext/ruby2d/window.c +1693 -283
  232. data/lib/ruby2d/atlas_parser.rb +194 -0
  233. data/lib/ruby2d/audio.rb +73 -0
  234. data/lib/ruby2d/benchmark.rb +259 -0
  235. data/lib/ruby2d/bitmap_text.rb +155 -0
  236. data/lib/ruby2d/button.rb +402 -0
  237. data/lib/ruby2d/canvas.rb +703 -279
  238. data/lib/ruby2d/circle.rb +206 -29
  239. data/lib/ruby2d/cli/browser.rb +314 -0
  240. data/lib/ruby2d/cli/build.rb +471 -257
  241. data/lib/ruby2d/cli/colorize.rb +7 -5
  242. data/lib/ruby2d/cli/examples.rb +127 -0
  243. data/lib/ruby2d/cli/launch.rb +24 -39
  244. data/lib/ruby2d/cli/lib_files.rb +48 -0
  245. data/lib/ruby2d/cli/messages.rb +40 -0
  246. data/lib/ruby2d/cli/setup.rb +273 -0
  247. data/lib/ruby2d/cli/static_server.rb +160 -0
  248. data/lib/ruby2d/cli/usage.rb +255 -0
  249. data/lib/ruby2d/color.rb +191 -69
  250. data/lib/ruby2d/core.rb +37 -19
  251. data/lib/ruby2d/deps_help.rb +89 -0
  252. data/lib/ruby2d/dsl.rb +51 -12
  253. data/lib/ruby2d/ellipse.rb +228 -0
  254. data/lib/ruby2d/exceptions.rb +0 -2
  255. data/lib/ruby2d/font.rb +34 -74
  256. data/lib/ruby2d/gamepad.rb +323 -0
  257. data/lib/ruby2d/gem_paths.rb +19 -0
  258. data/lib/ruby2d/image.rb +155 -52
  259. data/lib/ruby2d/interactive.rb +103 -0
  260. data/lib/ruby2d/json_parser.rb +268 -0
  261. data/lib/ruby2d/line.rb +194 -85
  262. data/lib/ruby2d/mruby_compat.rb +12 -0
  263. data/lib/ruby2d/polygon.rb +297 -0
  264. data/lib/ruby2d/polyline.rb +368 -0
  265. data/lib/ruby2d/quad.rb +358 -94
  266. data/lib/ruby2d/rectangle.rb +77 -19
  267. data/lib/ruby2d/renderable.rb +411 -11
  268. data/lib/ruby2d/sprite.rb +471 -180
  269. data/lib/ruby2d/sprite_sheet.rb +64 -0
  270. data/lib/ruby2d/square.rb +29 -17
  271. data/lib/ruby2d/text.rb +196 -65
  272. data/lib/ruby2d/tileset.rb +139 -81
  273. data/lib/ruby2d/triangle.rb +324 -89
  274. data/lib/ruby2d/version.rb +1 -3
  275. data/lib/ruby2d/vertices.rb +62 -85
  276. data/lib/ruby2d/warnings.rb +29 -0
  277. data/lib/ruby2d/window/class_methods.rb +218 -0
  278. data/lib/ruby2d/window/gamepad_events.rb +141 -0
  279. data/lib/ruby2d/window/key_events.rb +74 -0
  280. data/lib/ruby2d/window/mouse_events.rb +171 -0
  281. data/lib/ruby2d/window/object_events.rb +168 -0
  282. data/lib/ruby2d/window.rb +632 -585
  283. data/lib/ruby2d.rb +14 -19
  284. metadata +275 -443
  285. data/assets/app.icns +0 -0
  286. data/assets/include/GL/glew.h +0 -26427
  287. data/assets/include/GLES2/gl2.h +0 -656
  288. data/assets/include/GLES2/gl2ext.h +0 -3949
  289. data/assets/include/GLES2/gl2ext_angle.h +0 -701
  290. data/assets/include/GLES2/gl2platform.h +0 -27
  291. data/assets/include/GLES3/gl3.h +0 -1192
  292. data/assets/include/GLES3/gl31.h +0 -1507
  293. data/assets/include/GLES3/gl32.h +0 -1808
  294. data/assets/include/GLES3/gl3platform.h +0 -27
  295. data/assets/include/KHR/khrplatform.h +0 -290
  296. data/assets/include/SDL2/SDL.h +0 -233
  297. data/assets/include/SDL2/SDL_assert.h +0 -326
  298. data/assets/include/SDL2/SDL_atomic.h +0 -415
  299. data/assets/include/SDL2/SDL_audio.h +0 -1500
  300. data/assets/include/SDL2/SDL_clipboard.h +0 -141
  301. data/assets/include/SDL2/SDL_config.h +0 -61
  302. data/assets/include/SDL2/SDL_config_android.h +0 -194
  303. data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
  304. data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
  305. data/assets/include/SDL2/SDL_config_macosx.h +0 -277
  306. data/assets/include/SDL2/SDL_config_minimal.h +0 -95
  307. data/assets/include/SDL2/SDL_config_ngage.h +0 -89
  308. data/assets/include/SDL2/SDL_config_os2.h +0 -207
  309. data/assets/include/SDL2/SDL_config_pandora.h +0 -141
  310. data/assets/include/SDL2/SDL_config_windows.h +0 -331
  311. data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
  312. data/assets/include/SDL2/SDL_config_winrt.h +0 -220
  313. data/assets/include/SDL2/SDL_config_xbox.h +0 -235
  314. data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
  315. data/assets/include/SDL2/SDL_endian.h +0 -348
  316. data/assets/include/SDL2/SDL_error.h +0 -163
  317. data/assets/include/SDL2/SDL_events.h +0 -1166
  318. data/assets/include/SDL2/SDL_filesystem.h +0 -149
  319. data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
  320. data/assets/include/SDL2/SDL_gesture.h +0 -117
  321. data/assets/include/SDL2/SDL_guid.h +0 -100
  322. data/assets/include/SDL2/SDL_haptic.h +0 -1341
  323. data/assets/include/SDL2/SDL_hidapi.h +0 -451
  324. data/assets/include/SDL2/SDL_hints.h +0 -2569
  325. data/assets/include/SDL2/SDL_image.h +0 -2173
  326. data/assets/include/SDL2/SDL_joystick.h +0 -1066
  327. data/assets/include/SDL2/SDL_keyboard.h +0 -353
  328. data/assets/include/SDL2/SDL_keycode.h +0 -358
  329. data/assets/include/SDL2/SDL_loadso.h +0 -115
  330. data/assets/include/SDL2/SDL_log.h +0 -404
  331. data/assets/include/SDL2/SDL_main.h +0 -275
  332. data/assets/include/SDL2/SDL_mixer.h +0 -2784
  333. data/assets/include/SDL2/SDL_mouse.h +0 -465
  334. data/assets/include/SDL2/SDL_mutex.h +0 -471
  335. data/assets/include/SDL2/SDL_name.h +0 -33
  336. data/assets/include/SDL2/SDL_pixels.h +0 -644
  337. data/assets/include/SDL2/SDL_platform.h +0 -261
  338. data/assets/include/SDL2/SDL_quit.h +0 -58
  339. data/assets/include/SDL2/SDL_rect.h +0 -376
  340. data/assets/include/SDL2/SDL_render.h +0 -1919
  341. data/assets/include/SDL2/SDL_revision.h +0 -6
  342. data/assets/include/SDL2/SDL_rwops.h +0 -841
  343. data/assets/include/SDL2/SDL_sensor.h +0 -322
  344. data/assets/include/SDL2/SDL_shape.h +0 -155
  345. data/assets/include/SDL2/SDL_stdinc.h +0 -830
  346. data/assets/include/SDL2/SDL_surface.h +0 -997
  347. data/assets/include/SDL2/SDL_system.h +0 -623
  348. data/assets/include/SDL2/SDL_syswm.h +0 -386
  349. data/assets/include/SDL2/SDL_test_images.h +0 -78
  350. data/assets/include/SDL2/SDL_test_random.h +0 -115
  351. data/assets/include/SDL2/SDL_thread.h +0 -464
  352. data/assets/include/SDL2/SDL_timer.h +0 -222
  353. data/assets/include/SDL2/SDL_touch.h +0 -150
  354. data/assets/include/SDL2/SDL_ttf.h +0 -2316
  355. data/assets/include/SDL2/SDL_types.h +0 -29
  356. data/assets/include/SDL2/SDL_version.h +0 -204
  357. data/assets/include/SDL2/SDL_video.h +0 -2150
  358. data/assets/include/SDL2/SDL_vulkan.h +0 -215
  359. data/assets/include/SDL2/begin_code.h +0 -187
  360. data/assets/include/mruby/boxing_no.h +0 -58
  361. data/assets/include/mruby/class.h +0 -108
  362. data/assets/include/mruby/error.h +0 -147
  363. data/assets/include/mruby/gc.h +0 -94
  364. data/assets/include/mruby/irep.h +0 -147
  365. data/assets/include/mruby/khash.h +0 -284
  366. data/assets/include/mruby/object.h +0 -43
  367. data/assets/include/mruby/presym/disable.h +0 -70
  368. data/assets/include/mruby/presym/enable.h +0 -37
  369. data/assets/include/mruby/presym.h +0 -40
  370. data/assets/include/mruby/proc.h +0 -211
  371. data/assets/include/mruby/throw.h +0 -66
  372. data/assets/macos/universal/bin/mrbc +0 -0
  373. data/assets/macos/universal/lib/libFLAC.a +0 -0
  374. data/assets/macos/universal/lib/libSDL2.a +0 -0
  375. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  376. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  377. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  378. data/assets/macos/universal/lib/libavif.a +0 -0
  379. data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
  380. data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
  381. data/assets/macos/universal/lib/libfreetype.a +0 -0
  382. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  383. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  384. data/assets/macos/universal/lib/libhwy.a +0 -0
  385. data/assets/macos/universal/lib/libjpeg.a +0 -0
  386. data/assets/macos/universal/lib/libjxl.a +0 -0
  387. data/assets/macos/universal/lib/libmodplug.a +0 -0
  388. data/assets/macos/universal/lib/libmpg123.a +0 -0
  389. data/assets/macos/universal/lib/libmruby.a +0 -0
  390. data/assets/macos/universal/lib/libogg.a +0 -0
  391. data/assets/macos/universal/lib/libpng.a +0 -0
  392. data/assets/macos/universal/lib/libtiff.a +0 -0
  393. data/assets/macos/universal/lib/libvorbis.a +0 -0
  394. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  395. data/assets/macos/universal/lib/libwebp.a +0 -0
  396. data/assets/macos/universal/lib/libzstd.a +0 -0
  397. data/assets/test_media/README.md +0 -3
  398. data/assets/test_media/bitstream_vera/COPYRIGHT.txt +0 -124
  399. data/assets/test_media/bitstream_vera/vera.ttf +0 -0
  400. data/assets/test_media/boom.png +0 -0
  401. data/assets/test_media/coin.png +0 -0
  402. data/assets/test_media/colors.png +0 -0
  403. data/assets/test_media/controller.png +0 -0
  404. data/assets/test_media/dial.wav +0 -0
  405. data/assets/test_media/hero.png +0 -0
  406. data/assets/test_media/image.bmp +0 -0
  407. data/assets/test_media/image.jpg +0 -0
  408. data/assets/test_media/image.png +0 -0
  409. data/assets/test_media/music.flac +0 -0
  410. data/assets/test_media/music.mp3 +0 -0
  411. data/assets/test_media/music.ogg +0 -0
  412. data/assets/test_media/music.wav +0 -0
  413. data/assets/test_media/originals/boom.pxm +0 -0
  414. data/assets/test_media/originals/coin.pxm +0 -0
  415. data/assets/test_media/originals/controller.sketch +0 -0
  416. data/assets/test_media/originals/hero.pxm +0 -0
  417. data/assets/test_media/originals/image.pxm +0 -0
  418. data/assets/test_media/originals/music.caf +0 -0
  419. data/assets/test_media/originals/texture_atlas.pxm +0 -0
  420. data/assets/test_media/rondo_alla_turka.ogg +0 -0
  421. data/assets/test_media/sound.flac +0 -0
  422. data/assets/test_media/sound.mp3 +0 -0
  423. data/assets/test_media/sound.ogg +0 -0
  424. data/assets/test_media/sound.wav +0 -0
  425. data/assets/test_media/sprite_sheet.png +0 -0
  426. data/assets/test_media/texture_atlas.png +0 -0
  427. data/assets/wasm/libmruby.a +0 -0
  428. data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
  429. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  430. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
  431. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  432. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
  433. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  434. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
  435. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
  436. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
  437. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
  438. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
  439. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
  440. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  441. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
  442. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
  443. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
  444. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
  445. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
  446. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
  447. data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
  448. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  449. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  450. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
  451. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  452. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  453. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  454. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
  455. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  456. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -1
  457. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  458. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
  459. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  460. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  461. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
  462. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  463. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  464. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  465. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  466. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  467. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  468. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  469. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  470. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  471. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  472. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  473. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  474. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  475. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  476. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  477. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  478. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  479. data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
  480. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  481. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  482. data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
  483. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  484. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  485. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  486. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  487. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  488. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  489. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  490. data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
  491. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  492. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -1
  493. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  494. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  495. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  496. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  497. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  498. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  499. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  500. data/assets/xcode/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
  501. data/assets/xcode/ios/Assets.xcassets/Contents.json +0 -6
  502. data/assets/xcode/ios/Base.lproj/LaunchScreen.storyboard +0 -27
  503. data/assets/xcode/ios/Info.plist +0 -43
  504. data/assets/xcode/ios/MRuby.framework/Headers/mrbconf.h +0 -143
  505. data/assets/xcode/ios/MRuby.framework/Headers/mruby/array.h +0 -280
  506. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
  507. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
  508. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
  509. data/assets/xcode/ios/MRuby.framework/Headers/mruby/class.h +0 -97
  510. data/assets/xcode/ios/MRuby.framework/Headers/mruby/common.h +0 -77
  511. data/assets/xcode/ios/MRuby.framework/Headers/mruby/compile.h +0 -195
  512. data/assets/xcode/ios/MRuby.framework/Headers/mruby/data.h +0 -75
  513. data/assets/xcode/ios/MRuby.framework/Headers/mruby/debug.h +0 -67
  514. data/assets/xcode/ios/MRuby.framework/Headers/mruby/dump.h +0 -196
  515. data/assets/xcode/ios/MRuby.framework/Headers/mruby/error.h +0 -75
  516. data/assets/xcode/ios/MRuby.framework/Headers/mruby/gc.h +0 -91
  517. data/assets/xcode/ios/MRuby.framework/Headers/mruby/hash.h +0 -215
  518. data/assets/xcode/ios/MRuby.framework/Headers/mruby/irep.h +0 -75
  519. data/assets/xcode/ios/MRuby.framework/Headers/mruby/istruct.h +0 -47
  520. data/assets/xcode/ios/MRuby.framework/Headers/mruby/khash.h +0 -274
  521. data/assets/xcode/ios/MRuby.framework/Headers/mruby/numeric.h +0 -161
  522. data/assets/xcode/ios/MRuby.framework/Headers/mruby/object.h +0 -44
  523. data/assets/xcode/ios/MRuby.framework/Headers/mruby/opcode.h +0 -69
  524. data/assets/xcode/ios/MRuby.framework/Headers/mruby/ops.h +0 -117
  525. data/assets/xcode/ios/MRuby.framework/Headers/mruby/proc.h +0 -131
  526. data/assets/xcode/ios/MRuby.framework/Headers/mruby/range.h +0 -49
  527. data/assets/xcode/ios/MRuby.framework/Headers/mruby/re.h +0 -16
  528. data/assets/xcode/ios/MRuby.framework/Headers/mruby/string.h +0 -444
  529. data/assets/xcode/ios/MRuby.framework/Headers/mruby/throw.h +0 -55
  530. data/assets/xcode/ios/MRuby.framework/Headers/mruby/value.h +0 -309
  531. data/assets/xcode/ios/MRuby.framework/Headers/mruby/variable.h +0 -136
  532. data/assets/xcode/ios/MRuby.framework/Headers/mruby/version.h +0 -110
  533. data/assets/xcode/ios/MRuby.framework/Headers/mruby.h +0 -1282
  534. data/assets/xcode/ios/MRuby.framework/Info.plist +0 -20
  535. data/assets/xcode/ios/MRuby.framework/MRuby +0 -0
  536. data/assets/xcode/ios/MyApp.xcodeproj/project.pbxproj +0 -368
  537. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  538. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  539. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
  540. data/assets/xcode/ios/main.c +0 -1
  541. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
  542. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -6
  543. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -17
  544. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
  545. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -6
  546. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
  547. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -6
  548. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
  549. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -6
  550. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -17
  551. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
  552. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -6
  553. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
  554. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -6
  555. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -32
  556. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -16
  557. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -16
  558. data/assets/xcode/tvos/Assets.xcassets/Contents.json +0 -6
  559. data/assets/xcode/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -22
  560. data/assets/xcode/tvos/Info.plist +0 -30
  561. data/assets/xcode/tvos/MRuby.framework/Headers/mrbconf.h +0 -143
  562. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/array.h +0 -280
  563. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
  564. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
  565. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
  566. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/class.h +0 -97
  567. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/common.h +0 -77
  568. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/compile.h +0 -195
  569. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/data.h +0 -75
  570. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/debug.h +0 -67
  571. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/dump.h +0 -196
  572. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/error.h +0 -75
  573. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/gc.h +0 -91
  574. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/hash.h +0 -215
  575. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/irep.h +0 -75
  576. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/istruct.h +0 -47
  577. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/khash.h +0 -274
  578. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/numeric.h +0 -161
  579. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/object.h +0 -44
  580. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/opcode.h +0 -69
  581. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/ops.h +0 -117
  582. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/proc.h +0 -131
  583. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/range.h +0 -49
  584. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/re.h +0 -16
  585. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/string.h +0 -444
  586. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/throw.h +0 -55
  587. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/value.h +0 -309
  588. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/variable.h +0 -136
  589. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/version.h +0 -110
  590. data/assets/xcode/tvos/MRuby.framework/Headers/mruby.h +0 -1282
  591. data/assets/xcode/tvos/MRuby.framework/Info.plist +0 -20
  592. data/assets/xcode/tvos/MRuby.framework/MRuby +0 -0
  593. data/assets/xcode/tvos/MyApp.xcodeproj/project.pbxproj +0 -350
  594. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  595. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  596. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
  597. data/assets/xcode/tvos/main.c +0 -1
  598. data/ext/ruby2d/common.c +0 -185
  599. data/ext/ruby2d/controllers.c +0 -110
  600. data/ext/ruby2d/gl.c +0 -398
  601. data/ext/ruby2d/gl2.c +0 -86
  602. data/ext/ruby2d/gl3.c +0 -304
  603. data/ext/ruby2d/gles.c +0 -302
  604. data/ext/ruby2d/input.c +0 -48
  605. data/ext/ruby2d/music.c +0 -127
  606. data/ext/ruby2d/sound.c +0 -132
  607. data/lib/ruby2d/cli/console.rb +0 -65
  608. data/lib/ruby2d/cli/enable_console.rb +0 -7
  609. data/lib/ruby2d/cli/platform.rb +0 -17
  610. data/lib/ruby2d/music.rb +0 -77
  611. data/lib/ruby2d/pixel.rb +0 -18
  612. data/lib/ruby2d/pixmap.rb +0 -39
  613. data/lib/ruby2d/pixmap_atlas.rb +0 -56
  614. data/lib/ruby2d/sound.rb +0 -61
  615. data/lib/ruby2d/texture.rb +0 -38
  616. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2.h +0 -0
  617. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2ext.h +0 -0
  618. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2platform.h +0 -0
  619. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_khrplatform.h +0 -0
  620. /data/assets/{include → platform/include}/mruby/re.h +0 -0
data/ext/ruby2d/font.c CHANGED
@@ -1,35 +1,581 @@
1
- // font.c
1
+ // font.c — Internal bitmap font for diagnostic overlays
2
+ //
3
+ // Provides a reusable 5x7 bitmap font covering printable ASCII (0x20–0x7E).
4
+ // Text is rendered to a cached SDL_Texture at physical-pixel resolution so it
5
+ // stays crisp on HiDPI displays, then drawn at logical coordinates.
2
6
 
3
7
  #include "ruby2d.h"
4
8
 
5
9
 
10
+ // Glyph Data //////////////////////////////////////////////////////////////////
11
+ //
12
+ // 95 glyphs for printable ASCII (space 0x20 through tilde 0x7E).
13
+ // Each glyph is 7 rows of uint8_t. Bits 4..0 encode columns left-to-right
14
+ // (bit 4 = leftmost, bit 0 = rightmost).
15
+
16
+ static const uint8_t r2d_font_glyphs[R2D_FONT_NUM_GLYPHS][R2D_FONT_GLYPH_HEIGHT] = {
17
+ // 0x20 ' ' (space)
18
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
19
+ // 0x21 '!'
20
+ { 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04 },
21
+ // 0x22 '"'
22
+ { 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00 },
23
+ // 0x23 '#'
24
+ { 0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A },
25
+ // 0x24 '$'
26
+ { 0x04, 0x0F, 0x14, 0x0E, 0x05, 0x1E, 0x04 },
27
+ // 0x25 '%'
28
+ { 0x18, 0x19, 0x02, 0x04, 0x08, 0x13, 0x03 },
29
+ // 0x26 '&'
30
+ { 0x0C, 0x12, 0x14, 0x08, 0x15, 0x12, 0x0D },
31
+ // 0x27 '''
32
+ { 0x0C, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00 },
33
+ // 0x28 '('
34
+ { 0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02 },
35
+ // 0x29 ')'
36
+ { 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08 },
37
+ // 0x2A '*'
38
+ { 0x00, 0x04, 0x15, 0x0E, 0x15, 0x04, 0x00 },
39
+ // 0x2B '+'
40
+ { 0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00 },
41
+ // 0x2C ','
42
+ { 0x00, 0x00, 0x00, 0x00, 0x0C, 0x04, 0x08 },
43
+ // 0x2D '-'
44
+ { 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00 },
45
+ // 0x2E '.'
46
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C },
47
+ // 0x2F '/'
48
+ { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00 },
49
+ // 0x30 '0'
50
+ { 0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E },
51
+ // 0x31 '1'
52
+ { 0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E },
53
+ // 0x32 '2'
54
+ { 0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F },
55
+ // 0x33 '3'
56
+ { 0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E },
57
+ // 0x34 '4'
58
+ { 0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02 },
59
+ // 0x35 '5'
60
+ { 0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E },
61
+ // 0x36 '6'
62
+ { 0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E },
63
+ // 0x37 '7'
64
+ { 0x1F, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08 },
65
+ // 0x38 '8'
66
+ { 0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E },
67
+ // 0x39 '9'
68
+ { 0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C },
69
+ // 0x3A ':'
70
+ { 0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00 },
71
+ // 0x3B ';'
72
+ { 0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x04, 0x08 },
73
+ // 0x3C '<'
74
+ { 0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02 },
75
+ // 0x3D '='
76
+ { 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00 },
77
+ // 0x3E '>'
78
+ { 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08 },
79
+ // 0x3F '?'
80
+ { 0x0E, 0x11, 0x01, 0x02, 0x04, 0x00, 0x04 },
81
+ // 0x40 '@'
82
+ { 0x0E, 0x11, 0x17, 0x15, 0x17, 0x10, 0x0E },
83
+ // 0x41 'A'
84
+ { 0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11 },
85
+ // 0x42 'B'
86
+ { 0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E },
87
+ // 0x43 'C'
88
+ { 0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E },
89
+ // 0x44 'D'
90
+ { 0x1C, 0x12, 0x11, 0x11, 0x11, 0x12, 0x1C },
91
+ // 0x45 'E'
92
+ { 0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F },
93
+ // 0x46 'F'
94
+ { 0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10 },
95
+ // 0x47 'G'
96
+ { 0x0E, 0x11, 0x10, 0x17, 0x11, 0x11, 0x0F },
97
+ // 0x48 'H'
98
+ { 0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11 },
99
+ // 0x49 'I'
100
+ { 0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E },
101
+ // 0x4A 'J'
102
+ { 0x07, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0C },
103
+ // 0x4B 'K'
104
+ { 0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11 },
105
+ // 0x4C 'L'
106
+ { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F },
107
+ // 0x4D 'M'
108
+ { 0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11 },
109
+ // 0x4E 'N'
110
+ { 0x11, 0x11, 0x19, 0x15, 0x13, 0x11, 0x11 },
111
+ // 0x4F 'O'
112
+ { 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E },
113
+ // 0x50 'P'
114
+ { 0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10 },
115
+ // 0x51 'Q'
116
+ { 0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0D },
117
+ // 0x52 'R'
118
+ { 0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11 },
119
+ // 0x53 'S'
120
+ { 0x0F, 0x10, 0x10, 0x0E, 0x01, 0x01, 0x1E },
121
+ // 0x54 'T'
122
+ { 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 },
123
+ // 0x55 'U'
124
+ { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E },
125
+ // 0x56 'V'
126
+ { 0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04 },
127
+ // 0x57 'W'
128
+ { 0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x11 },
129
+ // 0x58 'X'
130
+ { 0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11 },
131
+ // 0x59 'Y'
132
+ { 0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04 },
133
+ // 0x5A 'Z'
134
+ { 0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F },
135
+ // 0x5B '['
136
+ { 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E },
137
+ // 0x5C '\'
138
+ { 0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00 },
139
+ // 0x5D ']'
140
+ { 0x0E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0E },
141
+ // 0x5E '^'
142
+ { 0x04, 0x0A, 0x11, 0x00, 0x00, 0x00, 0x00 },
143
+ // 0x5F '_'
144
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F },
145
+ // 0x60 '`'
146
+ { 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00 },
147
+ // 0x61 'a'
148
+ { 0x00, 0x00, 0x0E, 0x01, 0x0F, 0x11, 0x0F },
149
+ // 0x62 'b'
150
+ { 0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x1E },
151
+ // 0x63 'c'
152
+ { 0x00, 0x00, 0x0E, 0x10, 0x10, 0x11, 0x0E },
153
+ // 0x64 'd'
154
+ { 0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0F },
155
+ // 0x65 'e'
156
+ { 0x00, 0x00, 0x0E, 0x11, 0x1F, 0x10, 0x0E },
157
+ // 0x66 'f'
158
+ { 0x06, 0x09, 0x08, 0x1C, 0x08, 0x08, 0x08 },
159
+ // 0x67 'g'
160
+ { 0x00, 0x0F, 0x11, 0x11, 0x0F, 0x01, 0x0E },
161
+ // 0x68 'h'
162
+ { 0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x11 },
163
+ // 0x69 'i'
164
+ { 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x0E },
165
+ // 0x6A 'j'
166
+ { 0x02, 0x00, 0x06, 0x02, 0x02, 0x12, 0x0C },
167
+ // 0x6B 'k'
168
+ { 0x10, 0x10, 0x12, 0x14, 0x18, 0x14, 0x12 },
169
+ // 0x6C 'l'
170
+ { 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E },
171
+ // 0x6D 'm'
172
+ { 0x00, 0x00, 0x1A, 0x15, 0x15, 0x11, 0x11 },
173
+ // 0x6E 'n'
174
+ { 0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11 },
175
+ // 0x6F 'o'
176
+ { 0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E },
177
+ // 0x70 'p'
178
+ { 0x00, 0x00, 0x1E, 0x11, 0x1E, 0x10, 0x10 },
179
+ // 0x71 'q'
180
+ { 0x00, 0x00, 0x0D, 0x13, 0x0F, 0x01, 0x01 },
181
+ // 0x72 'r'
182
+ { 0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10 },
183
+ // 0x73 's'
184
+ { 0x00, 0x00, 0x0E, 0x10, 0x0E, 0x01, 0x1E },
185
+ // 0x74 't'
186
+ { 0x08, 0x08, 0x1C, 0x08, 0x08, 0x09, 0x06 },
187
+ // 0x75 'u'
188
+ { 0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0D },
189
+ // 0x76 'v'
190
+ { 0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04 },
191
+ // 0x77 'w'
192
+ { 0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A },
193
+ // 0x78 'x'
194
+ { 0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11 },
195
+ // 0x79 'y'
196
+ { 0x00, 0x00, 0x11, 0x11, 0x0F, 0x01, 0x0E },
197
+ // 0x7A 'z'
198
+ { 0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F },
199
+ // 0x7B '{'
200
+ { 0x02, 0x04, 0x04, 0x08, 0x04, 0x04, 0x02 },
201
+ // 0x7C '|'
202
+ { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 },
203
+ // 0x7D '}'
204
+ { 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08 },
205
+ // 0x7E '~'
206
+ { 0x00, 0x00, 0x08, 0x15, 0x02, 0x00, 0x00 },
207
+ };
208
+
209
+
210
+ // Padding inside the semi-transparent background (in logical pixels)
211
+ #define R2D_FONT_PADDING_H 8
212
+ #define R2D_FONT_PADDING_V 10
213
+
214
+
215
+ // Bitmap Text API /////////////////////////////////////////////////////////////
216
+
217
+
218
+ /*
219
+ * Allocate a new bitmap text handle. All fields are zeroed so the first call
220
+ * to R2D_UpdateBitmapText will create the texture.
221
+ */
222
+ R2D_BitmapText *R2D_CreateBitmapText(void) {
223
+ R2D_BitmapText *bt = (R2D_BitmapText *)calloc(1, sizeof(R2D_BitmapText));
224
+ return bt;
225
+ }
226
+
227
+
6
228
  /*
7
- * Create a TTF_Font object given a path to a font and a size
229
+ * Free a bitmap text handle and its cached resources.
8
230
  */
9
- TTF_Font *R2D_FontCreateTTFFont(const char *path, int size, const char *style) {
231
+ void R2D_FreeBitmapText(R2D_BitmapText *bt) {
232
+ if (!bt) return;
233
+ if (bt->texture) SDL_DestroyTexture(bt->texture);
234
+ free(bt->text);
235
+ free(bt);
236
+ }
237
+
10
238
 
11
- // Check if font file exists
12
- if (!R2D_FileExists(path)) {
13
- R2D_Error("R2D_FontCreateTTFFont", "Font file `%s` not found", path);
14
- return NULL;
239
+ // Drop the cached texture and rendered string so the next draw rebuilds them.
240
+ // Used for full re-inits (ext_create reuse, teardown) — content changes go
241
+ // through R2D_UpdateBitmapText, which keeps the texture and uploads in place.
242
+ static void R2D_InvalidateBitmapText(R2D_BitmapText *bt) {
243
+ if (bt->texture) {
244
+ SDL_DestroyTexture(bt->texture);
245
+ bt->texture = NULL;
15
246
  }
247
+ bt->tex_w = 0;
248
+ bt->tex_h = 0;
249
+ bt->content_w = 0;
250
+ bt->content_h = 0;
251
+ free(bt->text);
252
+ bt->text = NULL;
253
+ }
16
254
 
17
- TTF_Font *font = TTF_OpenFont(path, size);
18
255
 
19
- if (!font) {
20
- R2D_Error("TTF_OpenFont", TTF_GetError());
21
- return NULL;
256
+ /*
257
+ * Render a string to a cached texture. If the string is identical to the
258
+ * previously rendered one, this is a no-op (cache hit). Otherwise the old
259
+ * texture is destroyed and a new one is built at physical-pixel resolution
260
+ * for HiDPI crispness.
261
+ *
262
+ * Parameters:
263
+ * bt Bitmap text handle (from R2D_CreateBitmapText)
264
+ * renderer The SDL renderer to create the texture on
265
+ * text The string to render (printable ASCII only)
266
+ * scale Logical pixel multiplier per glyph pixel (e.g. 3)
267
+ */
268
+ void R2D_UpdateBitmapText(R2D_BitmapText *bt, SDL_Renderer *renderer,
269
+ const char *text, int scale) {
270
+ if (!bt || !text) return;
271
+
272
+ // Cache hit — string and scale unchanged
273
+ if (bt->text && strcmp(text, bt->text) == 0 && bt->scale == scale) return;
274
+
275
+ // Drop only the cache key; the texture persists as a grow-only allocation
276
+ // and the new string is uploaded into it below.
277
+ free(bt->text);
278
+ bt->text = NULL;
279
+
280
+ // Each byte renders one glyph cell — a real glyph for printable ASCII, or a
281
+ // placeholder for anything out of range (non-ASCII, control chars). Counting
282
+ // bytes (not just printable ones) keeps the width consistent with ext_create
283
+ // and makes unsupported characters visible instead of silently vanishing.
284
+ int len = (int)strlen(text);
285
+ if (len == 0) {
286
+ // Nothing to render: cache the empty key and zero the content dims so the
287
+ // draw paths skip the (still-allocated) texture with its stale pixels.
288
+ bt->text = strdup(text);
289
+ bt->scale = scale;
290
+ bt->content_w = 0;
291
+ bt->content_h = 0;
292
+ bt->logical_w = 0.0f;
293
+ bt->logical_h = 0.0f;
294
+ return;
22
295
  }
23
296
 
24
- if(strncmp(style, "bold", 4) == 0) {
25
- TTF_SetFontStyle(font, TTF_STYLE_BOLD);
26
- } else if(strncmp(style, "italic", 6) == 0) {
27
- TTF_SetFontStyle(font, TTF_STYLE_ITALIC);
28
- } else if(strncmp(style, "underline", 9) == 0) {
29
- TTF_SetFontStyle(font, TTF_STYLE_UNDERLINE);
30
- } else if(strncmp(style, "strikethrough", 13) == 0) {
31
- TTF_SetFontStyle(font, TTF_STYLE_STRIKETHROUGH);
297
+ // Build surface at physical-pixel resolution for HiDPI crispness
298
+ float ds = R2D_GetDisplayScale();
299
+ int surface_scale = (int)(scale * ds);
300
+ if (surface_scale < scale) surface_scale = scale;
301
+
302
+ int glyph_w = R2D_FONT_GLYPH_WIDTH * surface_scale;
303
+ int glyph_h = R2D_FONT_GLYPH_HEIGHT * surface_scale;
304
+ int char_spacing = surface_scale;
305
+ int pad_h = bt->background ? (int)(R2D_FONT_PADDING_H * ds) : 0;
306
+ int pad_v = bt->background ? (int)(R2D_FONT_PADDING_V * ds) : 0;
307
+ int surface_w = len * glyph_w + (len - 1) * char_spacing + pad_h;
308
+ int surface_h = glyph_h + pad_v;
309
+
310
+ SDL_Surface *surface = SDL_CreateSurface(surface_w, surface_h, SDL_PIXELFORMAT_RGBA32);
311
+ if (!surface) return;
312
+
313
+ // Semi-transparent black background, or fully transparent when disabled
314
+ Uint8 bg_alpha = bt->background ? 180 : 0;
315
+ SDL_FillSurfaceRect(surface, NULL,
316
+ SDL_MapRGBA(SDL_GetPixelFormatDetails(surface->format), NULL, 0, 0, 0, bg_alpha));
317
+
318
+ int x_offset = bt->background ? (int)(R2D_FONT_PADDING_H * 0.5f * ds) : 0;
319
+ int y_offset = bt->background ? (int)(R2D_FONT_PADDING_V * 0.5f * ds) : 0;
320
+ uint32_t white = SDL_MapRGBA(SDL_GetPixelFormatDetails(surface->format), NULL, 255, 255, 255, 255);
321
+
322
+ for (const char *p = text; *p; p++) {
323
+ unsigned char ch = (unsigned char)*p;
324
+ // Substitute a visible placeholder for unsupported bytes (the font only
325
+ // covers printable ASCII), so dropped characters are noticeable.
326
+ if (ch < R2D_FONT_FIRST_CHAR || ch > R2D_FONT_LAST_CHAR) ch = '?';
327
+
328
+ int glyph_idx = ch - R2D_FONT_FIRST_CHAR;
329
+ const uint8_t *glyph = r2d_font_glyphs[glyph_idx];
330
+
331
+ for (int row = 0; row < R2D_FONT_GLYPH_HEIGHT; row++) {
332
+ for (int col = 0; col < R2D_FONT_GLYPH_WIDTH; col++) {
333
+ if (glyph[row] & (1 << (R2D_FONT_GLYPH_WIDTH - 1 - col))) {
334
+ SDL_Rect pixel = {
335
+ x_offset + col * surface_scale,
336
+ y_offset + row * surface_scale,
337
+ surface_scale,
338
+ surface_scale
339
+ };
340
+ SDL_FillSurfaceRect(surface, &pixel, white);
341
+ }
342
+ }
343
+ }
344
+
345
+ x_offset += glyph_w + char_spacing;
32
346
  }
33
347
 
34
- return font;
348
+ /* Refresh the GPU texture — platform-split exactly like text.c's ext_draw
349
+ (see the comment there for the measurements): the web build updates a
350
+ persistent grow-only texture in place, native recreates from the surface
351
+ each change because Metal is faster at create-fresh. */
352
+ #ifdef __EMSCRIPTEN__
353
+ if (bt->texture == NULL || surface_w > bt->tex_w || surface_h > bt->tex_h) {
354
+ int new_w = surface_w > bt->tex_w ? surface_w : bt->tex_w;
355
+ int new_h = surface_h > bt->tex_h ? surface_h : bt->tex_h;
356
+ if (bt->texture) SDL_DestroyTexture(bt->texture);
357
+ bt->texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32,
358
+ SDL_TEXTUREACCESS_STREAMING, new_w, new_h);
359
+ R2D_CheckSDL(bt->texture != NULL, "SDL_CreateTexture");
360
+ if (bt->texture) {
361
+ SDL_SetTextureBlendMode(bt->texture, SDL_BLENDMODE_BLEND);
362
+ bt->tex_w = new_w;
363
+ bt->tex_h = new_h;
364
+ } else {
365
+ bt->tex_w = 0;
366
+ bt->tex_h = 0;
367
+ }
368
+ }
369
+ if (bt->texture) {
370
+ SDL_Rect upload_rect = { 0, 0, surface_w, surface_h };
371
+ R2D_CheckSDL(SDL_UpdateTexture(bt->texture, &upload_rect, surface->pixels, surface->pitch),
372
+ "SDL_UpdateTexture");
373
+ bt->content_w = surface_w;
374
+ bt->content_h = surface_h;
375
+ }
376
+ #else
377
+ if (bt->texture) SDL_DestroyTexture(bt->texture);
378
+ bt->texture = SDL_CreateTextureFromSurface(renderer, surface);
379
+ R2D_CheckSDL(bt->texture != NULL, "SDL_CreateTextureFromSurface");
380
+ if (bt->texture) {
381
+ bt->content_w = surface_w;
382
+ bt->content_h = surface_h;
383
+ }
384
+ #endif
385
+ SDL_DestroySurface(surface);
386
+
387
+ // If texture creation failed (R2D_CheckSDL only logs), leave the cache key
388
+ // (bt->text / bt->scale) unset so the next draw retries, rather than
389
+ // committing a permanently blank glyph via the cache-hit short-circuit above.
390
+ if (!bt->texture) return;
391
+
392
+ // Compute the logical (window-coordinate) size for rendering
393
+ int logical_glyph_w = R2D_FONT_GLYPH_WIDTH * scale;
394
+ int logical_glyph_h = R2D_FONT_GLYPH_HEIGHT * scale;
395
+ int logical_spacing = scale;
396
+ int logical_pad_h = bt->background ? R2D_FONT_PADDING_H : 0;
397
+ int logical_pad_v = bt->background ? R2D_FONT_PADDING_V : 0;
398
+ bt->logical_w = (float)(len * logical_glyph_w + (len - 1) * logical_spacing + logical_pad_h);
399
+ bt->logical_h = (float)(logical_glyph_h + logical_pad_v);
400
+
401
+ bt->text = strdup(text);
402
+ bt->scale = scale;
403
+ }
404
+
405
+
406
+ /*
407
+ * Draw the cached bitmap text texture at the given logical coordinates.
408
+ */
409
+ void R2D_DrawBitmapText(R2D_BitmapText *bt, SDL_Renderer *renderer,
410
+ float x, float y) {
411
+ if (!bt || !bt->texture || bt->content_w <= 0) return;
412
+
413
+ #ifdef __EMSCRIPTEN__
414
+ // Clip to the content within the (possibly larger) persistent texture;
415
+ // native textures are content-sized, so NULL is equivalent (see text.c).
416
+ SDL_FRect src = { 0, 0, (float)bt->content_w, (float)bt->content_h };
417
+ const SDL_FRect *src_p = &src;
418
+ #else
419
+ const SDL_FRect *src_p = NULL;
420
+ #endif
421
+ SDL_FRect dst = { x, y, bt->logical_w, bt->logical_h };
422
+ R2D_CheckSDL(SDL_RenderTexture(renderer, bt->texture, src_p, &dst),
423
+ "SDL_RenderTexture");
424
+ }
425
+
426
+
427
+ // Ruby Bindings ///////////////////////////////////////////////////////////////
428
+
429
+ R2D_DEFINE_DATA_TYPE(R2D_BitmapText);
430
+
431
+ // BitmapText-specific ivar IDs. Shared ivar IDs live in ext.c.
432
+ static R_ID id_bt_scale, id_bt_ext;
433
+
434
+
435
+ /*
436
+ * Initialize Ruby2D::BitmapText native bindings
437
+ */
438
+ void R2D_BitmapText_Init() {
439
+ id_bt_scale = r_id("@scale");
440
+ id_bt_ext = r_id("@ext_bitmap_text");
441
+
442
+ r_define_class_method(ruby2d_ext_module, "bitmap_text_create", ruby2d_ext_bitmap_text_create, r_args_variadic);
443
+ r_define_class_method(ruby2d_ext_module, "bitmap_text_draw", ruby2d_ext_bitmap_text_draw, r_args_variadic);
444
+ }
445
+
446
+
447
+ /*
448
+ * Ruby2D::BitmapText#ext_create
449
+ *
450
+ * Allocates (or reuses) the internal R2D_BitmapText struct and computes the
451
+ * logical width/height from the string length and scale. No renderer is
452
+ * needed — the texture is built lazily in ext_draw.
453
+ */
454
+ R_VAL ruby2d_ext_bitmap_text_create(RUBY2D_METHOD_ARGS_VARIADIC) {
455
+ RUBY2D_EXTRACT_VARIADIC;
456
+ if (argc != 1) r_raise("Ruby2D::Ext.bitmap_text_create expects 1 arg (text), got %d", (int)argc);
457
+ R_VAL obj = argv[0];
458
+ R2D_Init();
459
+
460
+ const char *msg = obj_str(obj, id_content);
461
+ int scale = obj_int(obj, id_bt_scale);
462
+
463
+ // Check for existing struct — reuse it if present, otherwise allocate new
464
+ R2D_BitmapText *bt = NULL;
465
+ bool is_new = false;
466
+ R_VAL existing = r_iv_get(obj, "@ext_bitmap_text");
467
+ if (r_test(existing)) {
468
+ obj_struct(obj, id_bt_ext, R2D_BitmapText, bt);
469
+ if (bt) {
470
+ R2D_InvalidateBitmapText(bt);
471
+ }
472
+ }
473
+
474
+ // Allocate new struct only if we don't have one to reuse
475
+ if (!bt) {
476
+ bt = ALLOC(R2D_BitmapText);
477
+ memset(bt, 0, sizeof(R2D_BitmapText));
478
+ is_new = true;
479
+ }
480
+
481
+ // One glyph cell per byte (out-of-range bytes draw a placeholder at draw
482
+ // time), matching R2D_UpdateBitmapText so the reported width agrees with
483
+ // what's rendered.
484
+ int len = (msg == NULL) ? 0 : (int)strlen(msg);
485
+
486
+ // Compute logical dimensions (no background padding for user-facing text).
487
+ // Empty content reports a zero-width box at the glyph height — the draw path
488
+ // already no-ops on empty, so no texture is built.
489
+ int logical_w = (len == 0) ? 0
490
+ : len * (R2D_FONT_GLYPH_WIDTH * scale) + (len - 1) * scale;
491
+ int logical_h = R2D_FONT_GLYPH_HEIGHT * scale;
492
+
493
+ // Only set the struct on the Ruby object if we allocated new
494
+ if (is_new) {
495
+ obj_set_struct(obj, id_bt_ext, R2D_BitmapText, bt);
496
+ }
497
+
498
+ obj_set_int(obj, id_width, logical_w);
499
+ obj_set_int(obj, id_height, logical_h);
500
+
501
+ return R_TRUE;
502
+ }
503
+
504
+
505
+ /*
506
+ * Ruby2D::BitmapText#ext_draw
507
+ *
508
+ * Unwraps the struct, lazily builds/caches the texture via
509
+ * R2D_UpdateBitmapText, applies color and alpha modulation, and draws.
510
+ */
511
+ R_VAL ruby2d_ext_bitmap_text_draw(RUBY2D_METHOD_ARGS_VARIADIC) {
512
+ RUBY2D_EXTRACT_VARIADIC;
513
+ if (argc != 3) r_raise("Ruby2D::Ext.bitmap_text_draw expects 3 args (text, rx, ry), got %d", (int)argc);
514
+ R_VAL obj = argv[0];
515
+ float crx = NUM2DBL(argv[1]);
516
+ float cry = NUM2DBL(argv[2]);
517
+ R2D_BitmapText *bt;
518
+ obj_struct(obj, id_bt_ext, R2D_BitmapText, bt);
519
+
520
+ const char *msg = obj_str(obj, id_content);
521
+ int scale = obj_int(obj, id_bt_scale);
522
+
523
+ R2D_UpdateBitmapText(bt, R2D_GetRenderer(), msg, scale);
524
+
525
+ if (!bt->texture || bt->content_w <= 0) return R_NIL;
526
+
527
+ SDL_SetTextureBlendMode(bt->texture, SDL_BLENDMODE_BLEND);
528
+
529
+ // Apply color and alpha modulation
530
+ R_VAL color_obj = r_ivar_get(obj, id_color);
531
+ SDL_SetTextureColorModFloat(bt->texture,
532
+ NUM2DBL(r_ivar_get(color_obj, id_r)),
533
+ NUM2DBL(r_ivar_get(color_obj, id_g)),
534
+ NUM2DBL(r_ivar_get(color_obj, id_b))
535
+ );
536
+ SDL_SetTextureAlphaModFloat(bt->texture,
537
+ NUM2DBL(r_ivar_get(color_obj, id_a)));
538
+
539
+ // Rotate about (rx, ry), expressed relative to the texture's top-left — the
540
+ // same convention as Text (see text.c). Reuses the cached texture; only the
541
+ // blit is rotated.
542
+ float x = obj_float(obj, id_x);
543
+ float y = obj_float(obj, id_y);
544
+ #ifdef __EMSCRIPTEN__
545
+ // Clip to the content within the (possibly larger) persistent texture;
546
+ // native textures are content-sized, so NULL is equivalent (see text.c).
547
+ SDL_FRect src = { 0, 0, (float)bt->content_w, (float)bt->content_h };
548
+ const SDL_FRect *src_p = &src;
549
+ #else
550
+ const SDL_FRect *src_p = NULL;
551
+ #endif
552
+ SDL_FRect dst = { x, y, bt->logical_w, bt->logical_h };
553
+ SDL_FPoint center = { crx - x, cry - y };
554
+
555
+ R2D_CheckSDL(SDL_RenderTextureRotated(
556
+ R2D_GetRenderer(),
557
+ bt->texture,
558
+ src_p,
559
+ &dst,
560
+ obj_float(obj, id_rotate),
561
+ &center,
562
+ SDL_FLIP_NONE
563
+ ), "SDL_RenderTextureRotated");
564
+
565
+ return R_TRUE;
566
+ }
567
+
568
+
569
+ /*
570
+ * Free the memory and resources associated with an R2D_BitmapText object
571
+ */
572
+ static void R2D_BitmapText_free(void *p) {
573
+ if (!p) return;
574
+ R2D_BitmapText *bt = (R2D_BitmapText *)p;
575
+ if (bt->texture) {
576
+ if (R2D_RendererAlive()) SDL_DestroyTexture(bt->texture);
577
+ bt->texture = NULL;
578
+ }
579
+ free(bt->text);
580
+ xfree(bt);
35
581
  }
data/ext/ruby2d/fps.c ADDED
@@ -0,0 +1,92 @@
1
+ // fps.c
2
+
3
+ #include "ruby2d.h"
4
+
5
+
6
+ /*
7
+ * Calculates and returns the average frames per second (FPS) over the last
8
+ * FPS_SAMPLE_COUNT frames. Uses a circular buffer to store frame times and
9
+ * computes the rolling average FPS based on the elapsed time between frames.
10
+ */
11
+ #define FPS_SAMPLE_COUNT 60
12
+ static double frame_times[FPS_SAMPLE_COUNT];
13
+ static double running_total = 0.0; // running sum of the entries in frame_times
14
+ static int frame_index = 0;
15
+ static int frame_count = 0;
16
+ static SDL_Time last_time;
17
+ static bool fps_initialized = false;
18
+
19
+ double R2D_GetFrameRate() {
20
+ SDL_Time current_time;
21
+ double avg_fps = 0.0;
22
+
23
+ if (!SDL_GetCurrentTime(&current_time)) {
24
+ return 0.0;
25
+ }
26
+
27
+ if (!fps_initialized) {
28
+ // First call only seeds the timer — no delta yet, so we return 0.0
29
+ last_time = current_time;
30
+ fps_initialized = true;
31
+ } else {
32
+ // SDL_GetCurrentTime returns nanoseconds; convert to seconds
33
+ double delta = (current_time - last_time) / 1e9;
34
+
35
+ // Maintain a running sum instead of re-summing the whole window each frame:
36
+ // swap the sample being overwritten out for the new one. frame_times is
37
+ // zero-initialized, so the subtracted term is 0 until the window fills.
38
+ running_total += delta - frame_times[frame_index];
39
+ frame_times[frame_index] = delta;
40
+ frame_index = (frame_index + 1) % FPS_SAMPLE_COUNT;
41
+ if (frame_count < FPS_SAMPLE_COUNT) frame_count++;
42
+
43
+ // Once per full window (on wrap), resync the sum from the buffer to shed any
44
+ // floating-point drift the incremental add/subtract accumulates, so the
45
+ // average stays exactly what a full re-sum would give. O(1) amortized.
46
+ if (frame_index == 0) {
47
+ running_total = 0.0;
48
+ for (int i = 0; i < frame_count; i++) running_total += frame_times[i];
49
+ }
50
+
51
+ if (running_total > 0.0) avg_fps = frame_count / running_total;
52
+
53
+ last_time = current_time;
54
+ }
55
+
56
+ return avg_fps;
57
+ }
58
+
59
+
60
+ #define FPS_LOGICAL_SCALE 3
61
+ #define FPS_MARGIN 5 // Offset from the top-left corner of the window
62
+
63
+ static R2D_BitmapText *fps_text = NULL;
64
+
65
+
66
+ /*
67
+ * Draws the frame rate in the window using the internal bitmap font.
68
+ * Controlled at runtime by R2D_GetInit*.diagnostics or R2D_GetInit*.show_fps.
69
+ * The overlay texture is cached and only rebuilt when the displayed value changes.
70
+ */
71
+ void R2D_DrawFrameRate(R2D_Window *window) {
72
+ char fps_str[16];
73
+ snprintf(fps_str, sizeof(fps_str), "%.0f", window->fps);
74
+
75
+ if (!fps_text) {
76
+ fps_text = R2D_CreateBitmapText();
77
+ fps_text->background = true;
78
+ }
79
+ R2D_UpdateBitmapText(fps_text, window->sdl_renderer, fps_str, FPS_LOGICAL_SCALE);
80
+ R2D_DrawBitmapText(fps_text, window->sdl_renderer, (float)FPS_MARGIN, (float)FPS_MARGIN);
81
+ }
82
+
83
+
84
+ /*
85
+ * Free the cached FPS overlay resources. Called during window cleanup.
86
+ */
87
+ void R2D_FreeFpsOverlay(void) {
88
+ if (fps_text) {
89
+ R2D_FreeBitmapText(fps_text);
90
+ fps_text = NULL;
91
+ }
92
+ }