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.
- checksums.yaml +4 -4
- data/LICENSE.md +7 -0
- data/README.md +141 -0
- data/USAGE.md +2435 -0
- data/assets/Rakefile +637 -0
- data/assets/build_support/CMakeLists.txt +94 -0
- data/assets/build_support/mruby/build_config.rb +34 -0
- data/assets/build_support/mruby/build_config_wasm.rb +30 -0
- data/assets/build_support/sdl_test.c +174 -0
- data/assets/deps.yaml +16 -0
- data/assets/platform/include/SDL3/SDL.h +91 -0
- data/assets/platform/include/SDL3/SDL_assert.h +705 -0
- data/assets/platform/include/SDL3/SDL_asyncio.h +550 -0
- data/assets/platform/include/SDL3/SDL_atomic.h +692 -0
- data/assets/platform/include/SDL3/SDL_audio.h +2370 -0
- data/assets/platform/include/SDL3/SDL_begin_code.h +553 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_bits.h +47 -27
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_blendmode.h +59 -55
- data/assets/platform/include/SDL3/SDL_camera.h +535 -0
- data/assets/platform/include/SDL3/SDL_clipboard.h +331 -0
- data/assets/{include/SDL2/close_code.h → platform/include/SDL3/SDL_close_code.h} +9 -8
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_copying.h +3 -1
- data/assets/platform/include/SDL3/SDL_cpuinfo.h +374 -0
- data/assets/platform/include/SDL3/SDL_dialog.h +343 -0
- data/assets/platform/include/SDL3/SDL_dlopennote.h +234 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_egl.h +11 -8
- data/assets/platform/include/SDL3/SDL_endian.h +645 -0
- data/assets/platform/include/SDL3/SDL_error.h +226 -0
- data/assets/platform/include/SDL3/SDL_events.h +1645 -0
- data/assets/platform/include/SDL3/SDL_filesystem.h +537 -0
- data/assets/platform/include/SDL3/SDL_gamepad.h +1656 -0
- data/assets/platform/include/SDL3/SDL_gpu.h +4608 -0
- data/assets/platform/include/SDL3/SDL_guid.h +106 -0
- data/assets/platform/include/SDL3/SDL_haptic.h +1461 -0
- data/assets/platform/include/SDL3/SDL_hidapi.h +571 -0
- data/assets/platform/include/SDL3/SDL_hints.h +5001 -0
- data/assets/platform/include/SDL3/SDL_init.h +507 -0
- data/assets/platform/include/SDL3/SDL_intrin.h +410 -0
- data/assets/platform/include/SDL3/SDL_iostream.h +1379 -0
- data/assets/platform/include/SDL3/SDL_joystick.h +1385 -0
- data/assets/platform/include/SDL3/SDL_keyboard.h +608 -0
- data/assets/platform/include/SDL3/SDL_keycode.h +347 -0
- data/assets/platform/include/SDL3/SDL_loadso.h +145 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_locale.h +40 -24
- data/assets/platform/include/SDL3/SDL_log.h +541 -0
- data/assets/platform/include/SDL3/SDL_main.h +704 -0
- data/assets/platform/include/SDL3/SDL_main_impl.h +151 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_messagebox.h +85 -48
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_metal.h +29 -29
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_misc.h +13 -12
- data/assets/platform/include/SDL3/SDL_mouse.h +813 -0
- data/assets/platform/include/SDL3/SDL_mutex.h +1117 -0
- data/assets/platform/include/SDL3/SDL_oldnames.h +1339 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl.h +1247 -278
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl_glext.h +5 -1
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles.h +6 -7
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2.h +10 -11
- data/assets/platform/include/SDL3/SDL_pen.h +198 -0
- data/assets/platform/include/SDL3/SDL_pixels.h +1441 -0
- data/assets/{include/SDL2/SDL_test_log.h → platform/include/SDL3/SDL_platform.h} +25 -26
- data/assets/platform/include/SDL3/SDL_platform_defines.h +497 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_power.h +40 -20
- data/assets/platform/include/SDL3/SDL_process.h +441 -0
- data/assets/platform/include/SDL3/SDL_properties.h +572 -0
- data/assets/platform/include/SDL3/SDL_rect.h +528 -0
- data/assets/platform/include/SDL3/SDL_render.h +3028 -0
- data/assets/platform/include/SDL3/SDL_revision.h +59 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_scancode.h +59 -68
- data/assets/platform/include/SDL3/SDL_sensor.h +321 -0
- data/assets/platform/include/SDL3/SDL_stdinc.h +6186 -0
- data/assets/platform/include/SDL3/SDL_storage.h +686 -0
- data/assets/platform/include/SDL3/SDL_surface.h +1769 -0
- data/assets/platform/include/SDL3/SDL_system.h +840 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test.h +16 -22
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_assert.h +27 -34
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_common.h +109 -52
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_compare.h +22 -14
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_crc32.h +27 -30
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_font.h +50 -49
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_fuzzer.h +64 -79
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_harness.h +47 -30
- data/assets/platform/include/SDL3/SDL_test_log.h +83 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_md5.h +21 -28
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_memory.h +19 -16
- data/assets/platform/include/SDL3/SDL_thread.h +602 -0
- data/assets/platform/include/SDL3/SDL_time.h +249 -0
- data/assets/platform/include/SDL3/SDL_timer.h +454 -0
- data/assets/platform/include/SDL3/SDL_touch.h +184 -0
- data/assets/platform/include/SDL3/SDL_tray.h +544 -0
- data/assets/platform/include/SDL3/SDL_version.h +198 -0
- data/assets/platform/include/SDL3/SDL_video.h +3497 -0
- data/assets/platform/include/SDL3/SDL_vulkan.h +287 -0
- data/assets/platform/include/SDL3_image/SDL_image.h +3328 -0
- data/assets/platform/include/SDL3_mixer/SDL_mixer.h +3369 -0
- data/assets/platform/include/SDL3_ttf/SDL_textengine.h +181 -0
- data/assets/platform/include/SDL3_ttf/SDL_ttf.h +2833 -0
- data/assets/{include → platform/include}/mrbconf.h +42 -31
- data/assets/{include → platform/include}/mruby/array.h +3 -4
- data/assets/{include → platform/include}/mruby/boxing_nan.h +10 -0
- data/assets/platform/include/mruby/boxing_no.h +59 -0
- data/assets/{include → platform/include}/mruby/boxing_word.h +72 -26
- data/assets/platform/include/mruby/class.h +157 -0
- data/assets/{include → platform/include}/mruby/common.h +30 -1
- data/assets/{include → platform/include}/mruby/compile.h +52 -74
- data/assets/{include → platform/include}/mruby/data.h +2 -2
- data/assets/{include → platform/include}/mruby/debug.h +12 -5
- data/assets/{include → platform/include}/mruby/dump.h +7 -9
- data/assets/{include → platform/include}/mruby/endian.h +1 -1
- data/assets/platform/include/mruby/error.h +173 -0
- data/assets/platform/include/mruby/gc.h +79 -0
- data/assets/{include → platform/include}/mruby/hash.h +1 -7
- data/assets/platform/include/mruby/internal.h +282 -0
- data/assets/platform/include/mruby/irep.h +143 -0
- data/assets/{include → platform/include}/mruby/istruct.h +1 -1
- data/assets/platform/include/mruby/khash.h +455 -0
- data/assets/platform/include/mruby/mempool.h +19 -0
- data/assets/{include → platform/include}/mruby/numeric.h +7 -10
- data/assets/platform/include/mruby/object.h +51 -0
- data/assets/{include → platform/include}/mruby/opcode.h +5 -5
- data/assets/{include → platform/include}/mruby/ops.h +19 -6
- data/assets/platform/include/mruby/presym/id.h +1447 -0
- data/assets/{include → platform/include}/mruby/presym/scanning.h +10 -7
- data/assets/platform/include/mruby/presym/table.h +2893 -0
- data/assets/platform/include/mruby/presym.h +65 -0
- data/assets/platform/include/mruby/proc.h +184 -0
- data/assets/{include → platform/include}/mruby/range.h +0 -2
- data/assets/{include → platform/include}/mruby/string.h +33 -53
- data/assets/platform/include/mruby/throw.h +81 -0
- data/assets/{include → platform/include}/mruby/value.h +64 -29
- data/assets/{include → platform/include}/mruby/variable.h +6 -23
- data/assets/{include → platform/include}/mruby/version.h +7 -7
- data/assets/{include → platform/include}/mruby.h +238 -116
- data/assets/platform/macos-arm64/bin/mrbc +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_image.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/macos-arm64/lib/libmruby.a +0 -0
- data/assets/platform/wasm/lib/libFLAC.a +0 -0
- data/assets/platform/wasm/lib/libSDL3.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_image.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/wasm/lib/libfreetype.a +0 -0
- data/assets/platform/wasm/lib/libharfbuzz.a +0 -0
- data/assets/platform/wasm/lib/libmruby.a +0 -0
- data/assets/platform/wasm/lib/libogg.a +0 -0
- data/assets/platform/wasm/lib/libplutosvg.a +0 -0
- data/assets/platform/wasm/lib/libplutovg.a +0 -0
- data/assets/platform/wasm/lib/libpng.a +0 -0
- data/assets/platform/wasm/lib/libpng16.a +0 -0
- data/assets/platform/wasm/lib/libvorbis.a +0 -0
- data/assets/platform/wasm/lib/libvorbisfile.a +0 -0
- data/assets/platform/wasm/lib/libzlibstatic.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/bin/mrbc.exe +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_image.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libmruby.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/bin/mrbc.exe +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_image.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libmruby.a +0 -0
- data/assets/resources/fonts/outfit/OFL.txt +93 -0
- data/assets/resources/fonts/outfit/outfit.ttf +0 -0
- data/assets/resources/fonts/roboto_mono/OFL.txt +91 -0
- data/assets/resources/fonts/roboto_mono/roboto_mono.ttf +0 -0
- data/assets/resources/icons/icon.icns +0 -0
- data/assets/resources/icons/icon.png +0 -0
- data/assets/resources/spritesheets/License.txt +28 -0
- data/assets/resources/spritesheets/spritesheet-backgrounds.png +0 -0
- data/assets/resources/spritesheets/spritesheet-backgrounds.xml +16 -0
- data/assets/resources/spritesheets/spritesheet-characters.png +0 -0
- data/assets/resources/spritesheets/spritesheet-characters.xml +47 -0
- data/assets/resources/spritesheets/spritesheet-enemies.png +0 -0
- data/assets/resources/spritesheets/spritesheet-enemies.xml +62 -0
- data/assets/resources/spritesheets/spritesheet-tiles.png +0 -0
- data/assets/resources/spritesheets/spritesheet-tiles.xml +316 -0
- data/assets/{wasm → resources/web}/template.html +1 -1
- data/assets/target.rb +131 -0
- data/bin/ruby2d +281 -82
- data/examples/astar.rb +269 -0
- data/examples/asteroids.rb +403 -0
- data/examples/bezier_editor.rb +96 -0
- data/examples/boids.rb +191 -0
- data/examples/bouncing_balls.rb +119 -0
- data/examples/breakout.rb +186 -0
- data/examples/constellations.rb +100 -0
- data/examples/dashboard.rb +133 -0
- data/examples/double_pendulum.rb +254 -0
- data/examples/falling_sand.rb +291 -0
- data/examples/fireworks.rb +110 -0
- data/examples/fluid_dynamics.rb +340 -0
- data/examples/fourier_epicycles.rb +142 -0
- data/examples/fractal_tree.rb +326 -0
- data/examples/game_of_life.rb +148 -0
- data/examples/gamepads.rb +333 -0
- data/examples/hill_driver.rb +613 -0
- data/examples/logo_animation.rb +251 -0
- data/examples/lorenz_attractor.rb +115 -0
- data/examples/mandelbrot.rb +207 -0
- data/examples/marching_squares.rb +200 -0
- data/examples/maze.rb +323 -0
- data/examples/nbody.rb +338 -0
- data/examples/outrun.rb +391 -0
- data/examples/pixel_paint.rb +313 -0
- data/examples/platformer.rb +335 -0
- data/examples/ray_casting_maze.rb +175 -0
- data/examples/shadow_casting.rb +151 -0
- data/examples/shape_recognizer.rb +908 -0
- data/examples/snake.rb +144 -0
- data/examples/sprite_sheets.rb +246 -0
- data/examples/swarm.rb +206 -0
- data/examples/tsp_annealing.rb +104 -0
- data/examples/ui_controls.rb +163 -0
- data/examples/wireframe_3d.rb +139 -0
- data/ext/ruby2d/audio.c +324 -0
- data/ext/ruby2d/canvas.c +1715 -494
- data/ext/ruby2d/ext.c +541 -0
- data/ext/ruby2d/extconf.rb +122 -145
- data/ext/ruby2d/font.c +566 -20
- data/ext/ruby2d/fps.c +92 -0
- data/ext/ruby2d/image.c +466 -41
- data/ext/ruby2d/ruby2d.c +374 -1890
- data/ext/ruby2d/ruby2d.h +840 -460
- data/ext/ruby2d/shapes.c +931 -101
- data/ext/ruby2d/text.c +586 -21
- data/ext/ruby2d/window.c +1693 -283
- data/lib/ruby2d/atlas_parser.rb +194 -0
- data/lib/ruby2d/audio.rb +73 -0
- data/lib/ruby2d/benchmark.rb +259 -0
- data/lib/ruby2d/bitmap_text.rb +155 -0
- data/lib/ruby2d/button.rb +402 -0
- data/lib/ruby2d/canvas.rb +703 -279
- data/lib/ruby2d/circle.rb +206 -29
- data/lib/ruby2d/cli/browser.rb +314 -0
- data/lib/ruby2d/cli/build.rb +471 -257
- data/lib/ruby2d/cli/colorize.rb +7 -5
- data/lib/ruby2d/cli/examples.rb +127 -0
- data/lib/ruby2d/cli/launch.rb +24 -39
- data/lib/ruby2d/cli/lib_files.rb +48 -0
- data/lib/ruby2d/cli/messages.rb +40 -0
- data/lib/ruby2d/cli/setup.rb +273 -0
- data/lib/ruby2d/cli/static_server.rb +160 -0
- data/lib/ruby2d/cli/usage.rb +255 -0
- data/lib/ruby2d/color.rb +191 -69
- data/lib/ruby2d/core.rb +37 -19
- data/lib/ruby2d/deps_help.rb +89 -0
- data/lib/ruby2d/dsl.rb +51 -12
- data/lib/ruby2d/ellipse.rb +228 -0
- data/lib/ruby2d/exceptions.rb +0 -2
- data/lib/ruby2d/font.rb +34 -74
- data/lib/ruby2d/gamepad.rb +323 -0
- data/lib/ruby2d/gem_paths.rb +19 -0
- data/lib/ruby2d/image.rb +155 -52
- data/lib/ruby2d/interactive.rb +103 -0
- data/lib/ruby2d/json_parser.rb +268 -0
- data/lib/ruby2d/line.rb +194 -85
- data/lib/ruby2d/mruby_compat.rb +12 -0
- data/lib/ruby2d/polygon.rb +297 -0
- data/lib/ruby2d/polyline.rb +368 -0
- data/lib/ruby2d/quad.rb +358 -94
- data/lib/ruby2d/rectangle.rb +77 -19
- data/lib/ruby2d/renderable.rb +411 -11
- data/lib/ruby2d/sprite.rb +471 -180
- data/lib/ruby2d/sprite_sheet.rb +64 -0
- data/lib/ruby2d/square.rb +29 -17
- data/lib/ruby2d/text.rb +196 -65
- data/lib/ruby2d/tileset.rb +139 -81
- data/lib/ruby2d/triangle.rb +324 -89
- data/lib/ruby2d/version.rb +1 -3
- data/lib/ruby2d/vertices.rb +62 -85
- data/lib/ruby2d/warnings.rb +29 -0
- data/lib/ruby2d/window/class_methods.rb +218 -0
- data/lib/ruby2d/window/gamepad_events.rb +141 -0
- data/lib/ruby2d/window/key_events.rb +74 -0
- data/lib/ruby2d/window/mouse_events.rb +171 -0
- data/lib/ruby2d/window/object_events.rb +168 -0
- data/lib/ruby2d/window.rb +632 -585
- data/lib/ruby2d.rb +14 -19
- metadata +275 -443
- data/assets/app.icns +0 -0
- data/assets/include/GL/glew.h +0 -26427
- data/assets/include/GLES2/gl2.h +0 -656
- data/assets/include/GLES2/gl2ext.h +0 -3949
- data/assets/include/GLES2/gl2ext_angle.h +0 -701
- data/assets/include/GLES2/gl2platform.h +0 -27
- data/assets/include/GLES3/gl3.h +0 -1192
- data/assets/include/GLES3/gl31.h +0 -1507
- data/assets/include/GLES3/gl32.h +0 -1808
- data/assets/include/GLES3/gl3platform.h +0 -27
- data/assets/include/KHR/khrplatform.h +0 -290
- data/assets/include/SDL2/SDL.h +0 -233
- data/assets/include/SDL2/SDL_assert.h +0 -326
- data/assets/include/SDL2/SDL_atomic.h +0 -415
- data/assets/include/SDL2/SDL_audio.h +0 -1500
- data/assets/include/SDL2/SDL_clipboard.h +0 -141
- data/assets/include/SDL2/SDL_config.h +0 -61
- data/assets/include/SDL2/SDL_config_android.h +0 -194
- data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
- data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
- data/assets/include/SDL2/SDL_config_macosx.h +0 -277
- data/assets/include/SDL2/SDL_config_minimal.h +0 -95
- data/assets/include/SDL2/SDL_config_ngage.h +0 -89
- data/assets/include/SDL2/SDL_config_os2.h +0 -207
- data/assets/include/SDL2/SDL_config_pandora.h +0 -141
- data/assets/include/SDL2/SDL_config_windows.h +0 -331
- data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
- data/assets/include/SDL2/SDL_config_winrt.h +0 -220
- data/assets/include/SDL2/SDL_config_xbox.h +0 -235
- data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
- data/assets/include/SDL2/SDL_endian.h +0 -348
- data/assets/include/SDL2/SDL_error.h +0 -163
- data/assets/include/SDL2/SDL_events.h +0 -1166
- data/assets/include/SDL2/SDL_filesystem.h +0 -149
- data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
- data/assets/include/SDL2/SDL_gesture.h +0 -117
- data/assets/include/SDL2/SDL_guid.h +0 -100
- data/assets/include/SDL2/SDL_haptic.h +0 -1341
- data/assets/include/SDL2/SDL_hidapi.h +0 -451
- data/assets/include/SDL2/SDL_hints.h +0 -2569
- data/assets/include/SDL2/SDL_image.h +0 -2173
- data/assets/include/SDL2/SDL_joystick.h +0 -1066
- data/assets/include/SDL2/SDL_keyboard.h +0 -353
- data/assets/include/SDL2/SDL_keycode.h +0 -358
- data/assets/include/SDL2/SDL_loadso.h +0 -115
- data/assets/include/SDL2/SDL_log.h +0 -404
- data/assets/include/SDL2/SDL_main.h +0 -275
- data/assets/include/SDL2/SDL_mixer.h +0 -2784
- data/assets/include/SDL2/SDL_mouse.h +0 -465
- data/assets/include/SDL2/SDL_mutex.h +0 -471
- data/assets/include/SDL2/SDL_name.h +0 -33
- data/assets/include/SDL2/SDL_pixels.h +0 -644
- data/assets/include/SDL2/SDL_platform.h +0 -261
- data/assets/include/SDL2/SDL_quit.h +0 -58
- data/assets/include/SDL2/SDL_rect.h +0 -376
- data/assets/include/SDL2/SDL_render.h +0 -1919
- data/assets/include/SDL2/SDL_revision.h +0 -6
- data/assets/include/SDL2/SDL_rwops.h +0 -841
- data/assets/include/SDL2/SDL_sensor.h +0 -322
- data/assets/include/SDL2/SDL_shape.h +0 -155
- data/assets/include/SDL2/SDL_stdinc.h +0 -830
- data/assets/include/SDL2/SDL_surface.h +0 -997
- data/assets/include/SDL2/SDL_system.h +0 -623
- data/assets/include/SDL2/SDL_syswm.h +0 -386
- data/assets/include/SDL2/SDL_test_images.h +0 -78
- data/assets/include/SDL2/SDL_test_random.h +0 -115
- data/assets/include/SDL2/SDL_thread.h +0 -464
- data/assets/include/SDL2/SDL_timer.h +0 -222
- data/assets/include/SDL2/SDL_touch.h +0 -150
- data/assets/include/SDL2/SDL_ttf.h +0 -2316
- data/assets/include/SDL2/SDL_types.h +0 -29
- data/assets/include/SDL2/SDL_version.h +0 -204
- data/assets/include/SDL2/SDL_video.h +0 -2150
- data/assets/include/SDL2/SDL_vulkan.h +0 -215
- data/assets/include/SDL2/begin_code.h +0 -187
- data/assets/include/mruby/boxing_no.h +0 -58
- data/assets/include/mruby/class.h +0 -108
- data/assets/include/mruby/error.h +0 -147
- data/assets/include/mruby/gc.h +0 -94
- data/assets/include/mruby/irep.h +0 -147
- data/assets/include/mruby/khash.h +0 -284
- data/assets/include/mruby/object.h +0 -43
- data/assets/include/mruby/presym/disable.h +0 -70
- data/assets/include/mruby/presym/enable.h +0 -37
- data/assets/include/mruby/presym.h +0 -40
- data/assets/include/mruby/proc.h +0 -211
- data/assets/include/mruby/throw.h +0 -66
- data/assets/macos/universal/bin/mrbc +0 -0
- data/assets/macos/universal/lib/libFLAC.a +0 -0
- data/assets/macos/universal/lib/libSDL2.a +0 -0
- data/assets/macos/universal/lib/libSDL2_image.a +0 -0
- data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/universal/lib/libavif.a +0 -0
- data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
- data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
- data/assets/macos/universal/lib/libfreetype.a +0 -0
- data/assets/macos/universal/lib/libgraphite2.a +0 -0
- data/assets/macos/universal/lib/libharfbuzz.a +0 -0
- data/assets/macos/universal/lib/libhwy.a +0 -0
- data/assets/macos/universal/lib/libjpeg.a +0 -0
- data/assets/macos/universal/lib/libjxl.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/universal/lib/libmpg123.a +0 -0
- data/assets/macos/universal/lib/libmruby.a +0 -0
- data/assets/macos/universal/lib/libogg.a +0 -0
- data/assets/macos/universal/lib/libpng.a +0 -0
- data/assets/macos/universal/lib/libtiff.a +0 -0
- data/assets/macos/universal/lib/libvorbis.a +0 -0
- data/assets/macos/universal/lib/libvorbisfile.a +0 -0
- data/assets/macos/universal/lib/libwebp.a +0 -0
- data/assets/macos/universal/lib/libzstd.a +0 -0
- data/assets/test_media/README.md +0 -3
- data/assets/test_media/bitstream_vera/COPYRIGHT.txt +0 -124
- data/assets/test_media/bitstream_vera/vera.ttf +0 -0
- data/assets/test_media/boom.png +0 -0
- data/assets/test_media/coin.png +0 -0
- data/assets/test_media/colors.png +0 -0
- data/assets/test_media/controller.png +0 -0
- data/assets/test_media/dial.wav +0 -0
- data/assets/test_media/hero.png +0 -0
- data/assets/test_media/image.bmp +0 -0
- data/assets/test_media/image.jpg +0 -0
- data/assets/test_media/image.png +0 -0
- data/assets/test_media/music.flac +0 -0
- data/assets/test_media/music.mp3 +0 -0
- data/assets/test_media/music.ogg +0 -0
- data/assets/test_media/music.wav +0 -0
- data/assets/test_media/originals/boom.pxm +0 -0
- data/assets/test_media/originals/coin.pxm +0 -0
- data/assets/test_media/originals/controller.sketch +0 -0
- data/assets/test_media/originals/hero.pxm +0 -0
- data/assets/test_media/originals/image.pxm +0 -0
- data/assets/test_media/originals/music.caf +0 -0
- data/assets/test_media/originals/texture_atlas.pxm +0 -0
- data/assets/test_media/rondo_alla_turka.ogg +0 -0
- data/assets/test_media/sound.flac +0 -0
- data/assets/test_media/sound.mp3 +0 -0
- data/assets/test_media/sound.ogg +0 -0
- data/assets/test_media/sound.wav +0 -0
- data/assets/test_media/sprite_sheet.png +0 -0
- data/assets/test_media/texture_atlas.png +0 -0
- data/assets/wasm/libmruby.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -1
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
- data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -1
- data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
- data/assets/xcode/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
- data/assets/xcode/ios/Assets.xcassets/Contents.json +0 -6
- data/assets/xcode/ios/Base.lproj/LaunchScreen.storyboard +0 -27
- data/assets/xcode/ios/Info.plist +0 -43
- data/assets/xcode/ios/MRuby.framework/Headers/mrbconf.h +0 -143
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/array.h +0 -280
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/class.h +0 -97
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/common.h +0 -77
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/compile.h +0 -195
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/data.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/debug.h +0 -67
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/dump.h +0 -196
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/error.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/gc.h +0 -91
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/hash.h +0 -215
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/irep.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/istruct.h +0 -47
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/khash.h +0 -274
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/numeric.h +0 -161
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/object.h +0 -44
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/opcode.h +0 -69
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/ops.h +0 -117
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/proc.h +0 -131
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/range.h +0 -49
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/re.h +0 -16
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/string.h +0 -444
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/throw.h +0 -55
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/value.h +0 -309
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/variable.h +0 -136
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/version.h +0 -110
- data/assets/xcode/ios/MRuby.framework/Headers/mruby.h +0 -1282
- data/assets/xcode/ios/MRuby.framework/Info.plist +0 -20
- data/assets/xcode/ios/MRuby.framework/MRuby +0 -0
- data/assets/xcode/ios/MyApp.xcodeproj/project.pbxproj +0 -368
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
- data/assets/xcode/ios/main.c +0 -1
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -17
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -17
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -32
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -22
- data/assets/xcode/tvos/Info.plist +0 -30
- data/assets/xcode/tvos/MRuby.framework/Headers/mrbconf.h +0 -143
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/array.h +0 -280
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/class.h +0 -97
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/common.h +0 -77
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/compile.h +0 -195
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/data.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/debug.h +0 -67
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/dump.h +0 -196
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/error.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/gc.h +0 -91
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/hash.h +0 -215
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/irep.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/istruct.h +0 -47
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/khash.h +0 -274
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/numeric.h +0 -161
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/object.h +0 -44
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/opcode.h +0 -69
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/ops.h +0 -117
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/proc.h +0 -131
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/range.h +0 -49
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/re.h +0 -16
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/string.h +0 -444
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/throw.h +0 -55
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/value.h +0 -309
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/variable.h +0 -136
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/version.h +0 -110
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby.h +0 -1282
- data/assets/xcode/tvos/MRuby.framework/Info.plist +0 -20
- data/assets/xcode/tvos/MRuby.framework/MRuby +0 -0
- data/assets/xcode/tvos/MyApp.xcodeproj/project.pbxproj +0 -350
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
- data/assets/xcode/tvos/main.c +0 -1
- data/ext/ruby2d/common.c +0 -185
- data/ext/ruby2d/controllers.c +0 -110
- data/ext/ruby2d/gl.c +0 -398
- data/ext/ruby2d/gl2.c +0 -86
- data/ext/ruby2d/gl3.c +0 -304
- data/ext/ruby2d/gles.c +0 -302
- data/ext/ruby2d/input.c +0 -48
- data/ext/ruby2d/music.c +0 -127
- data/ext/ruby2d/sound.c +0 -132
- data/lib/ruby2d/cli/console.rb +0 -65
- data/lib/ruby2d/cli/enable_console.rb +0 -7
- data/lib/ruby2d/cli/platform.rb +0 -17
- data/lib/ruby2d/music.rb +0 -77
- data/lib/ruby2d/pixel.rb +0 -18
- data/lib/ruby2d/pixmap.rb +0 -39
- data/lib/ruby2d/pixmap_atlas.rb +0 -56
- data/lib/ruby2d/sound.rb +0 -61
- data/lib/ruby2d/texture.rb +0 -38
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2ext.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2platform.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_khrplatform.h +0 -0
- /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 <
|
|
26
|
+
#include <stdlib.h>
|
|
27
|
+
#include <math.h>
|
|
11
28
|
|
|
12
|
-
|
|
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
|
-
//
|
|
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
|
-
#
|
|
43
|
-
#
|
|
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
|
-
#
|
|
41
|
+
#include <unistd.h>
|
|
52
42
|
#endif
|
|
53
43
|
|
|
54
|
-
// WebAssembly
|
|
55
44
|
#ifdef __EMSCRIPTEN__
|
|
56
|
-
#
|
|
57
|
-
#else
|
|
58
|
-
#define WASM false
|
|
45
|
+
#include <emscripten.h>
|
|
59
46
|
#endif
|
|
60
47
|
|
|
61
48
|
|
|
62
|
-
//
|
|
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
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
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
|
-
//
|
|
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
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
#
|
|
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
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
#
|
|
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
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
#define
|
|
118
|
-
|
|
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
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
|
130
|
-
|
|
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
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
#
|
|
144
|
-
#
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
//
|
|
195
|
-
#define
|
|
196
|
-
#define
|
|
197
|
-
#define
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#define
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
#define
|
|
204
|
-
#define
|
|
205
|
-
#define
|
|
206
|
-
#define
|
|
207
|
-
#define
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
#define
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
#define
|
|
214
|
-
#define
|
|
215
|
-
#define
|
|
216
|
-
#define
|
|
217
|
-
#define
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
#define
|
|
221
|
-
#define
|
|
222
|
-
#define
|
|
223
|
-
#define
|
|
224
|
-
#define
|
|
225
|
-
#define
|
|
226
|
-
#define
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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 *
|
|
287
|
-
|
|
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
|
-
|
|
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
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
int
|
|
332
|
-
|
|
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
|
|
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
|
|
686
|
+
* Enable/disable FPS display
|
|
358
687
|
*/
|
|
359
|
-
void
|
|
688
|
+
void R2D_ShowFPS(bool status);
|
|
360
689
|
|
|
361
690
|
/*
|
|
362
|
-
*
|
|
363
|
-
*/
|
|
364
|
-
bool R2D_Init();
|
|
365
|
-
|
|
366
|
-
/*
|
|
367
|
-
* Gets the primary display's dimensions
|
|
691
|
+
* Calculate rolling average frame rate
|
|
368
692
|
*/
|
|
369
|
-
|
|
693
|
+
double R2D_GetFrameRate(void);
|
|
370
694
|
|
|
371
695
|
/*
|
|
372
|
-
*
|
|
696
|
+
* Draw FPS counter overlay on the window
|
|
373
697
|
*/
|
|
374
|
-
void
|
|
375
|
-
|
|
376
|
-
// Shapes //////////////////////////////////////////////////////////////////////
|
|
698
|
+
void R2D_DrawFrameRate(R2D_Window *window);
|
|
377
699
|
|
|
378
700
|
/*
|
|
379
|
-
*
|
|
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
|
-
|
|
703
|
+
void R2D_FreeFpsOverlay(void);
|
|
387
704
|
|
|
388
705
|
/*
|
|
389
|
-
*
|
|
706
|
+
* Allocate a new bitmap text handle
|
|
390
707
|
*/
|
|
391
|
-
|
|
708
|
+
R2D_BitmapText *R2D_CreateBitmapText(void);
|
|
392
709
|
|
|
393
710
|
/*
|
|
394
|
-
*
|
|
711
|
+
* Free a bitmap text handle and its cached resources
|
|
395
712
|
*/
|
|
396
|
-
void
|
|
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
|
-
*
|
|
716
|
+
* Render a string to a cached texture (no-op if string unchanged)
|
|
407
717
|
*/
|
|
408
|
-
void
|
|
409
|
-
|
|
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
|
|
722
|
+
* Draw cached bitmap text texture at (x, y) in logical coordinates
|
|
421
723
|
*/
|
|
422
|
-
void
|
|
423
|
-
|
|
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
|
-
*
|
|
728
|
+
* Initialize Ruby 2D subsystems
|
|
433
729
|
*/
|
|
434
|
-
|
|
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
|
-
*
|
|
733
|
+
* Gets the primary display's dimensions
|
|
443
734
|
*/
|
|
444
|
-
|
|
735
|
+
void R2D_GetDisplayDimensions(int *w, int *h);
|
|
445
736
|
|
|
446
737
|
/*
|
|
447
|
-
*
|
|
738
|
+
* Add gamepad mappings from a file. Returns the number of mappings added,
|
|
739
|
+
* or -1 on error.
|
|
448
740
|
*/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// Font ////////////////////////////////////////////////////////////////////////
|
|
741
|
+
int R2D_AddGamepadMappingsFromFile(const char *path);
|
|
452
742
|
|
|
453
743
|
/*
|
|
454
|
-
*
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
// Text ////////////////////////////////////////////////////////////////////////
|
|
747
|
+
int R2D_AddGamepadMapping(const char *mapping);
|
|
459
748
|
|
|
460
749
|
/*
|
|
461
|
-
*
|
|
750
|
+
* Trigger whole-gamepad rumble. Strengths are 0.0..1.0; duration is in
|
|
751
|
+
* seconds. Returns true on success.
|
|
462
752
|
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
// Sound ///////////////////////////////////////////////////////////////////////
|
|
753
|
+
bool R2D_RumbleGamepad(SDL_JoystickID id, double low, double high, double duration);
|
|
466
754
|
|
|
467
755
|
/*
|
|
468
|
-
*
|
|
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
|
-
|
|
760
|
+
bool R2D_RumbleGamepadTriggers(SDL_JoystickID id, double left, double right, double duration);
|
|
471
761
|
|
|
472
762
|
/*
|
|
473
|
-
*
|
|
763
|
+
* Set the gamepad's LED color (PS4/PS5). Components are 0..255.
|
|
764
|
+
* Returns true on success.
|
|
474
765
|
*/
|
|
475
|
-
|
|
766
|
+
bool R2D_SetGamepadLED(SDL_JoystickID id, int r, int g, int b);
|
|
476
767
|
|
|
477
768
|
/*
|
|
478
|
-
*
|
|
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
|
-
|
|
773
|
+
int R2D_GetGamepadBattery(SDL_JoystickID id, int *out_percent);
|
|
481
774
|
|
|
482
775
|
/*
|
|
483
|
-
*
|
|
776
|
+
* Capability checks. Return true if the connected gamepad reports the
|
|
777
|
+
* given button or axis.
|
|
484
778
|
*/
|
|
485
|
-
|
|
779
|
+
bool R2D_GamepadHasButton(SDL_JoystickID id, int button);
|
|
780
|
+
bool R2D_GamepadHasAxis(SDL_JoystickID id, int axis);
|
|
486
781
|
|
|
487
782
|
/*
|
|
488
|
-
*
|
|
783
|
+
* Returns a bitfield of R2D_GAMEPAD_CAP_* flags describing which feedback
|
|
784
|
+
* capabilities the gamepad reports.
|
|
489
785
|
*/
|
|
490
|
-
int
|
|
786
|
+
int R2D_GetGamepadCaps(SDL_JoystickID id);
|
|
491
787
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
*/
|
|
495
|
-
void R2D_SetSoundVolume(R2D_Sound *snd, int volume);
|
|
788
|
+
|
|
789
|
+
// Ext /////////////////////////////////////////////////////////////////////////
|
|
496
790
|
|
|
497
791
|
/*
|
|
498
|
-
*
|
|
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
|
-
|
|
796
|
+
extern R_CLASS ruby2d_ext_module;
|
|
501
797
|
|
|
502
798
|
/*
|
|
503
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
814
|
+
void R2D_Ext_Init(void);
|
|
511
815
|
|
|
512
|
-
// Canvas //////////////////////////////////////////////////////////////////////
|
|
513
816
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
|
524
|
-
* @param [int] thickness must be > 1, else does nothing
|
|
822
|
+
* Draw a triangle
|
|
525
823
|
*/
|
|
526
|
-
void
|
|
527
|
-
|
|
528
|
-
|
|
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
|
|
532
|
-
* colour value.
|
|
834
|
+
* Draw a quad, using two triangles
|
|
533
835
|
*/
|
|
534
|
-
void
|
|
535
|
-
|
|
536
|
-
|
|
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
|
|
540
|
-
* @param [int] thickness must be > 1, else does nothing
|
|
848
|
+
* Draw a line from a quad
|
|
541
849
|
*/
|
|
542
|
-
void
|
|
543
|
-
|
|
544
|
-
|
|
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
|
|
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
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
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
|
|
567
|
-
|
|
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
|
-
//
|
|
881
|
+
// SVG default miter-limit (miter switches to clamped past this ratio)
|
|
882
|
+
#define R2D_MITER_LIMIT 4.0f
|
|
570
883
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
928
|
+
int *R2D_TriangulatePolygon(const float *verts, int n, int *out_tri_count);
|
|
595
929
|
|
|
596
930
|
/*
|
|
597
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|
-
*
|
|
964
|
+
* Initialize Ruby2D::Ext image bindings.
|
|
613
965
|
*/
|
|
614
|
-
|
|
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
|
-
*
|
|
977
|
+
* Initialize Ruby2D::Ext text bindings (TTF-backed text).
|
|
618
978
|
*/
|
|
619
|
-
void
|
|
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
|
-
//
|
|
985
|
+
// BitmapText //////////////////////////////////////////////////////////////////
|
|
622
986
|
|
|
623
987
|
/*
|
|
624
|
-
*
|
|
988
|
+
* Initialize Ruby2D::Ext bitmap-text bindings (built-in 5x7 font for overlays).
|
|
625
989
|
*/
|
|
626
|
-
void
|
|
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
|
-
*
|
|
1003
|
+
* Initialize Ruby2D::Ext canvas bindings.
|
|
630
1004
|
*/
|
|
631
|
-
void
|
|
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
|
-
*
|
|
1033
|
+
* Initialize Ruby2D::Ext audio bindings.
|
|
635
1034
|
*/
|
|
636
|
-
void
|
|
1035
|
+
void R2D_Audio_Init(void);
|
|
637
1036
|
|
|
638
|
-
|
|
1037
|
+
|
|
1038
|
+
// Window //////////////////////////////////////////////////////////////////////
|
|
639
1039
|
|
|
640
1040
|
/*
|
|
641
|
-
*
|
|
1041
|
+
* Initialize Ruby2D::Window native bindings
|
|
642
1042
|
*/
|
|
643
|
-
void
|
|
1043
|
+
void R2D_Window_Init(void);
|
|
644
1044
|
|
|
645
1045
|
/*
|
|
646
|
-
*
|
|
1046
|
+
* Apply viewport scaling mode via SDL3 logical presentation
|
|
647
1047
|
*/
|
|
648
|
-
void
|
|
1048
|
+
void R2D_ApplyViewportMode(R2D_Window *window);
|
|
649
1049
|
|
|
650
1050
|
/*
|
|
651
|
-
*
|
|
1051
|
+
* Set the icon for the window
|
|
652
1052
|
*/
|
|
653
|
-
|
|
1053
|
+
void R2D_SetIcon(R2D_Window *window, const char *icon);
|
|
654
1054
|
|
|
655
1055
|
/*
|
|
656
|
-
*
|
|
1056
|
+
* Take a screenshot of the window
|
|
657
1057
|
*/
|
|
658
|
-
void
|
|
659
|
-
|
|
660
|
-
// Window //////////////////////////////////////////////////////////////////////
|
|
1058
|
+
void R2D_Screenshot(R2D_Window *window, const char *path);
|
|
661
1059
|
|
|
662
1060
|
/*
|
|
663
|
-
*
|
|
1061
|
+
* Show the cursor over the window
|
|
664
1062
|
*/
|
|
665
|
-
|
|
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
|
-
*
|
|
1066
|
+
* Hide the cursor over the window
|
|
671
1067
|
*/
|
|
672
|
-
|
|
1068
|
+
void R2D_HideCursor(void);
|
|
673
1069
|
|
|
674
1070
|
/*
|
|
675
|
-
*
|
|
1071
|
+
* Check if the cursor is visible
|
|
676
1072
|
*/
|
|
677
|
-
|
|
1073
|
+
bool R2D_CursorVisible(void);
|
|
678
1074
|
|
|
679
1075
|
/*
|
|
680
|
-
*
|
|
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
|
-
|
|
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
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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
|
}
|