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/ruby2d.h CHANGED
@@ -3,149 +3,314 @@
3
3
  #ifndef RUBY2D_H
4
4
  #define RUBY2D_H
5
5
 
6
+
7
+ // Ruby Engine and Includes ////////////////////////////////////////////////////
8
+
9
+ #ifdef MRUBY
10
+ #include <mruby.h>
11
+ #include <mruby/array.h>
12
+ #include <mruby/string.h>
13
+ #include <mruby/variable.h>
14
+ #include <mruby/numeric.h>
15
+ #include <mruby/data.h>
16
+ #include <mruby/irep.h>
17
+ #include <mruby/error.h>
18
+ #else
19
+ #include <ruby.h>
20
+ #endif
21
+
6
22
  #ifdef __cplusplus
7
23
  extern "C" {
8
24
  #endif
9
25
 
10
- #include <stdbool.h>
26
+ #include <stdlib.h>
27
+ #include <math.h>
11
28
 
12
- // Set Platform Constants //////////////////////////////////////////////////////
29
+ #include <SDL3/SDL.h>
30
+ #include <SDL3_image/SDL_image.h>
31
+ #include <SDL3_mixer/SDL_mixer.h>
32
+ #include <SDL3_ttf/SDL_ttf.h>
13
33
 
14
- #ifndef MRUBY
15
- #define MRUBY false
16
- #endif
17
34
 
18
- // Apple
19
- #ifdef __APPLE__
20
- #ifndef __TARGETCONDITIONALS__
21
- #include "TargetConditionals.h"
22
- #endif
23
- #if TARGET_OS_OSX
24
- #define MACOS true
25
- #else
26
- #define MACOS false
27
- #endif
28
- #if TARGET_OS_IOS
29
- #define IOS true
30
- #else
31
- #define IOS false
32
- #endif
33
- #if TARGET_OS_TV
34
- #define TVOS true
35
- #else
36
- #define TVOS false
37
- #endif
38
- #endif
35
+ // Platform Specifics //////////////////////////////////////////////////////////
39
36
 
40
- // Windows
41
37
  #ifdef _WIN32
42
- #define WINDOWS true
43
- #else
44
- #define WINDOWS false
45
- #endif
46
-
47
- // Windows and MinGW
48
- #ifdef __MINGW32__
49
- #define MINGW true
38
+ #include <io.h>
39
+ #define F_OK 0 // for testing file existence
50
40
  #else
51
- #define MINGW false
41
+ #include <unistd.h>
52
42
  #endif
53
43
 
54
- // WebAssembly
55
44
  #ifdef __EMSCRIPTEN__
56
- #define WASM true
57
- #else
58
- #define WASM false
45
+ #include <emscripten.h>
59
46
  #endif
60
47
 
61
48
 
62
- // #define GLES true
49
+ // Ruby/MRuby Abstraction Macros ///////////////////////////////////////////////
50
+ //
51
+ // These macros provide a unified C API across CRuby and mruby so that
52
+ // extension code never calls rb_* or mrb_* directly. Grouped by functionality,
53
+ // with both implementations shown side-by-side for easy comparison.
54
+
55
+ // --- MRuby Type Conversions (mruby only) -------------------------------------
56
+ // CRuby provides these natively; mruby needs shims to match the CRuby API.
57
+ // The full set is kept for parity even if a given macro is currently unused.
58
+ #ifdef MRUBY
59
+ // C to Ruby value
60
+ #define INT2FIX(val) (mrb_fixnum_value(val))
61
+ #define INT2NUM(val) (mrb_fixnum_value((mrb_int)(val)))
62
+ #define UINT2NUM(val) (INT2NUM((unsigned mrb_int)(val)))
63
+ #define LL2NUM(val) (INT2NUM(val))
64
+ #define ULL2NUM(val) (INT2NUM((uint64_t)(val)))
65
+ #define DBL2NUM(val) (mrb_float_value(mrb, (mrb_float)(val)))
66
+ // Ruby value to C
67
+ #define TO_PDT(val) ((mrb_type(val) == MRB_TT_FLOAT) ? mrb_float(val) : mrb_int(mrb, (val)))
68
+ #define FIX2INT(val) (mrb_fixnum(val))
69
+ #define NUM2INT(val) ((mrb_int)TO_PDT(val))
70
+ #define NUM2UINT(val) ((unsigned mrb_int)TO_PDT(val))
71
+ #define NUM2LONG(val) (mrb_int(mrb, (val)))
72
+ #define NUM2LL(val) ((int64_t)(TO_PDT(val)))
73
+ #define NUM2ULL(val) ((uint64_t)(TO_PDT(val)))
74
+ #define NUM2DBL(val) (mrb_as_float(mrb, (val)))
75
+ #define NUM2CHR(val) ((mrb_string_p(val) && (RSTRING_LEN(val)>=1)) ? RSTRING_PTR(val)[0] : (char)(NUM2INT(val) & 0xff))
76
+ // Memory management
77
+ #define ALLOC(type) ((type *)mrb_malloc(mrb, sizeof(type)))
78
+ #define ALLOC_N(type, n) ((type *)mrb_malloc(mrb, sizeof(type) * (n)))
79
+ #define ALLOCA_N(type, n) ((type *)alloca(sizeof(type) * (n)))
80
+ #define MEMCMP(p1, p2, type, n) (memcmp((p1), (p2), sizeof(type)*(n)))
81
+ #define xfree(ptr) mrb_free(mrb, ptr)
82
+ #endif
63
83
 
64
- // ARM and GLES
65
- #if IOS || TVOS || WASM
66
- #define GLES true
84
+ // --- Core Value Types --------------------------------------------------------
85
+ // Fundamental type aliases used everywhere in the abstraction layer.
86
+ #ifdef MRUBY
87
+ #define R_VAL mrb_value
88
+ #define R_NIL (mrb_nil_value())
89
+ #define R_TRUE (mrb_true_value())
90
+ #define R_FALSE (mrb_false_value())
91
+ #define R_CLASS struct RClass *
92
+ #define R_ID mrb_sym
67
93
  #else
68
- #define GLES false
94
+ #define R_VAL VALUE
95
+ #define R_NIL Qnil
96
+ #define R_TRUE Qtrue
97
+ #define R_FALSE Qfalse
98
+ #define R_CLASS R_VAL
99
+ #define R_ID ID
69
100
  #endif
70
101
 
102
+ // --- Instance Variable Access ------------------------------------------------
103
+ // r_iv_get/set: access by string name (e.g. "@width") — interns on each call.
104
+ // r_ivar_get/set: access by pre-interned R_ID — faster in hot paths.
105
+ #ifdef MRUBY
106
+ #define r_iv_get(self, var) mrb_iv_get(mrb, self, mrb_intern_lit(mrb, var))
107
+ #define r_iv_set(self, var, val) mrb_iv_set(mrb, self, mrb_intern_lit(mrb, var), val)
108
+ #define r_ivar_get(obj, id) mrb_iv_get(mrb, (obj), (id))
109
+ #define r_ivar_set(obj, id, val) mrb_iv_set(mrb, (obj), (id), (val))
110
+ #else
111
+ #define r_iv_get(self, var) rb_iv_get(self, var)
112
+ #define r_iv_set(self, var, val) rb_iv_set(self, var, val)
113
+ #define r_ivar_get(obj, id) rb_ivar_get((obj), (id))
114
+ #define r_ivar_set(obj, id, val) rb_ivar_set((obj), (id), (val))
115
+ #endif
71
116
 
117
+ // --- Function Calls, Strings, Truthiness -------------------------------------
118
+ // r_funcall: call a Ruby method by name on an object.
119
+ // r_str_new: create a Ruby string from a C string.
120
+ // r_test: check if a Ruby value is truthy (not nil/false).
121
+ #ifdef MRUBY
122
+ #define r_funcall(self, method, n, ...) mrb_funcall(mrb, self, method, n, ##__VA_ARGS__)
123
+ #define r_str_new(str) mrb_str_new(mrb, str, strlen(str))
124
+ #define r_test(val) (mrb_test(val) == true)
125
+ #else
126
+ #define r_funcall(self, method, n, ...) rb_funcall(self, rb_intern(method), n, ##__VA_ARGS__)
127
+ #define r_str_new(str) rb_str_new2(str)
128
+ #define r_test(val) (val != Qfalse && val != Qnil)
129
+ #endif
72
130
 
73
- // Includes ////////////////////////////////////////////////////////////////////
131
+ // --- GC Arena ----------------------------------------------------------------
132
+ // r_gc_arena_save / r_gc_arena_restore: bracket C-driven calls into Ruby so
133
+ // values they pin in mruby's GC arena are released. mruby's mrb_funcall keeps
134
+ // its return value arena-protected for the C caller; a call site that runs once
135
+ // per frame outside the VM (the main-loop tick) would otherwise grow the arena
136
+ // unboundedly whenever the called method returns a heap object. No-ops on
137
+ // CRuby, which has no arena.
138
+ #ifdef MRUBY
139
+ #define r_gc_arena_save() mrb_gc_arena_save(mrb)
140
+ #define r_gc_arena_restore(idx) mrb_gc_arena_restore(mrb, idx)
141
+ #else
142
+ #define r_gc_arena_save() 0
143
+ #define r_gc_arena_restore(idx) ((void)(idx))
144
+ #endif
74
145
 
75
- // Define to get GNU extension functions and types, like `vasprintf()` and M_PI
76
- #ifndef _GNU_SOURCE
77
- #define _GNU_SOURCE 1
146
+ // --- Symbols & IDs -----------------------------------------------------------
147
+ // r_char_to_sym: C string → Ruby symbol value.
148
+ // r_id: C string → interned ID for fast repeated lookups.
149
+ // r_sym_to_id: Ruby symbol value → interned ID.
150
+ #ifdef MRUBY
151
+ #define r_char_to_sym(str) mrb_symbol_value(mrb_intern_cstr(mrb, str))
152
+ #define r_id(str) mrb_intern_cstr(mrb, str)
153
+ #define r_sym_to_id(val) mrb_symbol(val)
154
+ #else
155
+ #define r_char_to_sym(str) ID2SYM(rb_intern(str))
156
+ #define r_id(str) rb_intern(str)
157
+ #define r_sym_to_id(val) rb_sym2id(val)
78
158
  #endif
79
159
 
80
- #if WINDOWS && !MINGW
81
- #include <io.h>
82
- #define F_OK 0 // For testing file existence
160
+ // --- Arrays ------------------------------------------------------------------
161
+ // Create, access, and push to Ruby arrays.
162
+ #ifdef MRUBY
163
+ #define r_ary_new() mrb_ary_new(mrb)
164
+ #define r_ary_push(self, val) mrb_ary_push(mrb, self, val)
165
+ #define r_ary_entry(ary, pos) mrb_ary_entry(ary, pos)
166
+ #define r_ary_len(self) RARRAY_LEN(self)
83
167
  #else
84
- #include <unistd.h>
168
+ #define r_ary_new() rb_ary_new()
169
+ #define r_ary_push(self, val) rb_ary_push(self, val)
170
+ #define r_ary_entry(ary, pos) rb_ary_entry(ary, pos)
171
+ #define r_ary_len(self) RARRAY_LEN(self)
85
172
  #endif
86
173
 
87
- #if WINDOWS
88
- #include <stdio.h>
89
- #include <math.h>
90
- #include <winsock2.h>
91
- #include <windows.h>
92
- // For terminal colors
93
- #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
94
- #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
95
- #endif
174
+ // --- Data Wrapping -----------------------------------------------------------
175
+ // Wrap/unwrap C structs as Ruby objects for the GC to manage.
176
+ // r_wrap_struct / r_unwrap_struct: wrap a C pointer into a Ruby object / get
177
+ // the pointer back. Used by Ruby2D::Ext bindings that receive opaque handles
178
+ // as method arguments.
179
+ // r_data_ptr: get the raw C pointer from a wrapped Ruby object (untyped form
180
+ // used for opaque ext_* ivar handles when the type is known from context).
181
+ #ifdef MRUBY
182
+ #define r_wrap_struct(type, ptr) \
183
+ mrb_obj_value(Data_Wrap_Struct(mrb, mrb->object_class, &type##_data_type, ptr))
184
+ #define r_unwrap_struct(val, type) ((type *)DATA_PTR(val))
185
+ #define r_data_ptr(val) DATA_PTR(val)
186
+ #else
187
+ #define r_wrap_struct(type, ptr) \
188
+ TypedData_Wrap_Struct(rb_cObject, &type##_data_type, ptr)
189
+ #define r_unwrap_struct(val, type) ((type *)RTYPEDDATA_DATA(val))
190
+ #define r_data_ptr(val) RTYPEDDATA_DATA(val)
96
191
  #endif
97
192
 
98
- // SDL
99
- #if IOS || TVOS
100
- #include "SDL2/SDL.h"
193
+ // --- Module and Method Definition --------------------------------------------
194
+ // Define the Ruby2D module and Ruby2D::Ext class methods from C. User-facing
195
+ // Ruby classes (Triangle, Window, ...) are defined in Ruby, not here.
196
+ // r_args_variadic: marks Ext bindings as variable-arity (args via argv).
197
+ #ifdef MRUBY
198
+ #define r_define_module(name) mrb_define_module(mrb, name)
199
+ #define r_define_module_under(parent, name) mrb_define_module_under(mrb, parent, name)
200
+ #define r_define_class_method(klass, name, fn, args) mrb_define_class_method(mrb, klass, name, fn, args)
201
+ #define r_args_variadic (MRB_ARGS_ANY())
101
202
  #else
102
- #include <SDL2/SDL.h>
203
+ #define r_define_module(name) rb_define_module(name)
204
+ #define r_define_module_under(parent, name) rb_define_module_under(parent, name)
205
+ #define r_define_class_method(klass, name, fn, args) rb_define_singleton_method(klass, name, fn, args)
206
+ #define r_args_variadic (-1)
103
207
  #endif
104
208
 
105
- // If MinGW, undefine `main()` from SDL_main.c
106
- #if MINGW
107
- #undef main
209
+ // --- Error Handling ----------------------------------------------------------
210
+ // Raise a RuntimeError with a formatted message. Use for internal/unexpected
211
+ // failures (programmer errors, SDL calls that shouldn't fail).
212
+ #ifdef MRUBY
213
+ #define r_raise(...) mrb_raisef(mrb, mrb_class_get(mrb, "RuntimeError"), __VA_ARGS__)
214
+ #else
215
+ #define r_raise(...) rb_raise(rb_eRuntimeError, __VA_ARGS__)
108
216
  #endif
109
217
 
110
- #if WASM
111
- #include <stdlib.h>
112
- #include <stdio.h>
113
- #include <string.h>
114
- #include <math.h>
115
- #include <emscripten.h>
116
- #include <SDL.h>
117
- #define GL_GLEXT_PROTOTYPES 1
118
- #include <SDL_opengles2.h>
218
+ // Raise a Ruby2D::Error with a formatted message. Use for user-facing failures
219
+ // (missing/corrupt/invalid assets) so they share one rescuable exception class
220
+ // with the Ruby-side raises. `ruby2d_module` is set in R2D_Init and Ruby2D::Error
221
+ // is defined before the extension loads, so the lookup is always valid here.
222
+ #ifdef MRUBY
223
+ #define r_error(...) mrb_raisef(mrb, mrb_class_get_under(mrb, ruby2d_module, "Error"), __VA_ARGS__)
224
+ #else
225
+ #define r_error(...) rb_raise(rb_const_get(ruby2d_module, rb_intern("Error")), __VA_ARGS__)
226
+ #endif
227
+
228
+ // --- Data Type Definition ----------------------------------------------------
229
+ // Declare a GC-friendly data type for wrapping C structs as Ruby objects.
230
+ // Each TYPE must provide a TYPE_free(void *ptr) function. The macro generates
231
+ // the glue needed by each runtime's data-wrapping API.
232
+ #ifdef MRUBY
233
+ #define R2D_DEFINE_DATA_TYPE(TYPE) \
234
+ static void TYPE##_free(void *ptr); \
235
+ static void TYPE##_mrb_free(mrb_state *mrb, void *ptr) { \
236
+ (void)mrb; TYPE##_free(ptr); \
237
+ } \
238
+ static const struct mrb_data_type TYPE##_data_type = { \
239
+ #TYPE, \
240
+ TYPE##_mrb_free \
241
+ }
242
+ #else
243
+ #define R2D_DEFINE_DATA_TYPE(TYPE) \
244
+ static size_t TYPE##_memsize(const void *ptr) { \
245
+ return ptr ? sizeof(TYPE) : 0; \
246
+ } \
247
+ static void TYPE##_free(void *ptr); \
248
+ static const rb_data_type_t TYPE##_data_type = { \
249
+ #TYPE, \
250
+ { \
251
+ 0, /* dmark: no Ruby VALUEs inside, so no mark needed */ \
252
+ TYPE##_free, /* dfree */ \
253
+ TYPE##_memsize /* dsize */ \
254
+ }, \
255
+ 0, 0, \
256
+ RUBY_TYPED_FREE_IMMEDIATELY \
257
+ }
119
258
  #endif
