ruby2d 0.10.0 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/include/SDL2/SDL.h +108 -14
- data/assets/include/SDL2/SDL_assert.h +81 -50
- data/assets/include/SDL2/SDL_atomic.h +135 -35
- data/assets/include/SDL2/SDL_audio.h +960 -355
- data/assets/include/SDL2/SDL_bits.h +11 -6
- data/assets/include/SDL2/SDL_blendmode.h +91 -14
- data/assets/include/SDL2/SDL_clipboard.h +30 -7
- data/assets/include/SDL2/SDL_config.h +3 -1
- data/assets/include/SDL2/SDL_config_android.h +11 -1
- data/assets/include/SDL2/SDL_config_emscripten.h +216 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +9 -1
- data/assets/include/SDL2/SDL_config_macosx.h +16 -2
- data/assets/include/SDL2/SDL_config_minimal.h +4 -1
- data/assets/include/SDL2/SDL_config_os2.h +37 -20
- data/assets/include/SDL2/SDL_config_pandora.h +6 -1
- data/assets/include/SDL2/SDL_config_psp.h +8 -8
- data/assets/include/SDL2/SDL_config_windows.h +39 -22
- data/assets/include/SDL2/SDL_config_winrt.h +23 -8
- data/assets/include/SDL2/SDL_config_wiz.h +6 -1
- data/assets/include/SDL2/SDL_copying.h +1 -1
- data/assets/include/SDL2/SDL_cpuinfo.h +331 -71
- data/assets/include/SDL2/SDL_egl.h +906 -280
- data/assets/include/SDL2/SDL_endian.h +101 -47
- data/assets/include/SDL2/SDL_error.h +70 -19
- data/assets/include/SDL2/SDL_events.h +387 -79
- data/assets/include/SDL2/SDL_filesystem.h +73 -64
- data/assets/include/SDL2/SDL_gamecontroller.h +585 -125
- data/assets/include/SDL2/SDL_gesture.h +36 -6
- data/assets/include/SDL2/SDL_haptic.h +304 -210
- data/assets/include/SDL2/SDL_hidapi.h +451 -0
- data/assets/include/SDL2/SDL_hints.h +1286 -897
- data/assets/include/SDL2/SDL_joystick.h +577 -130
- data/assets/include/SDL2/SDL_keyboard.h +162 -63
- data/assets/include/SDL2/SDL_keycode.h +7 -5
- data/assets/include/SDL2/SDL_loadso.h +42 -8
- data/assets/include/SDL2/SDL_locale.h +34 -32
- data/assets/include/SDL2/SDL_log.h +212 -19
- data/assets/include/SDL2/SDL_main.h +72 -17
- data/assets/include/SDL2/SDL_messagebox.h +70 -23
- data/assets/include/SDL2/SDL_metal.h +27 -32
- data/assets/include/SDL2/SDL_misc.h +19 -15
- data/assets/include/SDL2/SDL_mouse.h +262 -110
- data/assets/include/SDL2/SDL_mutex.h +286 -66
- data/assets/include/SDL2/SDL_name.h +1 -1
- data/assets/include/SDL2/SDL_opengl.h +1 -1
- data/assets/include/SDL2/SDL_opengles.h +1 -1
- data/assets/include/SDL2/SDL_opengles2.h +2 -2
- data/assets/include/SDL2/SDL_pixels.h +199 -34
- data/assets/include/SDL2/SDL_platform.h +39 -2
- data/assets/include/SDL2/SDL_power.h +23 -10
- data/assets/include/SDL2/SDL_quit.h +1 -1
- data/assets/include/SDL2/SDL_rect.h +78 -28
- data/assets/include/SDL2/SDL_render.h +1204 -472
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +605 -33
- data/assets/include/SDL2/SDL_scancode.h +1 -1
- data/assets/include/SDL2/SDL_sensor.h +76 -42
- data/assets/include/SDL2/SDL_shape.h +38 -27
- data/assets/include/SDL2/SDL_stdinc.h +96 -24
- data/assets/include/SDL2/SDL_surface.h +571 -139
- data/assets/include/SDL2/SDL_system.h +339 -101
- data/assets/include/SDL2/SDL_syswm.h +50 -20
- data/assets/include/SDL2/SDL_test.h +1 -1
- data/assets/include/SDL2/SDL_test_assert.h +2 -2
- data/assets/include/SDL2/SDL_test_common.h +23 -6
- data/assets/include/SDL2/SDL_test_compare.h +1 -1
- data/assets/include/SDL2/SDL_test_crc32.h +1 -1
- data/assets/include/SDL2/SDL_test_font.h +3 -3
- data/assets/include/SDL2/SDL_test_fuzzer.h +28 -26
- data/assets/include/SDL2/SDL_test_harness.h +6 -6
- data/assets/include/SDL2/SDL_test_images.h +1 -1
- data/assets/include/SDL2/SDL_test_log.h +1 -1
- data/assets/include/SDL2/SDL_test_md5.h +1 -1
- data/assets/include/SDL2/SDL_test_memory.h +1 -1
- data/assets/include/SDL2/SDL_test_random.h +2 -2
- data/assets/include/SDL2/SDL_thread.h +226 -128
- data/assets/include/SDL2/SDL_timer.h +129 -22
- data/assets/include/SDL2/SDL_touch.h +48 -8
- data/assets/include/SDL2/SDL_ttf.h +102 -9
- data/assets/include/SDL2/SDL_types.h +1 -1
- data/assets/include/SDL2/SDL_version.h +72 -46
- data/assets/include/SDL2/SDL_video.h +1266 -460
- data/assets/include/SDL2/SDL_vulkan.h +100 -161
- data/assets/include/SDL2/begin_code.h +22 -1
- data/assets/include/SDL2/close_code.h +1 -1
- data/assets/include/mrbconf.h +234 -0
- data/assets/include/mruby/array.h +317 -0
- data/assets/include/mruby/boxing_nan.h +130 -0
- data/assets/include/mruby/boxing_no.h +58 -0
- data/assets/include/mruby/boxing_word.h +205 -0
- data/assets/include/mruby/class.h +108 -0
- data/assets/include/mruby/common.h +92 -0
- data/assets/include/mruby/compile.h +210 -0
- data/assets/include/mruby/data.h +76 -0
- data/assets/include/mruby/debug.h +66 -0
- data/assets/include/mruby/dump.h +158 -0
- data/assets/include/mruby/endian.h +44 -0
- data/assets/include/mruby/error.h +137 -0
- data/assets/include/mruby/gc.h +92 -0
- data/assets/include/mruby/hash.h +242 -0
- data/assets/include/mruby/irep.h +147 -0
- data/assets/include/mruby/istruct.h +50 -0
- data/assets/include/mruby/khash.h +284 -0
- data/assets/include/mruby/numeric.h +169 -0
- data/assets/include/mruby/object.h +43 -0
- data/assets/include/mruby/opcode.h +43 -0
- data/assets/include/mruby/ops.h +122 -0
- data/assets/include/mruby/presym/disable.h +70 -0
- data/assets/include/mruby/presym/enable.h +37 -0
- data/assets/include/mruby/presym/scanning.h +73 -0
- data/assets/include/mruby/presym.h +40 -0
- data/assets/include/mruby/proc.h +209 -0
- data/assets/include/mruby/range.h +79 -0
- data/assets/include/mruby/re.h +16 -0
- data/assets/include/mruby/string.h +469 -0
- data/assets/include/mruby/throw.h +66 -0
- data/assets/include/mruby/value.h +400 -0
- data/assets/include/mruby/variable.h +140 -0
- data/assets/include/mruby/version.h +143 -0
- data/assets/include/mruby.h +1444 -0
- 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/{lib → universal/lib}/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libSDL2_ttf.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/libjpeg.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/{lib → universal/lib}/libmpg123.a +0 -0
- data/assets/{mingw/lib/libSDL2.a → macos/universal/lib/libmruby.a} +0 -0
- data/assets/macos/{lib → universal/lib}/libogg.a +0 -0
- data/assets/macos/universal/lib/libpng16.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/test_media/README.md +3 -0
- data/assets/test_media/bitstream_vera/COPYRIGHT.txt +124 -0
- 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/build_config.rb +13 -0
- data/assets/wasm/libmruby.a +0 -0
- data/assets/wasm/template.html +17 -0
- data/assets/windows/glew/README.md +10 -0
- data/assets/windows/glew/glew.h +23686 -0
- data/assets/{mingw/lib → windows/glew}/libglew32.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/libjbig.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjpeg.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/libpng16.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 -0
- 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/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
- data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
- data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
- data/assets/{ios → xcode/ios}/Info.plist +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
- data/assets/{ios → xcode/ios}/main.c +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
- data/assets/{tvos → xcode/tvos}/main.c +0 -0
- data/bin/ruby2d +3 -4
- data/ext/ruby2d/extconf.rb +68 -46
- data/ext/ruby2d/font.c +35 -0
- data/ext/ruby2d/gl.c +9 -58
- data/ext/ruby2d/gl2.c +8 -83
- data/ext/ruby2d/gl3.c +57 -116
- data/ext/ruby2d/gles.c +130 -151
- data/ext/ruby2d/image.c +16 -96
- data/ext/ruby2d/ruby2d.c +265 -298
- data/ext/ruby2d/ruby2d.h +69 -159
- data/ext/ruby2d/sound.c +1 -1
- data/ext/ruby2d/text.c +20 -114
- data/ext/ruby2d/window.c +257 -219
- data/lib/ruby2d/circle.rb +3 -1
- data/lib/ruby2d/cli/build.rb +239 -59
- data/lib/ruby2d/cli/colorize.rb +5 -4
- data/lib/ruby2d/cli/platform.rb +17 -0
- data/lib/ruby2d/font.rb +26 -1
- data/lib/ruby2d/image.rb +22 -17
- data/lib/ruby2d/line.rb +3 -1
- data/lib/ruby2d/quad.rb +3 -1
- data/lib/ruby2d/rectangle.rb +1 -1
- data/lib/ruby2d/renderable.rb +0 -12
- data/lib/ruby2d/sound.rb +25 -0
- data/lib/ruby2d/sprite.rb +44 -89
- data/lib/ruby2d/square.rb +1 -1
- data/lib/ruby2d/text.rb +40 -20
- data/lib/ruby2d/texture.rb +28 -0
- data/lib/ruby2d/tileset.rb +47 -28
- data/lib/ruby2d/triangle.rb +3 -1
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/vertices.rb +89 -0
- data/lib/ruby2d/window.rb +13 -3
- data/lib/ruby2d.rb +16 -20
- metadata +249 -153
- data/assets/README.md +0 -22
- data/assets/Rakefile +0 -85
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/SDL2_mixer.dll +0 -0
- data/assets/mingw/bin/SDL2_ttf.dll +0 -0
- data/assets/mingw/bin/glew32.dll +0 -0
- data/assets/mingw/bin/libFLAC-8.dll +0 -0
- data/assets/mingw/bin/libfreetype-6.dll +0 -0
- data/assets/mingw/bin/libjpeg-9.dll +0 -0
- data/assets/mingw/bin/libmodplug-1.dll +0 -0
- data/assets/mingw/bin/libmpg123-0.dll +0 -0
- data/assets/mingw/bin/libogg-0.dll +0 -0
- data/assets/mingw/bin/libopus-0.dll +0 -0
- data/assets/mingw/bin/libopusfile-0.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libvorbis-0.dll +0 -0
- data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/bin/zlib1.dll +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/assets/mingw/lib/libglew32.dll.a +0 -0
- data/ext/ruby2d/sprite.c +0 -147
- data/ext/ruby2d/tileset.c +0 -30
data/lib/ruby2d/cli/build.rb
CHANGED
@@ -1,58 +1,45 @@
|
|
1
|
-
# Build a Ruby 2D app
|
1
|
+
# Build a compiled Ruby 2D app with mruby
|
2
2
|
|
3
|
+
require 'ruby2d'
|
3
4
|
require 'fileutils'
|
5
|
+
require 'ruby2d/cli/colorize'
|
6
|
+
require 'ruby2d/cli/platform'
|
4
7
|
|
5
|
-
# The installed gem directory
|
6
|
-
@gem_dir = "#{Gem::Specification.find_by_name('ruby2d').gem_dir}"
|
7
8
|
|
8
9
|
# The Ruby 2D library files
|
9
|
-
@
|
10
|
+
@ruby2d_lib_files = [
|
10
11
|
'cli/colorize',
|
11
12
|
'exceptions',
|
12
13
|
'renderable',
|
13
14
|
'color',
|
14
15
|
'window',
|
15
16
|
'dsl',
|
17
|
+
'entity',
|
16
18
|
'quad',
|
17
19
|
'line',
|
18
20
|
'circle',
|
19
21
|
'rectangle',
|
20
22
|
'square',
|
21
23
|
'triangle',
|
24
|
+
'pixel',
|
22
25
|
'image',
|
23
26
|
'sprite',
|
27
|
+
'tileset',
|
24
28
|
'font',
|
25
29
|
'text',
|
26
30
|
'sound',
|
27
31
|
'music',
|
32
|
+
'texture',
|
33
|
+
'vertices',
|
28
34
|
'../ruby2d'
|
29
35
|
]
|
30
36
|
|
31
37
|
|
32
|
-
#
|
33
|
-
def check_build_src_file(rb_file)
|
34
|
-
if !rb_file
|
35
|
-
puts "Please provide a Ruby file to build"
|
36
|
-
exit
|
37
|
-
elsif !File.exist? rb_file
|
38
|
-
puts "Can't find file: #{rb_file}"
|
39
|
-
exit
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# Assemble the Ruby 2D library in one `.rb` file
|
45
|
-
def make_lib
|
46
|
-
FileUtils.mkdir_p 'build'
|
47
|
-
|
48
|
-
lib_dir = "#{@gem_dir}/lib/ruby2d/"
|
49
|
-
|
50
|
-
lib = ''
|
51
|
-
@lib_files.each do |f|
|
52
|
-
lib << File.read("#{lib_dir + f}.rb") + "\n\n"
|
53
|
-
end
|
38
|
+
# Helpers ######################################################################
|
54
39
|
|
55
|
-
|
40
|
+
def run_cmd(cmd)
|
41
|
+
puts "#{'$'.info} #{cmd.bold}\n" if @debug
|
42
|
+
system cmd
|
56
43
|
end
|
57
44
|
|
58
45
|
|
@@ -66,57 +53,251 @@ def strip_require(file)
|
|
66
53
|
end
|
67
54
|
|
68
55
|
|
69
|
-
#
|
70
|
-
def
|
71
|
-
|
56
|
+
# Add linker flags
|
57
|
+
def add_ld_flags(ld_flags, name, type, dir = nil)
|
58
|
+
case type
|
59
|
+
when :archive
|
60
|
+
ld_flags << "#{dir}/lib#{name}.a "
|
61
|
+
when :framework
|
62
|
+
ld_flags << "-Wl,-framework,#{name} "
|
63
|
+
end
|
64
|
+
end
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
66
|
+
|
67
|
+
# Build Tasks ##################################################################
|
68
|
+
|
69
|
+
# Build the user's application
|
70
|
+
def build(target, ruby2d_app)
|
71
|
+
|
72
|
+
# Check if source file provided is good
|
73
|
+
if !ruby2d_app
|
74
|
+
puts "Please provide a Ruby file to build"
|
75
|
+
exit
|
76
|
+
elsif !File.exist? ruby2d_app
|
77
|
+
puts "Can't find file: #{ruby2d_app}"
|
76
78
|
exit
|
77
79
|
end
|
78
80
|
|
79
81
|
# Add debugging information to produce backtrace
|
80
82
|
if @debug then debug_flag = '-g' end
|
81
83
|
|
82
|
-
#
|
83
|
-
|
84
|
-
`mrbc #{debug_flag} -Bruby2d_lib -obuild/lib.c build/lib.rb`
|
84
|
+
# Create build directory
|
85
|
+
FileUtils.mkdir_p 'build'
|
85
86
|
|
86
|
-
#
|
87
|
-
|
88
|
-
|
87
|
+
# Assemble Ruby 2D library files into one '.rb' file
|
88
|
+
|
89
|
+
ruby2d_lib_dir = "#{Ruby2D.gem_dir}/lib/ruby2d/"
|
90
|
+
|
91
|
+
ruby2d_lib = ''
|
92
|
+
@ruby2d_lib_files.each do |f|
|
93
|
+
ruby2d_lib << File.read("#{ruby2d_lib_dir + f}.rb") + "\n\n"
|
94
|
+
end
|
95
|
+
|
96
|
+
File.write('build/ruby2d_lib.rb', ruby2d_lib)
|
97
|
+
|
98
|
+
# Assemble the Ruby 2D C extension files into one '.c' file
|
99
|
+
|
100
|
+
ruby2d_ext_dir = "#{Ruby2D.gem_dir}/ext/ruby2d/"
|
101
|
+
|
102
|
+
ruby2d_ext = "#define MRUBY 1" << "\n\n"
|
103
|
+
Dir["#{ruby2d_ext_dir}*.c"].each do |c_file|
|
104
|
+
ruby2d_ext << File.read(c_file)
|
105
|
+
end
|
106
|
+
|
107
|
+
File.write('build/ruby2d_ext.c', ruby2d_ext)
|
108
|
+
|
109
|
+
# Select `mrbc` executable based on platform
|
110
|
+
case $RUBY2D_PLATFORM
|
111
|
+
when :macos
|
112
|
+
mrbc = "#{Ruby2D.assets}/macos/universal/bin/mrbc"
|
113
|
+
when :windows
|
114
|
+
mrbc = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/bin/mrbc.exe"
|
115
|
+
else
|
116
|
+
mrbc = 'mrbc'
|
117
|
+
end
|
118
|
+
|
119
|
+
# Compile the Ruby 2D lib (`.rb` files) to mruby bytecode
|
120
|
+
run_cmd "#{mrbc} #{debug_flag} -Bruby2d_lib -obuild/ruby2d_lib.c build/ruby2d_lib.rb"
|
121
|
+
|
122
|
+
# Read the user's provided Ruby source file, copy to build dir and compile to bytecode
|
123
|
+
File.open('build/ruby2d_app.rb', 'w') { |f| f << strip_require(ruby2d_app) }
|
124
|
+
run_cmd "#{mrbc} #{debug_flag} -Bruby2d_app -obuild/ruby2d_app.c build/ruby2d_app.rb"
|
89
125
|
|
90
126
|
# Combine contents of C source files and bytecode into one file
|
91
127
|
open('build/app.c', 'w') do |f|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
f << File.read("#{@gem_dir}/ext/ruby2d/ruby2d.c")
|
128
|
+
['ruby2d_app', 'ruby2d_lib', 'ruby2d_ext'].each do |c_file|
|
129
|
+
f << File.read("build/#{c_file}.c") << "\n\n"
|
130
|
+
end
|
96
131
|
end
|
97
132
|
|
98
|
-
# Compile
|
99
|
-
|
133
|
+
# Compile the final application based on the target platform
|
134
|
+
case target
|
135
|
+
when :native
|
136
|
+
compile_native
|
137
|
+
when :web
|
138
|
+
compile_web
|
139
|
+
end
|
100
140
|
|
101
|
-
#
|
141
|
+
# Remove files used in the build process
|
102
142
|
clean_up unless @debug
|
103
143
|
|
104
|
-
# Success!
|
105
|
-
puts "Native app created at `build/app`"
|
106
144
|
end
|
107
145
|
|
108
146
|
|
109
|
-
#
|
110
|
-
def
|
111
|
-
|
147
|
+
# Create a native executable using the available C compiler
|
148
|
+
def compile_native
|
149
|
+
|
150
|
+
# Get include directories
|
151
|
+
incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
|
152
|
+
incl_dir_deps = "#{Ruby2D.assets}/include/"
|
153
|
+
|
154
|
+
# Add compiler flags for each platform
|
155
|
+
case $RUBY2D_PLATFORM
|
156
|
+
|
157
|
+
when :macos
|
158
|
+
ld_dir = "#{Ruby2D.assets}/macos/universal/lib"
|
159
|
+
|
160
|
+
c_flags = '-arch arm64 -arch x86_64'
|
161
|
+
|
162
|
+
ld_flags = ''
|
163
|
+
['mruby', 'SDL2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf',
|
164
|
+
'jpeg', 'png16', 'tiff', 'webp',
|
165
|
+
'mpg123', 'ogg', 'FLAC', 'vorbis', 'vorbisfile', 'modplug',
|
166
|
+
'freetype', 'harfbuzz', 'graphite2'].each do |name|
|
167
|
+
add_ld_flags(ld_flags, name, :archive, ld_dir)
|
168
|
+
end
|
169
|
+
|
170
|
+
ld_flags << "-lz -lbz2 -liconv -lstdc++ "
|
171
|
+
['Cocoa', 'Carbon', 'CoreVideo', 'OpenGL', 'Metal', 'CoreAudio', 'AudioToolbox',
|
172
|
+
'IOKit', 'GameController', 'ForceFeedback', 'CoreHaptics'].each do |name|
|
173
|
+
add_ld_flags(ld_flags, name, :framework)
|
174
|
+
end
|
175
|
+
|
176
|
+
when :linux, :linux_rpi, :bsd
|
177
|
+
# TODO: implement this
|
178
|
+
# ld_flags = '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm -lGL'
|
179
|
+
|
180
|
+
when :windows
|
181
|
+
ld_dir = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/lib"
|
182
|
+
|
183
|
+
ld_flags = '-static -Wl,--start-group '
|
184
|
+
['mruby',
|
185
|
+
'SDL2',
|
186
|
+
'SDL2_image', 'jpeg', 'png16', 'tiff', 'webp', 'jbig', 'deflate', 'lzma', 'zstd', 'Lerc',
|
187
|
+
'SDL2_mixer', 'mpg123', 'FLAC', 'vorbis', 'vorbisfile', 'ogg', 'modplug', 'opus', 'opusfile', 'sndfile',
|
188
|
+
'SDL2_ttf', 'freetype', 'harfbuzz', 'graphite2', 'bz2', 'brotlicommon', 'brotlidec',
|
189
|
+
'glew32', 'stdc++', 'z', 'ssp'
|
190
|
+
].each do |name|
|
191
|
+
add_ld_flags(ld_flags, name, :archive, ld_dir)
|
192
|
+
end
|
193
|
+
ld_flags << '-lmingw32 -lopengl32 -lole32 -loleaut32 -limm32 -lversion -lwinmm -lrpcrt4 -mwindows -lsetupapi -ldwrite '\
|
194
|
+
'-lws2_32 -lshlwapi '
|
195
|
+
ld_flags << '-Wl,--end-group'
|
196
|
+
end
|
197
|
+
|
198
|
+
# Compile the app
|
199
|
+
run_cmd "cc #{c_flags} -I#{incl_dir_ruby2d} -I#{incl_dir_deps} build/app.c #{ld_flags} -o build/app"
|
200
|
+
|
201
|
+
create_macos_bundle if $RUBY2D_PLATFORM == :macos
|
112
202
|
end
|
113
203
|
|
114
204
|
|
115
|
-
#
|
116
|
-
def
|
205
|
+
# Create a WebAssembly executable using Emscripten
|
206
|
+
def compile_web
|
207
|
+
|
208
|
+
# Check for compiler toolchain issues
|
209
|
+
if doctor_web(:building)
|
210
|
+
puts "Fix errors before building.\n\n"
|
211
|
+
end
|
212
|
+
|
213
|
+
wasm_assets = "#{Ruby2D.assets}/wasm"
|
214
|
+
|
215
|
+
# Get include directories
|
216
|
+
incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
|
217
|
+
incl_dir_deps = "#{Ruby2D.assets}/include/"
|
218
|
+
|
219
|
+
optimize_flags = '-Os --closure 1'
|
220
|
+
ld_flags = "#{wasm_assets}/libmruby.a"
|
221
|
+
|
222
|
+
# Compile using Emscripten
|
223
|
+
run_cmd "emcc -s WASM=1 -I#{incl_dir_ruby2d} -I#{incl_dir_deps} "\
|
224
|
+
"-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 "\
|
225
|
+
"build/app.c #{ld_flags} -o build/app.html"
|
226
|
+
|
227
|
+
# TODO: Copy HTML template from gem assets to build directory
|
228
|
+
# FileUtils.cp "#{wasm_assets}/template.html", 'build/app.html'
|
229
|
+
|
230
|
+
exit(1) unless $?.success?
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
def doctor_native
|
235
|
+
# Check if MRuby exists; if not, quit
|
236
|
+
if `which mruby`.empty?
|
237
|
+
puts "#{'Error:'.error} Can't find `mruby`, which is needed to build native Ruby 2D applications.\n"
|
238
|
+
exit
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
# Check for problems with web build
|
244
|
+
def doctor_web(mode = nil)
|
245
|
+
|
246
|
+
errors = false
|
247
|
+
mruby_errors = false
|
248
|
+
emscripten_errors = false
|
249
|
+
|
250
|
+
puts "\nChecking for mruby"
|
251
|
+
|
252
|
+
# Check for `mrbc`
|
253
|
+
print ' mrbc...'
|
254
|
+
if `which mrbc`.empty?
|
255
|
+
puts 'not found'.error
|
256
|
+
mruby_errors = true
|
257
|
+
else
|
258
|
+
puts 'found'.success
|
259
|
+
end
|
117
260
|
|
118
|
-
|
119
|
-
|
261
|
+
puts "\nChecking for Emscripten tools"
|
262
|
+
|
263
|
+
# Check for `emcc`
|
264
|
+
print ' emcc...'
|
265
|
+
if `which emcc`.empty?
|
266
|
+
puts 'not found'.error
|
267
|
+
emscripten_errors = true
|
268
|
+
else
|
269
|
+
puts 'found'.success
|
270
|
+
end
|
271
|
+
|
272
|
+
# Check for `emar`
|
273
|
+
print ' emar...'
|
274
|
+
if `which emar`.empty?
|
275
|
+
puts 'not found'.error
|
276
|
+
emscripten_errors = true
|
277
|
+
else
|
278
|
+
puts 'found'.success
|
279
|
+
end
|
280
|
+
|
281
|
+
if mruby_errors || emscripten_errors then errors = true end
|
282
|
+
|
283
|
+
if errors
|
284
|
+
puts "\nErrors were found!\n\n"
|
285
|
+
if mruby_errors
|
286
|
+
puts "* Did you install mruby?"
|
287
|
+
end
|
288
|
+
if emscripten_errors
|
289
|
+
puts "* Did you run \`./emsdk_env.sh\` ?", " For help, check out the \"Getting Started\" guide on webassembly.org"
|
290
|
+
end
|
291
|
+
puts "\n"
|
292
|
+
exit(1)
|
293
|
+
else
|
294
|
+
puts "\n👍 Everything looks good!\n\n"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
|
299
|
+
# Build an app bundle for macOS
|
300
|
+
def create_macos_bundle
|
120
301
|
|
121
302
|
# Property list source for the bundle
|
122
303
|
info_plist = %(
|
@@ -151,10 +332,10 @@ def build_macos(rb_file)
|
|
151
332
|
# FileUtils.cp "#{@gem_dir}/assets/app.icns", 'build/App.app/Contents/Resources'
|
152
333
|
|
153
334
|
# Clean up
|
154
|
-
FileUtils.rm_f 'build/app' unless @debug
|
335
|
+
# FileUtils.rm_f 'build/app' unless @debug
|
155
336
|
|
156
337
|
# Success!
|
157
|
-
puts 'macOS app bundle created: `build/App.app`'
|
338
|
+
# puts 'macOS app bundle created: `build/App.app`'
|
158
339
|
end
|
159
340
|
|
160
341
|
|
@@ -206,8 +387,7 @@ end
|
|
206
387
|
# Clean up unneeded build files
|
207
388
|
def clean_up(cmd = nil)
|
208
389
|
FileUtils.rm(
|
209
|
-
Dir.glob('build
|
210
|
-
Dir.glob('build/app.c')
|
390
|
+
Dir.glob('build/*.{rb,c,js}')
|
211
391
|
)
|
212
392
|
if cmd == :all
|
213
393
|
puts "cleaning up..."
|
data/lib/ruby2d/cli/colorize.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
# Extend `String` to include some fancy colors
|
4
4
|
class String
|
5
5
|
def ruby2d_colorize(c); "\e[#{c}m#{self}\e[0m" end
|
6
|
-
def bold;
|
7
|
-
def info;
|
8
|
-
def warn;
|
9
|
-
def
|
6
|
+
def bold; ruby2d_colorize('1') end
|
7
|
+
def info; ruby2d_colorize('1;34') end
|
8
|
+
def warn; ruby2d_colorize('1;33') end
|
9
|
+
def success; ruby2d_colorize('1;32') end
|
10
|
+
def error; ruby2d_colorize('1;31') end
|
10
11
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Set the OS and platform
|
2
|
+
|
3
|
+
case RUBY_PLATFORM
|
4
|
+
when /darwin/
|
5
|
+
$RUBY2D_PLATFORM = :macos
|
6
|
+
when /linux/
|
7
|
+
$RUBY2D_PLATFORM = :linux
|
8
|
+
if `cat /etc/os-release` =~ /raspbian/
|
9
|
+
$RUBY2D_PLATFORM = :linux_rpi
|
10
|
+
end
|
11
|
+
when /bsd/
|
12
|
+
$RUBY2D_PLATFORM = :bsd
|
13
|
+
when /mingw/
|
14
|
+
$RUBY2D_PLATFORM = :windows
|
15
|
+
else
|
16
|
+
$RUBY2D_PLATFORM = nil
|
17
|
+
end
|
data/lib/ruby2d/font.rb
CHANGED
@@ -2,8 +2,28 @@
|
|
2
2
|
|
3
3
|
module Ruby2D
|
4
4
|
class Font
|
5
|
+
FONT_CACHE_LIMIT = 100
|
6
|
+
|
7
|
+
@@loaded_fonts = {}
|
8
|
+
|
9
|
+
attr_reader :ttf_font
|
10
|
+
|
11
|
+
def initialize(path, size, style=nil)
|
12
|
+
@ttf_font = Font.ext_load(path, size, style.to_s)
|
13
|
+
end
|
5
14
|
|
6
15
|
class << self
|
16
|
+
def load(path, size, style=nil)
|
17
|
+
unless File.exist? path
|
18
|
+
raise Error, "Cannot find font file `#{path}`"
|
19
|
+
end
|
20
|
+
|
21
|
+
(@@loaded_fonts[[path, size, style]] ||= Font.new(path, size, style)).tap do |font|
|
22
|
+
if @@loaded_fonts.size > FONT_CACHE_LIMIT
|
23
|
+
@@loaded_fonts.shift
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
7
27
|
|
8
28
|
# List all fonts, names only
|
9
29
|
def all
|
@@ -50,6 +70,7 @@ module Ruby2D
|
|
50
70
|
macos_font_path = '/Library/Fonts'
|
51
71
|
linux_font_path = '/usr/share/fonts'
|
52
72
|
windows_font_path = 'C:/Windows/Fonts'
|
73
|
+
openbsd_font_path = '/usr/X11R6/lib/X11/fonts'
|
53
74
|
|
54
75
|
# If MRI and/or non-Bash shell (like cmd.exe)
|
55
76
|
if Object.const_defined? :RUBY_PLATFORM
|
@@ -60,16 +81,20 @@ module Ruby2D
|
|
60
81
|
linux_font_path
|
61
82
|
when /mingw/
|
62
83
|
windows_font_path
|
84
|
+
when /openbsd/
|
85
|
+
openbsd_font_path
|
63
86
|
end
|
64
87
|
# If MRuby
|
65
88
|
else
|
66
89
|
uname = `uname`
|
67
|
-
if uname.include? 'Darwin'
|
90
|
+
if uname.include? 'Darwin' # macOS
|
68
91
|
macos_font_path
|
69
92
|
elsif uname.include? 'Linux'
|
70
93
|
linux_font_path
|
71
94
|
elsif uname.include? 'MINGW'
|
72
95
|
windows_font_path
|
96
|
+
elsif uname.include? 'OpenBSD'
|
97
|
+
openbsd_font_path
|
73
98
|
end
|
74
99
|
end
|
75
100
|
end
|
data/lib/ruby2d/image.rb
CHANGED
@@ -7,26 +7,34 @@ module Ruby2D
|
|
7
7
|
attr_reader :path
|
8
8
|
attr_accessor :x, :y, :width, :height, :rotate, :data
|
9
9
|
|
10
|
-
def
|
10
|
+
def self.load_image(path)
|
11
11
|
unless File.exist? path
|
12
12
|
raise Error, "Cannot find image file `#{path}`"
|
13
13
|
end
|
14
|
+
|
15
|
+
ext_load_image(path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(path, opts = {})
|
14
19
|
@path = path
|
20
|
+
|
21
|
+
@texture = Texture.new(*Image.load_image(@path))
|
22
|
+
@width = opts[:width] || @texture.width
|
23
|
+
@height = opts[:height] || @texture.height
|
24
|
+
|
15
25
|
@x = opts[:x] || 0
|
16
26
|
@y = opts[:y] || 0
|
17
27
|
@z = opts[:z] || 0
|
18
|
-
@width = opts[:width] || nil
|
19
|
-
@height = opts[:height] || nil
|
20
28
|
@rotate = opts[:rotate] || 0
|
21
29
|
self.color = opts[:color] || 'white'
|
22
|
-
self.opacity = opts[:opacity] if opts[:opacity]
|
23
|
-
|
24
|
-
raise Error, "Image `#{@path}` cannot be created"
|
25
|
-
end
|
30
|
+
self.color.opacity = opts[:opacity] if opts[:opacity]
|
31
|
+
|
26
32
|
unless opts[:show] == false then add end
|
27
33
|
end
|
28
34
|
|
29
35
|
def draw(opts = {})
|
36
|
+
Window.render_ready_check
|
37
|
+
|
30
38
|
opts[:width] = opts[:width] || @width
|
31
39
|
opts[:height] = opts[:height] || @height
|
32
40
|
opts[:rotate] = opts[:rotate] || @rotate
|
@@ -34,20 +42,17 @@ module Ruby2D
|
|
34
42
|
opts[:color] = [1.0, 1.0, 1.0, 1.0]
|
35
43
|
end
|
36
44
|
|
37
|
-
|
38
|
-
self, opts[:x], opts[:y], opts[:width], opts[:height], opts[:rotate],
|
39
|
-
opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]
|
40
|
-
])
|
45
|
+
render(x: opts[:x], y: opts[:y], width: opts[:width], height: opts[:height], color: Color.new(opts[:color]), rotate: opts[:rotate])
|
41
46
|
end
|
42
47
|
|
43
48
|
private
|
44
49
|
|
45
|
-
def render
|
46
|
-
|
47
|
-
self, @x, @y, @width, @height, @rotate,
|
48
|
-
@color.r, @color.g, @color.b, @color.a
|
49
|
-
])
|
50
|
-
end
|
50
|
+
def render(x: @x, y: @y, width: @width, height: @height, color: @color, rotate: @rotate)
|
51
|
+
vertices = Vertices.new(x, y, width, height, rotate)
|
51
52
|
|
53
|
+
@texture.draw(
|
54
|
+
vertices.coordinates, vertices.texture_coordinates, color
|
55
|
+
)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
end
|
data/lib/ruby2d/line.rb
CHANGED
@@ -14,7 +14,7 @@ module Ruby2D
|
|
14
14
|
@z = opts[:z] || 0
|
15
15
|
@width = opts[:width] || 2
|
16
16
|
self.color = opts[:color] || 'white'
|
17
|
-
self.opacity = opts[:opacity] if opts[:opacity]
|
17
|
+
self.color.opacity = opts[:opacity] if opts[:opacity]
|
18
18
|
add
|
19
19
|
end
|
20
20
|
|
@@ -39,6 +39,8 @@ module Ruby2D
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.draw(opts = {})
|
42
|
+
Window.render_ready_check
|
43
|
+
|
42
44
|
ext_draw([
|
43
45
|
opts[:x1], opts[:y1], opts[:x2], opts[:y2], opts[:width],
|
44
46
|
opts[:color][0][0], opts[:color][0][1], opts[:color][0][2], opts[:color][0][3],
|
data/lib/ruby2d/quad.rb
CHANGED
@@ -25,7 +25,7 @@ module Ruby2D
|
|
25
25
|
@y4 = opts[:y4] || 100
|
26
26
|
@z = opts[:z] || 0
|
27
27
|
self.color = opts[:color] || 'white'
|
28
|
-
self.opacity = opts[:opacity] if opts[:opacity]
|
28
|
+
self.color.opacity = opts[:opacity] if opts[:opacity]
|
29
29
|
add
|
30
30
|
end
|
31
31
|
|
@@ -49,6 +49,8 @@ module Ruby2D
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.draw(opts = {})
|
52
|
+
Window.render_ready_check
|
53
|
+
|
52
54
|
ext_draw([
|
53
55
|
opts[:x1], opts[:y1], opts[:color][0][0], opts[:color][0][1], opts[:color][0][2], opts[:color][0][3],
|
54
56
|
opts[:x2], opts[:y2], opts[:color][1][0], opts[:color][1][1], opts[:color][1][2], opts[:color][1][3],
|
data/lib/ruby2d/rectangle.rb
CHANGED
@@ -10,7 +10,7 @@ module Ruby2D
|
|
10
10
|
@width = opts[:width] || 200
|
11
11
|
@height = opts[:height] || 100
|
12
12
|
self.color = opts[:color] || 'white'
|
13
|
-
self.opacity = opts[:opacity] if opts[:opacity]
|
13
|
+
self.color.opacity = opts[:opacity] if opts[:opacity]
|
14
14
|
update_coords(@x, @y, @width, @height)
|
15
15
|
add
|
16
16
|
end
|
data/lib/ruby2d/renderable.rb
CHANGED
@@ -31,18 +31,6 @@ module Ruby2D
|
|
31
31
|
alias_method :colour, :color
|
32
32
|
alias_method :colour=, :color=
|
33
33
|
|
34
|
-
# Allow shortcuts for setting color values
|
35
|
-
def r; self.color.r end
|
36
|
-
def g; self.color.g end
|
37
|
-
def b; self.color.b end
|
38
|
-
def a; self.color.a end
|
39
|
-
def r=(c); self.color.r = c end
|
40
|
-
def g=(c); self.color.g = c end
|
41
|
-
def b=(c); self.color.b = c end
|
42
|
-
def a=(c); self.color.a = c end
|
43
|
-
def opacity; self.color.opacity end
|
44
|
-
def opacity=(val); self.color.opacity = val end
|
45
|
-
|
46
34
|
# Add a contains method stub
|
47
35
|
def contains?(x, y)
|
48
36
|
x >= @x && x <= (@x + @width) && y >= @y && y <= (@y + @height)
|
data/lib/ruby2d/sound.rb
CHANGED
@@ -26,5 +26,30 @@ module Ruby2D
|
|
26
26
|
ext_length
|
27
27
|
end
|
28
28
|
|
29
|
+
# Get the volume of the sound
|
30
|
+
def volume
|
31
|
+
ext_get_volume
|
32
|
+
end
|
33
|
+
|
34
|
+
# Set the volume of the sound
|
35
|
+
def volume=(v)
|
36
|
+
# Clamp value to between 0-100
|
37
|
+
if v < 0 then v = 0 end
|
38
|
+
if v > 100 then v = 100 end
|
39
|
+
ext_set_volume(v)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get the volume of the sound mixer
|
43
|
+
def self.mix_volume
|
44
|
+
ext_get_mix_volume
|
45
|
+
end
|
46
|
+
|
47
|
+
# Set the volume of the sound mixer
|
48
|
+
def self.mix_volume=(v)
|
49
|
+
# Clamp value to between 0-100
|
50
|
+
if v < 0 then v = 0 end
|
51
|
+
if v > 100 then v = 100 end
|
52
|
+
ext_set_mix_volume(v)
|
53
|
+
end
|
29
54
|
end
|
30
55
|
end
|