120
259
 
121
- // OpenGL
122
- #if GLES
123
- #if IOS || TVOS
124
- #include "SDL2/SDL_opengles2.h"
125
- #else
126
- #include <SDL2/SDL_opengles2.h>
127
- #endif
260
+ // --- Instance Variable Attribute Macros --------------------------------------
261
+ // Convenience get/set wrappers for common scalar and struct types stored as
262
+ // instance variables on a Ruby object passed in via argv. Used by Ruby2D::Ext
263
+ // bindings; the `obj` argument names which Ruby object to read/write.
264
+ //
265
+ // Usage:
266
+ // int w = obj_int(img, id_width);
267
+ // obj_set_int(img, id_width, w * 2);
268
+ // const char *title = obj_str(win, id_title);
269
+ // R2D_Image *p; obj_struct(img, id_ext_image, R2D_Image, p);
270
+
271
+ #define obj_int(obj, id) NUM2INT(r_ivar_get((obj), (id)))
272
+ #define obj_set_int(obj, id, val) r_ivar_set((obj), (id), INT2NUM(val))
273
+ #define obj_float(obj, id) NUM2DBL(r_ivar_get((obj), (id)))
274
+ #define obj_set_float(obj, id, val) r_ivar_set((obj), (id), DBL2NUM(val))
275
+ #define obj_bool(obj, id) r_test(r_ivar_get((obj), (id)))
276
+ #define obj_set_bool(obj, id, val) r_ivar_set((obj), (id), (val) ? R_TRUE : R_FALSE)
277
+ #define obj_str(obj, id) RSTRING_PTR(r_ivar_get((obj), (id)))
278
+ // Byte length of the string ivar — the exact count obj_str's pointer spans,
279
+ // including any embedded NULs. Use alongside obj_str when a length-terminated
280
+ // API is needed (e.g. TTF_RenderText_*) instead of relying on NUL-termination.
281
+ #define obj_str_len(obj, id) ((size_t)RSTRING_LEN(r_ivar_get((obj), (id))))
282
+ #define obj_set_str(obj, id, val) r_ivar_set((obj), (id), r_str_new(val))
283
+
284
+ #ifdef MRUBY
285
+ #define obj_struct(obj, id, type, ptr_var) \
286
+ Data_Get_Struct(mrb, r_ivar_get((obj), (id)), &type##_data_type, ptr_var)
128
287
  #else
129
- #define GL_GLEXT_PROTOTYPES 1
130
- #if WINDOWS
131
- #define GLEW_STATIC
132
- #include <GL/glew.h>
133
- #endif
134
- #include <SDL2/SDL_opengl.h>
288
+ #define obj_struct(obj, id, type, ptr_var) \
289
+ TypedData_Get_Struct(r_ivar_get((obj), (id)), type, &type##_data_type, ptr_var)
135
290
  #endif
136
291
 
137
- // SDL libraries
138
- #if IOS || TVOS
139
- #include "SDL2/SDL_image.h"
140
- #include "SDL2/SDL_mixer.h"
141
- #include "SDL2/SDL_ttf.h"
292
+ // Wrap `ptr` as a Ruby data object and store it in ivar `id`. The wrap form is
293
+ // identical for CRuby and mruby once routed through r_wrap_struct.
294
+ #define obj_set_struct(obj, id, type, ptr) \
295
+ r_ivar_set((obj), (id), r_wrap_struct(type, ptr))
296
+
297
+ // --- Method Signature / Argument Extraction ----------------------------------
298
+ // Every Ruby2D::Ext binding uses the VARIADIC form (variable arity, args
299
+ // unpacked from argv). The first arg is conventionally the Ruby object the
300
+ // binding operates on; remaining args are method-specific.
301
+ #ifdef MRUBY
302
+ #define RUBY2D_METHOD_ARGS_VARIADIC mrb_state* mrb, R_VAL self
303
+ #define RUBY2D_EXTRACT_VARIADIC \
304
+ mrb_value *argv; \
305
+ mrb_int argc; \
306
+ mrb_get_args(mrb, "*", &argv, &argc)
142
307
  #else
143
- #include <SDL2/SDL_image.h>
144
- #include <SDL2/SDL_mixer.h>
145
- #include <SDL2/SDL_ttf.h>
308
+ #define RUBY2D_METHOD_ARGS_VARIADIC int argc, R_VAL *argv, R_VAL self
309
+ #define RUBY2D_EXTRACT_VARIADIC ((void)0)
146
310
  #endif
147
311
 
148
- // Ruby 2D Definitions /////////////////////////////////////////////////////////
312
+
313
+ // Constants ///////////////////////////////////////////////////////////////////
149
314
 
150
315
  // Messages
151
316
  #define R2D_INFO 1
@@ -154,24 +319,44 @@ extern "C" {
154
319
 
155
320
  // Window attributes
156
321
  #define R2D_RESIZABLE SDL_WINDOW_RESIZABLE
157
- #define R2D_BORDERLESS SDL_WINDOW_BORDERLESS
158
- #define R2D_FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP
159
- #define R2D_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI
322
+ #define R2D_HIGHDPI SDL_WINDOW_HIGH_PIXEL_DENSITY
160
323
  #define R2D_DISPLAY_WIDTH 0
161
324
  #define R2D_DISPLAY_HEIGHT 0
162
325
 
163
- // Viewport scaling modes
164
- #define R2D_FIXED 1
165
- #define R2D_EXPAND 2
166
- #define R2D_SCALE 3
167
- #define R2D_STRETCH 4
168
-
169
- // Positions
170
- #define R2D_CENTER 1
171
- #define R2D_TOP_LEFT 2
172
- #define R2D_TOP_RIGHT 3
173
- #define R2D_BOTTOM_LEFT 4
174
- #define R2D_BOTTOM_RIGHT 5
326
+ // Viewport scaling modes — control how the logical viewport maps to the window
327
+ // when the window is resized.
328
+ //
329
+ // LETTERBOX Scales the viewport uniformly to fit the window, adding black
330
+ // bars on the sides or top/bottom to preserve the aspect ratio.
331
+ // STRETCH Stretches the viewport to fill the entire window, which may
332
+ // distort the aspect ratio.
333
+ // INTEGER Scales using the largest integer multiplier that fits within the
334
+ // window, keeping pixels crisp (useful for pixel art).
335
+ // OVERSCAN Scales the viewport uniformly to cover the entire window,
336
+ // cropping any content that extends beyond the window edges.
337
+ // EXPAND Grows or shrinks the viewport coordinate space to match the
338
+ // window size. Content is not scaled — more or less of the world
339
+ // becomes visible as the window resizes.
340
+ // FIXED The viewport is not scaled or adjusted. Content is drawn 1:1 at
341
+ // its original size regardless of the window dimensions.
342
+ #define R2D_VIEWPORT_LETTERBOX 1
343
+ #define R2D_VIEWPORT_STRETCH 2
344
+ #define R2D_VIEWPORT_INTEGER 3
345
+ #define R2D_VIEWPORT_OVERSCAN 4
346
+ #define R2D_VIEWPORT_EXPAND 5
347
+ #define R2D_VIEWPORT_FIXED 6
348
+
349
+ // Render modes — control when the window presents frames.
350
+ //
351
+ // CONTINUOUS Render every tick up to fps_cap. Default; right for games and
352
+ // anything with continuous animation.
353
+ // ON_DEMAND Only render when Window#request_render is called, or when SDL
354
+ // signals the window must be redrawn (expose, resize, display
355
+ // change). Input, update, and frame pacing still run every tick.
356
+ // Right for apps whose contents change only in response to input:
357
+ // charts, IDEs, dashboards, most non-game GUIs.
358
+ #define R2D_RENDER_CONTINUOUS 1
359
+ #define R2D_RENDER_ON_DEMAND 2
175
360
 
176
361
  // Keyboard events
177
362
  #define R2D_KEY_DOWN 1 // key is pressed
@@ -183,6 +368,11 @@ extern "C" {
183
368
  #define R2D_MOUSE_UP 2 // mouse button released
184
369
  #define R2D_MOUSE_SCROLL 3 // mouse scrolling or wheel movement
185
370
  #define R2D_MOUSE_MOVE 4 // mouse movement
371
+ #define R2D_MOUSE_HELD 5 // mouse button is held down
372
+ #define R2D_MOUSE_ENTER 6 // cursor entered the window
373
+ #define R2D_MOUSE_LEAVE 7 // cursor left the window
374
+
375
+ // Mouse buttons
186
376
  #define R2D_MOUSE_LEFT SDL_BUTTON_LEFT
187
377
  #define R2D_MOUSE_MIDDLE SDL_BUTTON_MIDDLE
188
378
  #define R2D_MOUSE_RIGHT SDL_BUTTON_RIGHT
@@ -191,85 +381,108 @@ extern "C" {
191
381
  #define R2D_MOUSE_SCROLL_NORMAL SDL_MOUSEWHEEL_NORMAL
192
382
  #define R2D_MOUSE_SCROLL_INVERTED SDL_MOUSEWHEEL_FLIPPED
193
383
 
194
- // Controller events
195
- #define R2D_AXIS 1
196
- #define R2D_BUTTON_DOWN 2
197
- #define R2D_BUTTON_UP 3
198
-
199
- // Controller axis labels
200
- #define R2D_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID
201
- #define R2D_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX
202
- #define R2D_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY
203
- #define R2D_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX
204
- #define R2D_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY
205
- #define R2D_AXIS_TRIGGERLEFT SDL_CONTROLLER_AXIS_TRIGGERLEFT
206
- #define R2D_AXIS_TRIGGERRIGHT SDL_CONTROLLER_AXIS_TRIGGERRIGHT
207
- #define R2D_AXIS_MAX SDL_CONTROLLER_AXIS_MAX
208
-
209
- // Controller button labels
210
- #define R2D_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID
211
- #define R2D_BUTTON_A SDL_CONTROLLER_BUTTON_A
212
- #define R2D_BUTTON_B SDL_CONTROLLER_BUTTON_B
213
- #define R2D_BUTTON_X SDL_CONTROLLER_BUTTON_X
214
- #define R2D_BUTTON_Y SDL_CONTROLLER_BUTTON_Y
215
- #define R2D_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK
216
- #define R2D_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE
217
- #define R2D_BUTTON_START SDL_CONTROLLER_BUTTON_START
218
- #define R2D_BUTTON_LEFTSTICK SDL_CONTROLLER_BUTTON_LEFTSTICK
219
- #define R2D_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK
220
- #define R2D_BUTTON_LEFTSHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER
221
- #define R2D_BUTTON_RIGHTSHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
222
- #define R2D_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP
223
- #define R2D_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN
224
- #define R2D_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT
225
- #define R2D_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT
226
- #define R2D_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX
227
-
228
- // Internal Shared Data ////////////////////////////////////////////////////////
229
-
230
- extern bool R2D_diagnostics; // flag for whether to print diagnostics with R2D_Log
231
-
232
- // Type Definitions ////////////////////////////////////////////////////////////
233
-
234
- // R2D_Event
384
+ // Gamepad events
385
+ #define R2D_GAMEPAD_CONNECT 1
386
+ #define R2D_GAMEPAD_DISCONNECT 2
387
+ #define R2D_GAMEPAD_AXIS 3
388
+ #define R2D_GAMEPAD_BUTTON_DOWN 4
389
+ #define R2D_GAMEPAD_BUTTON_UP 5
390
+ #define R2D_GAMEPAD_BUTTON_HELD 6
391
+
392
+ // Gamepad axis labels
393
+ #define R2D_AXIS_INVALID SDL_GAMEPAD_AXIS_INVALID
394
+ #define R2D_AXIS_LEFTX SDL_GAMEPAD_AXIS_LEFTX
395
+ #define R2D_AXIS_LEFTY SDL_GAMEPAD_AXIS_LEFTY
396
+ #define R2D_AXIS_RIGHTX SDL_GAMEPAD_AXIS_RIGHTX
397
+ #define R2D_AXIS_RIGHTY SDL_GAMEPAD_AXIS_RIGHTY
398
+ #define R2D_AXIS_LEFT_TRIGGER SDL_GAMEPAD_AXIS_LEFT_TRIGGER
399
+ #define R2D_AXIS_RIGHT_TRIGGER SDL_GAMEPAD_AXIS_RIGHT_TRIGGER
400
+ #define R2D_AXIS_COUNT SDL_GAMEPAD_AXIS_COUNT
401
+
402
+ // Bitmap font
403
+ #define R2D_FONT_GLYPH_WIDTH 5
404
+ #define R2D_FONT_GLYPH_HEIGHT 7
405
+ #define R2D_FONT_FIRST_CHAR 0x20
406
+ #define R2D_FONT_LAST_CHAR 0x7E
407
+ #define R2D_FONT_NUM_GLYPHS 95
408
+
409
+ // Gamepad button labels
410
+ #define R2D_BUTTON_INVALID SDL_GAMEPAD_BUTTON_INVALID
411
+ #define R2D_BUTTON_SOUTH SDL_GAMEPAD_BUTTON_SOUTH
412
+ #define R2D_BUTTON_EAST SDL_GAMEPAD_BUTTON_EAST
413
+ #define R2D_BUTTON_WEST SDL_GAMEPAD_BUTTON_WEST
414
+ #define R2D_BUTTON_NORTH SDL_GAMEPAD_BUTTON_NORTH
415
+ #define R2D_BUTTON_BACK SDL_GAMEPAD_BUTTON_BACK
416
+ #define R2D_BUTTON_GUIDE SDL_GAMEPAD_BUTTON_GUIDE
417
+ #define R2D_BUTTON_START SDL_GAMEPAD_BUTTON_START
418
+ #define R2D_BUTTON_LEFT_STICK SDL_GAMEPAD_BUTTON_LEFT_STICK
419
+ #define R2D_BUTTON_RIGHT_STICK SDL_GAMEPAD_BUTTON_RIGHT_STICK
420
+ #define R2D_BUTTON_LEFT_SHOULDER SDL_GAMEPAD_BUTTON_LEFT_SHOULDER
421
+ #define R2D_BUTTON_RIGHT_SHOULDER SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER
422
+ #define R2D_BUTTON_DPAD_UP SDL_GAMEPAD_BUTTON_DPAD_UP
423
+ #define R2D_BUTTON_DPAD_DOWN SDL_GAMEPAD_BUTTON_DPAD_DOWN
424
+ #define R2D_BUTTON_DPAD_LEFT SDL_GAMEPAD_BUTTON_DPAD_LEFT
425
+ #define R2D_BUTTON_DPAD_RIGHT SDL_GAMEPAD_BUTTON_DPAD_RIGHT
426
+ #define R2D_BUTTON_MISC1 SDL_GAMEPAD_BUTTON_MISC1
427
+ #define R2D_BUTTON_PADDLE1 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1
428
+ #define R2D_BUTTON_PADDLE2 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1
429
+ #define R2D_BUTTON_PADDLE3 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2
430
+ #define R2D_BUTTON_PADDLE4 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2
431
+ #define R2D_BUTTON_TOUCHPAD SDL_GAMEPAD_BUTTON_TOUCHPAD
432
+ #define R2D_BUTTON_MISC2 SDL_GAMEPAD_BUTTON_MISC2
433
+ #define R2D_BUTTON_MISC3 SDL_GAMEPAD_BUTTON_MISC3
434
+ #define R2D_BUTTON_MISC4 SDL_GAMEPAD_BUTTON_MISC4
435
+ #define R2D_BUTTON_MISC5 SDL_GAMEPAD_BUTTON_MISC5
436
+ #define R2D_BUTTON_MISC6 SDL_GAMEPAD_BUTTON_MISC6
437
+ #define R2D_BUTTON_COUNT SDL_GAMEPAD_BUTTON_COUNT
438
+
439
+ // Gamepad battery state
440
+ #define R2D_GAMEPAD_BATTERY_UNKNOWN 0
441
+ #define R2D_GAMEPAD_BATTERY_WIRED 1
442
+ #define R2D_GAMEPAD_BATTERY_ON_BATTERY 2
443
+
444
+ // Gamepad capability bits (returned by R2D_GetGamepadCaps)
445
+ #define R2D_GAMEPAD_CAP_RUMBLE (1 << 0)
446
+ #define R2D_GAMEPAD_CAP_RUMBLE_TRIGGERS (1 << 1)
447
+ #define R2D_GAMEPAD_CAP_RGB_LED (1 << 2)
448
+
449
+
450
+ // Structs /////////////////////////////////////////////////////////////////////
451
+
452
+ // Pull-model event buffer — poll_events queues events into a C-side buffer;
453
+ // drain_events returns them to Ruby as a flat array with R2D_EVT_STRIDE
454
+ // elements per event.
455
+ #define R2D_EVT_KEY 1
456
+ #define R2D_EVT_MOUSE 2
457
+ #define R2D_EVT_GAMEPAD 3
458
+ #define R2D_EVT_CLOSE 4
459
+ #define R2D_EVT_STRIDE 12
460
+
235
461
  typedef struct {
236
- int which;
462
+ int category;
237
463
  int type;
464
+ int id;
238
465
  int button;
239
- bool dblclick;
240
- const char *key;
241
- int x;
242
- int y;
243
- int delta_x;
244
- int delta_y;
245
466
  int direction;
246
467
  int axis;
468
+ int x;
469
+ int y;
470
+ float delta_x;
471
+ float delta_y;
247
472
  int value;
248
- } R2D_Event;
249
-
250
- typedef void (*R2D_Update)();
251
- typedef void (*R2D_Render)();
252
- typedef void (*R2D_On_Key)(R2D_Event e);
253
- typedef void (*R2D_On_Mouse)(R2D_Event e);
254
- typedef void (*R2D_On_Controller)(R2D_Event e);
255
-
256
- // R2D_GL_Point, for graphics calculations
257
- typedef struct {
258
- GLfloat x;
259
- GLfloat y;
260
- } R2D_GL_Point;
473
+ const char *str;
474
+ } R2D_QueuedEvent;
261
475
 
262
476
  // R2D_Color
263
477
  typedef struct {
264
- GLfloat r;
265
- GLfloat g;
266
- GLfloat b;
267
- GLfloat a;
478
+ float r;
479
+ float g;
480
+ float b;
481
+ float a;
268
482
  } R2D_Color;
269
483
 
270
484
  // R2D_Mouse
271
485
  typedef struct {
272
- int visible;
273
486
  int x;
274
487
  int y;
275
488
  } R2D_Mouse;
@@ -278,60 +491,170 @@ typedef struct {
278
491
  typedef struct {
279
492
  int width;
280
493
  int height;
494
+ int base_width; // User-intended viewport width (not modified by expand resize)
495
+ int base_height; // User-intended viewport height (not modified by expand resize)
281
496
  int mode;
497
+ SDL_Rect fixed_rect; // Pixel-space rect for fixed mode (centered in output)
282
498
  } R2D_Viewport;
283
499
 
284
500
  // R2D_Window
285
501
  typedef struct {
286
- SDL_Window *sdl;
287
- SDL_GLContext glcontext;
288
- const GLubyte *R2D_GL_VENDOR;
289
- const GLubyte *R2D_GL_RENDERER;
290
- const GLubyte *R2D_GL_VERSION;
291
- GLint R2D_GL_MAJOR_VERSION;
292
- GLint R2D_GL_MINOR_VERSION;
293
- const GLubyte *R2D_GL_SHADING_LANGUAGE_VERSION;
502
+ SDL_Window *sdl_window;
503
+ SDL_Renderer *sdl_renderer;
294
504
  const char *title;
295
505
  int width;
296
506
  int height;
297
507
  int orig_width;
298
508
  int orig_height;
509
+ int display_width;
510
+ int display_height;
511
+ float display_content_scale;
512
+ float display_scale;
513
+ float display_refresh_rate;
299
514
  R2D_Viewport viewport;
300
- R2D_Update update;
301
- R2D_Render render;
302
515
  int flags;
516
+ R2D_Color background;
303
517
  R2D_Mouse mouse;
304
- R2D_On_Key on_key;
305
- R2D_On_Mouse on_mouse;
306
- R2D_On_Controller on_controller;
307
- bool vsync;
308
518
  int fps_cap;
309
- R2D_Color background;
310
519
  const char *icon;
311
- Uint32 frames;
312
- Uint32 elapsed_ms;
313
- Uint32 loop_ms;
314
- Uint32 delay_ms;
520
+ uint64_t frames;
315
521
  double fps;
316
522
  bool close;
523
+ bool pixel_scale;
524
+ int render_mode; // R2D_RENDER_CONTINUOUS or R2D_RENDER_ON_DEMAND
525
+ SDL_AtomicInt render_pending; // Set by request_render, cleared each rendered frame
526
+ float asset_scale; // DPI-aware coordinate multiplier for canvas/text
527
+ int display_pixel_width;
528
+ int display_pixel_height;
529
+ bool diagnostics;
530
+ bool show_fps;
531
+ char *screenshot_path; // deferred screenshot request (consumed once per frame)
317
532
  } R2D_Window;
318
533
 
319
-
320
- // R2D_Sound
534
+ // R2D_Image
321
535
  typedef struct {
322
- const char *path;
323
- Mix_Chunk *data;
324
- int channel;
325
- } R2D_Sound;
536
+ SDL_Surface *surface;
537
+ SDL_Texture *texture;
538
+ } R2D_Image;
539
+
540
+ // R2D_FontCacheEntry (defined in text.c)
541
+ typedef struct R2D_FontCacheEntry R2D_FontCacheEntry;
326
542
 
327
- // R2D_Music
543
+ // R2D_Text
544
+ typedef struct {
545
+ SDL_Surface *surface;
546
+ SDL_Texture *texture;
547
+ R2D_FontCacheEntry *font_entry;
548
+ // When non-NULL, `surface` is a shared handle owned by the text surface cache
549
+ // and must be released via R2D_TextSurfaceCacheRelease, not SDL_DestroySurface.
550
+ // When NULL, `surface` is owned by this R2D_Text (the cache-full degraded path).
551
+ char *cached_text;
552
+ // Byte length of `cached_text` (the content may contain embedded NULs, so the
553
+ // cache key is compared by length + memcmp, not strcmp). Valid when
554
+ // cached_text != NULL.
555
+ size_t cached_text_len;
556
+ // The asset scale the surface was rasterized at. When this differs from the
557
+ // current scale (e.g. the Text was built before the window opened, at scale
558
+ // 1.0), the surface is re-rasterized at draw time so HiDPI text stays crisp.
559
+ float rendered_scale;
560
+ // Content is empty (""). No surface is built; width is reported as 0
561
+ // (height stays the font's line height). The draw paths treat this as
562
+ // "nothing to draw" rather than a rasterization failure.
563
+ bool empty;
564
+ // GPU texture refresh state. texture_stale marks a freshly rasterized
565
+ // surface not yet reflected in the texture; text_draw refreshes with a
566
+ // platform-split strategy (see its comment): the web build keeps a
567
+ // persistent grow-only texture of tex_w x tex_h capacity, updated in place
568
+ // and drawn via a src rect; native recreates the texture per change
569
+ // (tex_w/tex_h unused there).
570
+ bool texture_stale;
571
+ int tex_w;
572
+ int tex_h;
573
+ } R2D_Text;
574
+
575
+ // R2D_Canvas
576
+ typedef struct {
577
+ SDL_Surface *surface;
578
+ SDL_Texture *texture;
579
+ // The asset scale the surface was allocated at. Every draw uses this cached
580
+ // value rather than the live window scale, so a Canvas built before the
581
+ // window opens still draws into the correct sub-rect afterward.
582
+ float scale;
583
+ // Region of `surface` mutated since the last GPU upload, in surface pixel
584
+ // coordinates. When `dirty` is false the texture matches the surface and
585
+ // ext_draw skips the upload entirely.
586
+ bool dirty;
587
+ SDL_Rect dirty_rect;
588
+ } R2D_Canvas;
589
+
590
+ // R2D_BitmapText
328
591
  typedef struct {
329
- const char *path;
330
- Mix_Music *data;
331
- int length; // Length of music track
332
- } R2D_Music;
592
+ SDL_Texture *texture;
593
+ char *text;
594
+ int scale;
595
+ bool background;
596
+ float logical_w;
597
+ float logical_h;
598
+ // GPU texture refresh state, platform-split like R2D_Text: the web build
599
+ // keeps a persistent grow-only texture of tex_w x tex_h capacity (unused on
600
+ // native, which recreates per change). The current string occupies the
601
+ // top-left content_w x content_h and draws via a src rect (zero when the
602
+ // string is empty).
603
+ int tex_w;
604
+ int tex_h;
605
+ int content_w;
606
+ int content_h;
607
+ } R2D_BitmapText;
608
+
609
+ // R2D_Audio
610
+ typedef struct {
611
+ MIX_Audio *mix_audio;
612
+ MIX_Track *mix_track;
613
+ } R2D_Audio;
614
+
615
+ // State Access ////////////////////////////////////////////////////////////////
616
+ //
617
+ // Each subsystem owns its state as a file-static and exposes it through
618
+ // getter/setter functions. No extern mutable globals for runtime state.
619
+
620
+ // Window state — owned by window.c
621
+ R2D_Window *R2D_GetWindow(void);
622
+
623
+ // Whether the renderer is still alive; texture finalizers check this before
624
+ // SDL_DestroyTexture so they no-op safely after the window/renderer is freed.
625
+ bool R2D_RendererAlive(void);
626
+ SDL_Renderer *R2D_GetRenderer(void);
627
+ float R2D_GetAssetScale(void);
628
+ float R2D_GetDisplayScale(void);
629
+ void R2D_SetWindow(R2D_Window *window);
630
+
631
+ // Mixer — owned by audio.c
632
+ void R2D_SetMixer(MIX_Mixer *mixer);
633
+ MIX_Mixer *R2D_GetMixer(void);
634
+
635
+ // Lazily open the audio mixer device. Kept out of R2D_Init so graphics can
636
+ // initialize on a machine with no/blocked playback device; audio entry points
637
+ // call this and surface a clear error only when audio is actually used.
638
+ bool R2D_InitAudio(void);
639
+
640
+ // Pre-window display info — populated by R2D_Init(), consumed by window_create.
641
+ // After window creation the R2D_Window fields are the canonical source.
642
+ float R2D_GetInitDisplayScale(void);
643
+ float R2D_GetInitContentScale(void);
644
+ float R2D_GetInitRefreshRate(void);
645
+ int R2D_GetInitDisplayWidth(void);
646
+ int R2D_GetInitDisplayHeight(void);
647
+ int R2D_GetInitDisplayPixelWidth(void);
648
+ int R2D_GetInitDisplayPixelHeight(void);
649
+
650
+
651
+ // Globals /////////////////////////////////////////////////////////////////////
333
652
 
334
- // Ruby 2D Functions ///////////////////////////////////////////////////////////
653
+ // Ruby 2D module
654
+ extern R_CLASS ruby2d_module;
655
+
656
+
657
+ // Utility /////////////////////////////////////////////////////////////////////
335
658
 
336
659
  /*
337
660
  * Checks if a file exists and can be accessed
@@ -343,6 +666,12 @@ bool R2D_FileExists(const char *path);
343
666
  */
344
667
  void R2D_Log(int type, const char *msg, ...);
345
668
 
669
+ /*
670
+ * Warn once per process if an SDL render call reported failure (avoids
671
+ * per-frame log flooding on a persistent GPU/driver fault)
672
+ */
673
+ void R2D_CheckSDL(bool ok, const char *what);
674
+
346
675
  /*
347
676
  * Logs Ruby 2D errors to the console, with caller and message body
348
677
  */
@@ -354,332 +683,403 @@ void R2D_Error(const char *caller, const char *msg, ...);
354
683
  void R2D_Diagnostics(bool status);
355
684
 
356
685
  /*
357
- * Enable terminal colors in Windows
686
+ * Enable/disable FPS display
358
687
  */
359
- void R2D_Windows_EnableTerminalColors();
688
+ void R2D_ShowFPS(bool status);
360
689
 
361
690
  /*
362
- * Initialize Ruby 2D subsystems
363
- */
364
- bool R2D_Init();
365
-
366
- /*
367
- * Gets the primary display's dimensions
691
+ * Calculate rolling average frame rate
368
692
  */
369
- void R2D_GetDisplayDimensions(int *w, int *h);
693
+ double R2D_GetFrameRate(void);
370
694
 
371
695
  /*
372
- * Quits Ruby 2D subsystems
696
+ * Draw FPS counter overlay on the window
373
697
  */
374
- void R2D_Quit(void);
375
-
376
- // Shapes //////////////////////////////////////////////////////////////////////
698
+ void R2D_DrawFrameRate(R2D_Window *window);
377
699
 
378
700
  /*
379
- * Rotate a point around a given point
380
- * Params:
381
- * p The point to rotate
382
- * angle The angle in degrees
383
- * rx The x coordinate to rotate around
384
- * ry The y coordinate to rotate around
701
+ * Free the cached FPS overlay resources
385
702
  */
386
- R2D_GL_Point R2D_RotatePoint(R2D_GL_Point p, GLfloat angle, GLfloat rx, GLfloat ry);
703
+ void R2D_FreeFpsOverlay(void);
387
704
 
388
705
  /*
389
- * Get the point to be rotated around given a position in a rectangle
706
+ * Allocate a new bitmap text handle
390
707
  */
391
- R2D_GL_Point R2D_GetRectRotationPoint(int x, int y, int w, int h, int position);
708
+ R2D_BitmapText *R2D_CreateBitmapText(void);
392
709
 
393
710
  /*
394
- * Draw a triangle
711
+ * Free a bitmap text handle and its cached resources
395
712
  */
396
- void R2D_DrawTriangle(
397
- GLfloat x1, GLfloat y1,
398
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
399
- GLfloat x2, GLfloat y2,
400
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
401
- GLfloat x3, GLfloat y3,
402
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3
403
- );
713
+ void R2D_FreeBitmapText(R2D_BitmapText *bt);
404
714
 
405
715
  /*
406
- * Draw a quad, using two triangles
716
+ * Render a string to a cached texture (no-op if string unchanged)
407
717
  */
408
- void R2D_DrawQuad(
409
- GLfloat x1, GLfloat y1,
410
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
411
- GLfloat x2, GLfloat y2,
412
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
413
- GLfloat x3, GLfloat y3,
414
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3,
415
- GLfloat x4, GLfloat y4,
416
- GLfloat r4, GLfloat g4, GLfloat b4, GLfloat a4
417
- );
718
+ void R2D_UpdateBitmapText(R2D_BitmapText *bt, SDL_Renderer *renderer,
719
+ const char *text, int scale);
418
720
 
419
721
  /*
420
- * Draw a line from a quad
722
+ * Draw cached bitmap text texture at (x, y) in logical coordinates
421
723
  */
422
- void R2D_DrawLine(
423
- GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
424
- GLfloat width,
425
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
426
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
427
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3,
428
- GLfloat r4, GLfloat g4, GLfloat b4, GLfloat a4
429
- );
724
+ void R2D_DrawBitmapText(R2D_BitmapText *bt, SDL_Renderer *renderer,
725
+ float x, float y);
430
726
 
431
727
  /*
432
- * Draw a circle from triangles
728
+ * Initialize Ruby 2D subsystems
433
729
  */
434
- void R2D_DrawCircle(
435
- GLfloat x, GLfloat y, GLfloat radius, int sectors,
436
- GLfloat r, GLfloat g, GLfloat b, GLfloat a
437
- );
438
-
439
- // Image ///////////////////////////////////////////////////////////////////////
730
+ bool R2D_Init(void);
440
731
 
441
732
  /*
442
- * Create a surface with image pixel data, given a file path
733
+ * Gets the primary display's dimensions
443
734
  */
444
- SDL_Surface *R2D_CreateImageSurface(const char *path);
735
+ void R2D_GetDisplayDimensions(int *w, int *h);
445
736
 
446
737
  /*
447
- * Convert images to RGB format if they are in a different (BGR for example) format.
738
+ * Add gamepad mappings from a file. Returns the number of mappings added,
739
+ * or -1 on error.
448
740
  */
449
- void R2D_ImageConvertToRGB(SDL_Surface *surface);
450
-
451
- // Font ////////////////////////////////////////////////////////////////////////
741
+ int R2D_AddGamepadMappingsFromFile(const char *path);
452
742
 
453
743
  /*
454
- * Create a TTF_Font object given a path to a font and a size
744
+ * Add a single gamepad mapping from a string. Returns 1 if added, 0 if it
745
+ * updated an existing mapping, or -1 on error.
455
746
  */
456
- TTF_Font *R2D_FontCreateTTFFont(const char *path, int size, const char *style);
457
-
458
- // Text ////////////////////////////////////////////////////////////////////////
747
+ int R2D_AddGamepadMapping(const char *mapping);
459
748
 
460
749
  /*
461
- * Create a SDL_Surface that contains the pixel data to render text, given a font and message
750
+ * Trigger whole-gamepad rumble. Strengths are 0.0..1.0; duration is in
751
+ * seconds. Returns true on success.
462
752
  */
463
- SDL_Surface *R2D_TextCreateSurface(TTF_Font *font, const char *message);
464
-
465
- // Sound ///////////////////////////////////////////////////////////////////////
753
+ bool R2D_RumbleGamepad(SDL_JoystickID id, double low, double high, double duration);
466
754
 
467
755
  /*
468
- * Create a sound, given an audio file path
756
+ * Trigger trigger-only rumble (PS5/DualSense, Xbox Series with adaptive
757
+ * triggers, etc). Strengths are 0.0..1.0; duration is in seconds.
758
+ * Returns true on success.
469
759
  */
470
- R2D_Sound *R2D_CreateSound(const char *path);
760
+ bool R2D_RumbleGamepadTriggers(SDL_JoystickID id, double left, double right, double duration);
471
761
 
472
762
  /*
473
- * Play the sound
763
+ * Set the gamepad's LED color (PS4/PS5). Components are 0..255.
764
+ * Returns true on success.
474
765
  */
475
- void R2D_PlaySound(R2D_Sound *snd, bool loop);
766
+ bool R2D_SetGamepadLED(SDL_JoystickID id, int r, int g, int b);
476
767
 
477
768
  /*
478
- * Stop the sound
769
+ * Look up the gamepad's battery status. Writes a percent (0..100, or -1
770
+ * if unknown) to *out_percent and returns one of the R2D_GAMEPAD_BATTERY_*
771
+ * constants.
479
772
  */
480
- void R2D_StopSound(R2D_Sound *snd);
773
+ int R2D_GetGamepadBattery(SDL_JoystickID id, int *out_percent);
481
774
 
482
775
  /*
483
- * Get the sound's length
776
+ * Capability checks. Return true if the connected gamepad reports the
777
+ * given button or axis.
484
778
  */
485
- int R2D_GetSoundLength(R2D_Sound *snd);
779
+ bool R2D_GamepadHasButton(SDL_JoystickID id, int button);
780
+ bool R2D_GamepadHasAxis(SDL_JoystickID id, int axis);
486
781
 
487
782
  /*
488
- * Get the sound's volume
783
+ * Returns a bitfield of R2D_GAMEPAD_CAP_* flags describing which feedback
784
+ * capabilities the gamepad reports.
489
785
  */
490
- int R2D_GetSoundVolume(R2D_Sound *snd);
786
+ int R2D_GetGamepadCaps(SDL_JoystickID id);
491
787
 
492
- /*
493
- * Set the sound's volume a given percentage
494
- */
495
- void R2D_SetSoundVolume(R2D_Sound *snd, int volume);
788
+
789
+ // Ext /////////////////////////////////////////////////////////////////////////
496
790
 
497
791
  /*
498
- * Get the sound mixer volume
792
+ * The Ruby2D::Ext module Ruby-callable bindings to libruby2d C primitives.
793
+ * Subsystem .c files (audio, image, text, etc.) register their own bindings
794
+ * on this module in their R2D_*_Init functions.
499
795
  */
500
- int R2D_GetSoundMixVolume();
796
+ extern R_CLASS ruby2d_ext_module;
501
797
 
502
798
  /*
503
- * Set the sound mixer volume a given percentage
799
+ * Shared ivar ID cache. Subsystem .c files reference these instead of
800
+ * caching their own per-file copies. Defined and interned in R2D_Ext_Init
801
+ * (ext.c). Subsystem-specific ivars (e.g. @clip_x, @fps_cap, @ext_audio)
802
+ * stay as static R_IDs in the subsystem that owns them.
504
803
  */
505
- void R2D_SetSoundMixVolume(int volume);
804
+ extern R_ID id_x, id_y, id_width, id_height, id_rotate;
805
+ extern R_ID id_color, id_r, id_g, id_b, id_a;
806
+ extern R_ID id_ext_image, id_ext_text;
807
+ extern R_ID id_path, id_content;
808
+ extern R_ID id_viewport_width, id_viewport_height;
506
809
 
507
810
  /*
508
- * Free the sound
811
+ * Initialize Ruby2D::Ext — creates the module and registers shape bindings.
812
+ * Must run before any other R2D_*_Init so the module exists for them.
509
813
  */
510
- void R2D_FreeSound(R2D_Sound *snd);
814
+ void R2D_Ext_Init(void);
511
815
 
512
- // Canvas //////////////////////////////////////////////////////////////////////
513
816
 
514
- /*
515
- * Draw a thick rectangle on a canvas using a pre-converted RGBA colour value.
516
- * @param [int] thickness must be > 1, else does nothing
517
- */
518
- void R2D_Canvas_DrawThickRect(SDL_Renderer *render, int x, int y, int width,
519
- int height, int thickness, int r, int g, int b,
520
- int a);
817
+ // Shapes //////////////////////////////////////////////////////////////////////
818
+ //
819
+ // Pure C primitives. Ruby-callable wrappers live in ext.c (Ruby2D::Ext).
521
820
 
522
821
  /*
523
- * Draw a thick line on a canvas using a pre-converted RGBA colour value.
524
- * @param [int] thickness must be > 1, else does nothing
822
+ * Draw a triangle
525
823
  */
526
- void R2D_Canvas_DrawThickLine(SDL_Renderer *render,
527
- int x1, int y1, int x2, int y2, int thickness,
528
- int r, int g, int b, int a);
824
+ void R2D_DrawTriangle(
825
+ float x1, float y1,
826
+ float r1, float g1, float b1, float a1,
827
+ float x2, float y2,
828
+ float r2, float g2, float b2, float a2,
829
+ float x3, float y3,
830
+ float r3, float g3, float b3, float a3
831
+ );
529
832
 
530
833
  /*
531
- * Draw a thin (single pixel) ellipse on a canvas using a pre-converted RGBA
532
- * colour value.
834
+ * Draw a quad, using two triangles
533
835
  */
534
- void R2D_Canvas_DrawThinEllipse(SDL_Renderer *render, int x, int y,
535
- float xradius, float yradius, float sectors,
536
- int r, int g, int b, int a);
836
+ void R2D_DrawQuad(
837
+ float x1, float y1,
838
+ float r1, float g1, float b1, float a1,
839
+ float x2, float y2,
840
+ float r2, float g2, float b2, float a2,
841
+ float x3, float y3,
842
+ float r3, float g3, float b3, float a3,
843
+ float x4, float y4,
844
+ float r4, float g4, float b4, float a4
845
+ );
537
846
 
538
847
  /*
539
- * Draw a thick ellipse on a canvas using a pre-converted RGBA colour value.
540
- * @param [int] thickness must be > 1, else does nothing
848
+ * Draw a line from a quad
541
849
  */
542
- void R2D_Canvas_DrawThickEllipse(SDL_Renderer *render, int x, int y,
543
- float xradius, float yradius, float sectors,
544
- int thickness, int r, int g, int b, int a);
850
+ void R2D_DrawLine(
851
+ float x1, float y1, float x2, float y2,
852
+ float width,
853
+ float r1, float g1, float b1, float a1,
854
+ float r2, float g2, float b2, float a2,
855
+ float r3, float g3, float b3, float a3,
856
+ float r4, float g4, float b4, float a4
857
+ );
545
858
 
546
859
  /*
547
- * Draw a thick N-point polyline, with a mitre join where two
548
- * segments are joined.
549
- * @param [int] thickness must be > 1, else does nothing
550
- * @param [bool] skip_first_last use false for polyline, true for polygon when specifying first, second points again at the end
860
+ * Draw a circle from triangles
551
861
  */
552
- void R2D_Canvas_DrawThickPolyline(SDL_Renderer *render, SDL_FPoint *points,
553
- int num_points, int thickness, int r, int g,
554
- int b, int a, bool skip_first_last);
862
+ void R2D_DrawCircle(
863
+ float x, float y, float radius, int sectors,
864
+ float r, float g, float b, float a
865
+ );
555
866
 
556
867
  /*
557
- * Fill a polygon with a single colour.
558
- * @param points Array of points
559
- * @param num_points Number of points
560
- * @param colors Array of colours
561
- * @param num_colors Number of colors, must be at least 1, and may be less than
562
- * +num_points+ in which case the colours will be repeated
563
- * via modulo.
564
- * @note Currently supports only: convex polygons or simple polygons with one concave corner. For now.
868
+ * Compute the outer and inner outline points for a polyline or polygon stroke.
869
+ * `verts` is a flat array of `n` (x, y) pairs. `closed` treats the polyline as
870
+ * a closed polygon (corners computed for every vertex); otherwise endpoints get
871
+ * butt caps. `stroke_width` is the total stroke thickness. `miter_limit` clamps
872
+ * sharp corners (SVG default: 4.0). `outer` and `inner` must be preallocated
873
+ * with `n * 2` floats each.
565
874
  */
566
- void R2D_Canvas_FillPolygon(SDL_Renderer *render, SDL_FPoint *points,
567
- int num_points, SDL_Color *colors, int num_colors);
875
+ void R2D_ComputeStrokeOutline(
876
+ const float *verts, int n, int closed,
877
+ float stroke_width, float miter_limit,
878
+ float *outer, float *inner
879
+ );
568
880
 
569
- // Music ///////////////////////////////////////////////////////////////////////
881
+ // SVG default miter-limit (miter switches to clamped past this ratio)
882
+ #define R2D_MITER_LIMIT 4.0f
570
883
 
571
- /*
572
- * Create the music, given an audio file path
573
- */
574
- R2D_Music *R2D_CreateMusic(const char *path);
884
+ // Vertex-count threshold below which the stroke/geometry helpers serve their
885
+ // scratch buffers from the stack. Covers triangles (n=3), quads (n=4), default
886
+ // 30-sector circles/ellipses, and all but the largest polygons/polylines;
887
+ // larger paths fall back to the heap. Avoids per-frame malloc/free churn.
888
+ #define R2D_STROKE_STACK_N 64
575
889
 
576
890
  /*
577
- * Play the music
891
+ * Stroke a polyline or closed polygon via SDL_RenderGeometry. Miter-joined
892
+ * corners clamped at `miter_limit` (SVG default 4.0). When `closed` is non-zero
893
+ * the last vertex connects back to the first; otherwise endpoints get butt caps.
578
894
  */
579
- void R2D_PlayMusic(R2D_Music *mus, bool loop);
895
+ void R2D_StrokePath(
896
+ const float *verts, int n, int closed,
897
+ float stroke_width, float miter_limit,
898
+ const float *colors
899
+ );
580
900
 
581
901
  /*
582
- * Pause the playing music
902
+ * Stroke an ellipse outline as a ring of triangles via SDL_RenderGeometry.
903
+ * `angle` (radians) tilts the ellipse off-axis; pass 0 for axis-aligned.
583
904
  */
584
- void R2D_PauseMusic();
905
+ void R2D_StrokeEllipse(
906
+ float cx, float cy, float rx, float ry, float angle,
907
+ int sectors, float stroke_width,
908
+ float r, float g, float b, float a
909
+ );
585
910
 
586
911
  /*
587
- * Resume the current music
912
+ * Draw a filled ellipse via a triangle fan.
913
+ * `angle` (radians) tilts the ellipse off-axis; pass 0 for axis-aligned.
588
914
  */
589
- void R2D_ResumeMusic();
915
+ void R2D_DrawEllipse(
916
+ float cx, float cy, float rx, float ry, float angle, int sectors,
917
+ float r, float g, float b, float a
918
+ );
590
919
 
591
920
  /*
592
- * Stop the playing music; interrupts fader effects
921
+ * Triangulate a simple polygon by ear clipping.
922
+ * `verts` is n pairs of (x, y). On success returns a malloc'd array of
923
+ * (n - 2) * 3 vertex indices (caller must free) and writes the triangle
924
+ * count to *out_tri_count. Returns NULL on failure (n < 3, allocation,
925
+ * or degenerate input). Self-intersecting input is out of scope: output
926
+ * is defined but may not be visually faithful.
593
927
  */
594
- void R2D_StopMusic();
928
+ int *R2D_TriangulatePolygon(const float *verts, int n, int *out_tri_count);
595
929
 
596
930
  /*
597
- * Get the music volume
931
+ * Draw a filled polygon. Triangulated via ear clipping so concave
932
+ * polygons fill correctly. `verts` is n pairs of (x, y). When
933
+ * `per_vertex_colors` is non-NULL it is n × 4 floats (rgba per vertex)
934
+ * and overrides the single r,g,b,a color.
598
935
  */
599
- int R2D_GetMusicVolume();
936
+ void R2D_DrawPolygon(
937
+ const float *verts, int n,
938
+ const float *per_vertex_colors,
939
+ float r, float g, float b, float a
940
+ );
600
941
 
601
942
  /*
602
- * Set the music volume a given percentage
943
+ * Draw a dashed line from (x1,y1) to (x2,y2) as repeated thick quads.
944
+ * Each of the 4 input colors maps to a corner of the full line quad
945
+ * (c1=start+perp, c2=start-perp, c3=end-perp, c4=end+perp). Per-segment
946
+ * endpoint colors are linearly interpolated along the length.
603
947
  */
604
- void R2D_SetMusicVolume(int volume);
948
+ void R2D_DrawDashedLine(
949
+ float x1, float y1, float x2, float y2,
950
+ float stroke_width, float dash, float gap,
951
+ float r1, float g1, float b1, float a1,
952
+ float r2, float g2, float b2, float a2,
953
+ float r3, float g3, float b3, float a3,
954
+ float r4, float g4, float b4, float a4
955
+ );
605
956
 
606
- /*
607
- * Fade out the playing music
608
- */
609
- void R2D_FadeOutMusic(int ms);
957
+ // Image ///////////////////////////////////////////////////////////////////////
958
+ //
959
+ // SDL_image-backed textures. Ruby-callable bindings live as Ruby2D::Ext class
960
+ // methods (image_create, image_draw, image_draw_quads, image_resize). Bindings
961
+ // take the Image Ruby object as their first argument and read its ivars.
610
962
 
611
963
  /*
612
- * Get the length of the music in seconds
964
+ * Initialize Ruby2D::Ext image bindings.
613
965
  */
614
- int R2D_GetMusicLength(R2D_Music *mus);
966
+ void R2D_Image_Init(void);
967
+
968
+ R_VAL ruby2d_ext_image_create(RUBY2D_METHOD_ARGS_VARIADIC);
969
+ R_VAL ruby2d_ext_image_draw(RUBY2D_METHOD_ARGS_VARIADIC);
970
+ R_VAL ruby2d_ext_image_draw_quads(RUBY2D_METHOD_ARGS_VARIADIC);
971
+ R_VAL ruby2d_ext_image_resize(RUBY2D_METHOD_ARGS_VARIADIC);
972
+
973
+
974
+ // Text ////////////////////////////////////////////////////////////////////////
615
975
 
616
976
  /*
617
- * Free the music
977
+ * Initialize Ruby2D::Ext text bindings (TTF-backed text).
618
978
  */
619
- void R2D_FreeMusic(R2D_Music *mus);
979
+ void R2D_Text_Init(void);
980
+
981
+ R_VAL ruby2d_ext_text_create(RUBY2D_METHOD_ARGS_VARIADIC);
982
+ R_VAL ruby2d_ext_text_draw(RUBY2D_METHOD_ARGS_VARIADIC);
983
+
620
984
 
621
- // Input ///////////////////////////////////////////////////////////////////////
985
+ // BitmapText //////////////////////////////////////////////////////////////////
622
986
 
623
987
  /*
624
- * Get the mouse coordinates relative to the viewport
988
+ * Initialize Ruby2D::Ext bitmap-text bindings (built-in 5x7 font for overlays).
625
989
  */
626
- void R2D_GetMouseOnViewport(R2D_Window *window, int wx, int wy, int *x, int *y);
990
+ void R2D_BitmapText_Init(void);
991
+
992
+ R_VAL ruby2d_ext_bitmap_text_create(RUBY2D_METHOD_ARGS_VARIADIC);
993
+ R_VAL ruby2d_ext_bitmap_text_draw(RUBY2D_METHOD_ARGS_VARIADIC);
994
+
995
+
996
+ // Canvas //////////////////////////////////////////////////////////////////////
997
+ //
998
+ // SDL_Surface-backed off-screen drawing target. Ruby-callable bindings live
999
+ // as Ruby2D::Ext class methods; bindings take the Canvas Ruby object as
1000
+ // argv[0] and read ivars off it. Per-pixel kernels remain in C.
627
1001
 
628
1002
  /*
629
- * Show the cursor over the window
1003
+ * Initialize Ruby2D::Ext canvas bindings.
630
1004
  */
631
- void R2D_ShowCursor();
1005
+ void R2D_Canvas_Init(void);
1006
+
1007
+ R_VAL ruby2d_ext_canvas_create(RUBY2D_METHOD_ARGS_VARIADIC);
1008
+ R_VAL ruby2d_ext_canvas_draw(RUBY2D_METHOD_ARGS_VARIADIC);
1009
+ R_VAL ruby2d_ext_canvas_clear(RUBY2D_METHOD_ARGS_VARIADIC);
1010
+ R_VAL ruby2d_ext_canvas_fill_triangle(RUBY2D_METHOD_ARGS_VARIADIC);
1011
+ R_VAL ruby2d_ext_canvas_fill_triangle_lerp(RUBY2D_METHOD_ARGS_VARIADIC);
1012
+ R_VAL ruby2d_ext_canvas_fill_rectangle(RUBY2D_METHOD_ARGS_VARIADIC);
1013
+ R_VAL ruby2d_ext_canvas_fill_rectangles(RUBY2D_METHOD_ARGS_VARIADIC);
1014
+ R_VAL ruby2d_ext_canvas_fill_pixel_grid(RUBY2D_METHOD_ARGS_VARIADIC);
1015
+ R_VAL ruby2d_ext_canvas_fill_ellipse(RUBY2D_METHOD_ARGS_VARIADIC);
1016
+ R_VAL ruby2d_ext_canvas_fill_polygon(RUBY2D_METHOD_ARGS_VARIADIC);
1017
+ R_VAL ruby2d_ext_canvas_fill_polygon_lerp(RUBY2D_METHOD_ARGS_VARIADIC);
1018
+ R_VAL ruby2d_ext_canvas_draw_line(RUBY2D_METHOD_ARGS_VARIADIC);
1019
+ R_VAL ruby2d_ext_canvas_draw_line_lerp(RUBY2D_METHOD_ARGS_VARIADIC);
1020
+ R_VAL ruby2d_ext_canvas_draw_lines(RUBY2D_METHOD_ARGS_VARIADIC);
1021
+ R_VAL ruby2d_ext_canvas_stroke_polygon(RUBY2D_METHOD_ARGS_VARIADIC);
1022
+ R_VAL ruby2d_ext_canvas_stroke_polyline(RUBY2D_METHOD_ARGS_VARIADIC);
1023
+ R_VAL ruby2d_ext_canvas_draw_image(RUBY2D_METHOD_ARGS_VARIADIC);
1024
+ R_VAL ruby2d_ext_canvas_draw_text(RUBY2D_METHOD_ARGS_VARIADIC);
1025
+
1026
+
1027
+ // Audio ///////////////////////////////////////////////////////////////////////
1028
+ //
1029
+ // SDL_mixer-backed audio. Ruby-callable bindings live as Ruby2D::Ext class
1030
+ // methods registered in audio.c (audio_load, audio_play, audio_pause, ...).
632
1031
 
633
1032
  /*
634
- * Hide the cursor over the window
1033
+ * Initialize Ruby2D::Ext audio bindings.
635
1034
  */
636
- void R2D_HideCursor();
1035
+ void R2D_Audio_Init(void);
637
1036
 
638
- // Controllers /////////////////////////////////////////////////////////////////
1037
+
1038
+ // Window //////////////////////////////////////////////////////////////////////
639
1039
 
640
1040
  /*
641
- * Add controller mapping from string
1041
+ * Initialize Ruby2D::Window native bindings
642
1042
  */
643
- void R2D_AddControllerMapping(const char *map);
1043
+ void R2D_Window_Init(void);
644
1044
 
645
1045
  /*
646
- * Load controller mappings from the specified file
1046
+ * Apply viewport scaling mode via SDL3 logical presentation
647
1047
  */
648
- void R2D_AddControllerMappingsFromFile(const char *path);
1048
+ void R2D_ApplyViewportMode(R2D_Window *window);
649
1049
 
650
1050
  /*
651
- * Check if joystick is a controller
1051
+ * Set the icon for the window
652
1052
  */
653
- bool R2D_IsController(SDL_JoystickID id);
1053
+ void R2D_SetIcon(R2D_Window *window, const char *icon);
654
1054
 
655
1055
  /*
656
- * Open controllers and joysticks
1056
+ * Take a screenshot of the window
657
1057
  */
658
- void R2D_OpenControllers();
659
-
660
- // Window //////////////////////////////////////////////////////////////////////
1058
+ void R2D_Screenshot(R2D_Window *window, const char *path);
661
1059
 
662
1060
  /*
663
- * Create a window
1061
+ * Show the cursor over the window
664
1062
  */
665
- R2D_Window *R2D_CreateWindow(
666
- const char *title, int width, int height, R2D_Update, R2D_Render, int flags
667
- );
1063
+ void R2D_ShowCursor(void);
668
1064
 
669
1065
  /*
670
- * Show the window
1066
+ * Hide the cursor over the window
671
1067
  */
672
- int R2D_Show(R2D_Window *window);
1068
+ void R2D_HideCursor(void);
673
1069
 
674
1070
  /*
675
- * Set the icon for the window
1071
+ * Check if the cursor is visible
676
1072
  */
677
- void R2D_SetIcon(R2D_Window *window, const char *icon);
1073
+ bool R2D_CursorVisible(void);
678
1074
 
679
1075
  /*
680
- * Take a screenshot of the window
1076
+ * Set the system cursor by name. Returns true on success, false on failure.
1077
+ * Valid names: "default", "text", "wait", "crosshair", "progress",
1078
+ * "nwse_resize", "nesw_resize", "ew_resize", "ns_resize", "move",
1079
+ * "not_allowed", "pointer", "nw_resize", "n_resize", "ne_resize",
1080
+ * "e_resize", "se_resize", "s_resize", "sw_resize", "w_resize"
681
1081
  */
682
- void R2D_Screenshot(R2D_Window *window, const char *path);
1082
+ bool R2D_SetSystemCursor(const char *name);
683
1083
 
684
1084
  /*
685
1085
  * Close the window
@@ -691,69 +1091,49 @@ int R2D_Close(R2D_Window *window);
691
1091
  */
692
1092
  int R2D_FreeWindow(R2D_Window *window);
693
1093
 
694
- // Ruby 2D OpenGL Functions ////////////////////////////////////////////////////
695
-
696
- int R2D_GL_Init(R2D_Window *window);
697
- void R2D_GL_PrintError(const char *error);
698
- void R2D_GL_PrintContextInfo(R2D_Window *window);
699
- void R2D_GL_StoreContextInfo(R2D_Window *window);
700
- GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, const char *shaderName);
701
- int R2D_GL_CheckLinked(GLuint program, const char *name);
702
- void R2D_GL_GetViewportScale(R2D_Window *window, int *w, int *h, double *scale);
703
- void R2D_GL_SetViewport(R2D_Window *window);
704
- void R2D_GL_CreateTexture(
705
- GLuint *id, GLint internalFormat, GLint format, GLenum type,
706
- int w, int h,
707
- const GLvoid *data, GLint filter);
708
- void R2D_GL_DrawTriangle(
709
- GLfloat x1, GLfloat y1,
710
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
711
- GLfloat x2, GLfloat y2,
712
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
713
- GLfloat x3, GLfloat y3,
714
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
715
- void R2D_GL_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id);
716
- void R2D_GL_FreeTexture(GLuint *id);
717
- void R2D_GL_Clear(R2D_Color clr);
718
- void R2D_GL_FlushBuffers();
719
-
720
- // OpenGL & GLES Internal Functions ////////////////////////////////////////////
721
-
722
- #if GLES
723
- int R2D_GLES_Init();
724
- void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]);
725
- void R2D_GLES_DrawTriangle(
726
- GLfloat x1, GLfloat y1,
727
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
728
- GLfloat x2, GLfloat y2,
729
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
730
- GLfloat x3, GLfloat y3,
731
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
732
- void R2D_GLES_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id);
733
- void R2D_GLES_FlushBuffers();
734
- #else
735
- int R2D_GL2_Init();
736
- int R2D_GL3_Init();
737
- void R2D_GL2_ApplyProjection(int w, int h);
738
- void R2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]);
739
- void R2D_GL2_DrawTriangle(
740
- GLfloat x1, GLfloat y1,
741
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
742
- GLfloat x2, GLfloat y2,
743
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
744
- GLfloat x3, GLfloat y3,
745
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
746
- void R2D_GL3_DrawTriangle(
747
- GLfloat x1, GLfloat y1,
748
- GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
749
- GLfloat x2, GLfloat y2,
750
- GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
751
- GLfloat x3, GLfloat y3,
752
- GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
753
- void R2D_GL2_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id);
754
- void R2D_GL3_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id);
755
- void R2D_GL3_FlushBuffers();
756
- #endif
1094
+ // Ruby2D::Ext window bindings — Ruby owns frame sequencing via its `tick`
1095
+ // method: poll_events → drain_events → begin_frame → end_frame. Events are
1096
+ // queued into a C-side buffer and returned to Ruby as a flat array; no
1097
+ // C-to-Ruby callbacks. CRuby drives the loop from Ruby; mruby/WASM use a
1098
+ // C-driven loop that calls Ruby's tick.
1099
+ R_VAL ruby2d_ext_window_create(RUBY2D_METHOD_ARGS_VARIADIC);
1100
+ R_VAL ruby2d_ext_window_show(RUBY2D_METHOD_ARGS_VARIADIC);
1101
+ R_VAL ruby2d_ext_window_poll_events(RUBY2D_METHOD_ARGS_VARIADIC);
1102
+ R_VAL ruby2d_ext_window_drain_events(RUBY2D_METHOD_ARGS_VARIADIC);
1103
+ R_VAL ruby2d_ext_window_scancode_name(RUBY2D_METHOD_ARGS_VARIADIC);
1104
+ R_VAL ruby2d_ext_window_begin_frame(RUBY2D_METHOD_ARGS_VARIADIC);
1105
+ R_VAL ruby2d_ext_window_end_frame(RUBY2D_METHOD_ARGS_VARIADIC);
1106
+ R_VAL ruby2d_ext_now(RUBY2D_METHOD_ARGS_VARIADIC);
1107
+ R_VAL ruby2d_ext_window_get_display_dimensions(RUBY2D_METHOD_ARGS_VARIADIC);
1108
+ R_VAL ruby2d_ext_window_set_viewport_mode(RUBY2D_METHOD_ARGS_VARIADIC);
1109
+ R_VAL ruby2d_ext_window_set_icon(RUBY2D_METHOD_ARGS_VARIADIC);
1110
+ R_VAL ruby2d_ext_window_set_title(RUBY2D_METHOD_ARGS_VARIADIC);
1111
+ R_VAL ruby2d_ext_window_set_resizable(RUBY2D_METHOD_ARGS_VARIADIC);
1112
+ R_VAL ruby2d_ext_window_set_size(RUBY2D_METHOD_ARGS_VARIADIC);
1113
+ R_VAL ruby2d_ext_window_diagnostics(RUBY2D_METHOD_ARGS_VARIADIC);
1114
+ R_VAL ruby2d_ext_window_set_fps_cap(RUBY2D_METHOD_ARGS_VARIADIC);
1115
+ R_VAL ruby2d_ext_window_show_fps(RUBY2D_METHOD_ARGS_VARIADIC);
1116
+ R_VAL ruby2d_ext_window_load_gamepad_mappings_file(RUBY2D_METHOD_ARGS_VARIADIC);
1117
+ R_VAL ruby2d_ext_window_add_gamepad_mapping(RUBY2D_METHOD_ARGS_VARIADIC);
1118
+ R_VAL ruby2d_ext_window_gamepad_rumble(RUBY2D_METHOD_ARGS_VARIADIC);
1119
+ R_VAL ruby2d_ext_window_gamepad_rumble_triggers(RUBY2D_METHOD_ARGS_VARIADIC);
1120
+ R_VAL ruby2d_ext_window_gamepad_set_led(RUBY2D_METHOD_ARGS_VARIADIC);
1121
+ R_VAL ruby2d_ext_window_gamepad_type(RUBY2D_METHOD_ARGS_VARIADIC);
1122
+ R_VAL ruby2d_ext_window_gamepad_battery(RUBY2D_METHOD_ARGS_VARIADIC);
1123
+ R_VAL ruby2d_ext_window_gamepad_has_button(RUBY2D_METHOD_ARGS_VARIADIC);
1124
+ R_VAL ruby2d_ext_window_gamepad_has_axis(RUBY2D_METHOD_ARGS_VARIADIC);
1125
+ R_VAL ruby2d_ext_window_gamepad_caps(RUBY2D_METHOD_ARGS_VARIADIC);
1126
+ R_VAL ruby2d_ext_window_gamepad_debug_info(RUBY2D_METHOD_ARGS_VARIADIC);
1127
+ R_VAL ruby2d_ext_window_gamepad_joystick_state(RUBY2D_METHOD_ARGS_VARIADIC);
1128
+ R_VAL ruby2d_ext_window_screenshot(RUBY2D_METHOD_ARGS_VARIADIC);
1129
+ R_VAL ruby2d_ext_window_show_cursor(RUBY2D_METHOD_ARGS_VARIADIC);
1130
+ R_VAL ruby2d_ext_window_hide_cursor(RUBY2D_METHOD_ARGS_VARIADIC);
1131
+ R_VAL ruby2d_ext_window_cursor_visible(RUBY2D_METHOD_ARGS_VARIADIC);
1132
+ R_VAL ruby2d_ext_window_set_system_cursor(RUBY2D_METHOD_ARGS_VARIADIC);
1133
+ R_VAL ruby2d_ext_window_close(RUBY2D_METHOD_ARGS_VARIADIC);
1134
+ R_VAL ruby2d_ext_window_set_render_mode(RUBY2D_METHOD_ARGS_VARIADIC);
1135
+ R_VAL ruby2d_ext_window_request_render(RUBY2D_METHOD_ARGS_VARIADIC);
1136
+
757
1137
 
758
1138
  #ifdef __cplusplus
759
1139
  }