ruby2d 0.11.1 → 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/{lib → 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 +39 -25
- data/ext/ruby2d/gl.c +1 -1
- data/ext/ruby2d/gl3.c +0 -1
- data/ext/ruby2d/gles.c +137 -84
- data/ext/ruby2d/ruby2d.c +126 -32
- data/ext/ruby2d/ruby2d.h +53 -6
- data/ext/ruby2d/text.c +14 -1
- data/ext/ruby2d/window.c +253 -215
- data/lib/ruby2d/cli/build.rb +237 -59
- data/lib/ruby2d/cli/colorize.rb +5 -4
- data/lib/ruby2d/cli/platform.rb +17 -0
- data/lib/ruby2d/font.rb +7 -1
- data/lib/ruby2d/sprite.rb +7 -2
- data/lib/ruby2d/text.rb +1 -3
- data/lib/ruby2d/texture.rb +21 -21
- data/lib/ruby2d/tileset.rb +34 -33
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/vertices.rb +11 -6
- data/lib/ruby2d.rb +14 -20
- metadata +246 -152
- 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/window.c
CHANGED
@@ -50,10 +50,249 @@ R2D_Window *R2D_CreateWindow(const char *title, int width, int height,
|
|
50
50
|
}
|
51
51
|
|
52
52
|
|
53
|
+
const Uint8 *key_state;
|
54
|
+
|
55
|
+
Uint32 frames;
|
56
|
+
Uint32 frames_last_sec;
|
57
|
+
Uint32 start_ms;
|
58
|
+
Uint32 next_second_ms;
|
59
|
+
Uint32 begin_ms;
|
60
|
+
Uint32 end_ms; // Time at end of loop
|
61
|
+
Uint32 elapsed_ms; // Total elapsed time
|
62
|
+
Uint32 loop_ms; // Elapsed time of current loop
|
63
|
+
int delay_ms; // Amount of delay to achieve desired frame rate
|
64
|
+
double decay_rate;
|
65
|
+
double fps;
|
66
|
+
|
67
|
+
R2D_Window *window;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
void main_loop() {
|
74
|
+
|
75
|
+
// Clear Frame /////////////////////////////////////////////////////////////
|
76
|
+
|
77
|
+
R2D_GL_Clear(window->background);
|
78
|
+
|
79
|
+
// Set FPS /////////////////////////////////////////////////////////////////
|
80
|
+
|
81
|
+
frames++;
|
82
|
+
frames_last_sec++;
|
83
|
+
end_ms = SDL_GetTicks();
|
84
|
+
elapsed_ms = end_ms - start_ms;
|
85
|
+
|
86
|
+
// Calculate the frame rate using an exponential moving average
|
87
|
+
if (next_second_ms < end_ms) {
|
88
|
+
fps = decay_rate * fps + (1.0 - decay_rate) * frames_last_sec;
|
89
|
+
frames_last_sec = 0;
|
90
|
+
next_second_ms = SDL_GetTicks() + 1000;
|
91
|
+
}
|
92
|
+
|
93
|
+
loop_ms = end_ms - begin_ms;
|
94
|
+
delay_ms = (1000 / window->fps_cap) - loop_ms;
|
95
|
+
|
96
|
+
if (delay_ms < 0) delay_ms = 0;
|
97
|
+
|
98
|
+
// Note: `loop_ms + delay_ms` should equal `1000 / fps_cap`
|
99
|
+
|
100
|
+
#ifndef __EMSCRIPTEN__
|
101
|
+
SDL_Delay(delay_ms);
|
102
|
+
#endif
|
103
|
+
|
104
|
+
begin_ms = SDL_GetTicks();
|
105
|
+
|
106
|
+
// Handle Input and Window Events //////////////////////////////////////////
|
107
|
+
|
108
|
+
int mx, my; // mouse x, y coordinates
|
109
|
+
|
110
|
+
SDL_Event e;
|
111
|
+
while (SDL_PollEvent(&e)) {
|
112
|
+
switch (e.type) {
|
113
|
+
|
114
|
+
case SDL_KEYDOWN:
|
115
|
+
if (window->on_key && e.key.repeat == 0) {
|
116
|
+
R2D_Event event = {
|
117
|
+
.type = R2D_KEY_DOWN, .key = SDL_GetScancodeName(e.key.keysym.scancode)
|
118
|
+
};
|
119
|
+
window->on_key(event);
|
120
|
+
}
|
121
|
+
break;
|
122
|
+
|
123
|
+
case SDL_KEYUP:
|
124
|
+
if (window->on_key) {
|
125
|
+
R2D_Event event = {
|
126
|
+
.type = R2D_KEY_UP, .key = SDL_GetScancodeName(e.key.keysym.scancode)
|
127
|
+
};
|
128
|
+
window->on_key(event);
|
129
|
+
}
|
130
|
+
break;
|
131
|
+
|
132
|
+
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP:
|
133
|
+
if (window->on_mouse) {
|
134
|
+
R2D_GetMouseOnViewport(window, e.button.x, e.button.y, &mx, &my);
|
135
|
+
R2D_Event event = {
|
136
|
+
.button = e.button.button, .x = mx, .y = my
|
137
|
+
};
|
138
|
+
event.type = e.type == SDL_MOUSEBUTTONDOWN ? R2D_MOUSE_DOWN : R2D_MOUSE_UP;
|
139
|
+
event.dblclick = e.button.clicks == 2 ? true : false;
|
140
|
+
window->on_mouse(event);
|
141
|
+
}
|
142
|
+
break;
|
143
|
+
|
144
|
+
case SDL_MOUSEWHEEL:
|
145
|
+
if (window->on_mouse) {
|
146
|
+
R2D_Event event = {
|
147
|
+
.type = R2D_MOUSE_SCROLL, .direction = e.wheel.direction,
|
148
|
+
.delta_x = e.wheel.x, .delta_y = -e.wheel.y
|
149
|
+
};
|
150
|
+
window->on_mouse(event);
|
151
|
+
}
|
152
|
+
break;
|
153
|
+
|
154
|
+
case SDL_MOUSEMOTION:
|
155
|
+
if (window->on_mouse) {
|
156
|
+
R2D_GetMouseOnViewport(window, e.motion.x, e.motion.y, &mx, &my);
|
157
|
+
R2D_Event event = {
|
158
|
+
.type = R2D_MOUSE_MOVE,
|
159
|
+
.x = mx, .y = my, .delta_x = e.motion.xrel, .delta_y = e.motion.yrel
|
160
|
+
};
|
161
|
+
window->on_mouse(event);
|
162
|
+
}
|
163
|
+
break;
|
164
|
+
|
165
|
+
case SDL_CONTROLLERAXISMOTION:
|
166
|
+
if (window->on_controller) {
|
167
|
+
R2D_Event event = {
|
168
|
+
.which = e.caxis.which, .type = R2D_AXIS,
|
169
|
+
.axis = e.caxis.axis, .value = e.caxis.value
|
170
|
+
};
|
171
|
+
window->on_controller(event);
|
172
|
+
}
|
173
|
+
break;
|
174
|
+
|
175
|
+
case SDL_JOYAXISMOTION:
|
176
|
+
if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
|
177
|
+
R2D_Event event = {
|
178
|
+
.which = e.jaxis.which, .type = R2D_AXIS,
|
179
|
+
.axis = e.jaxis.axis, .value = e.jaxis.value
|
180
|
+
};
|
181
|
+
window->on_controller(event);
|
182
|
+
}
|
183
|
+
break;
|
184
|
+
|
185
|
+
case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP:
|
186
|
+
if (window->on_controller) {
|
187
|
+
R2D_Event event = {
|
188
|
+
.which = e.cbutton.which, .button = e.cbutton.button
|
189
|
+
};
|
190
|
+
event.type = e.type == SDL_CONTROLLERBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
|
191
|
+
window->on_controller(event);
|
192
|
+
}
|
193
|
+
break;
|
194
|
+
|
195
|
+
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP:
|
196
|
+
if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
|
197
|
+
R2D_Event event = {
|
198
|
+
.which = e.jbutton.which, .button = e.jbutton.button
|
199
|
+
};
|
200
|
+
event.type = e.type == SDL_JOYBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
|
201
|
+
window->on_controller(event);
|
202
|
+
}
|
203
|
+
break;
|
204
|
+
|
205
|
+
case SDL_JOYDEVICEADDED:
|
206
|
+
R2D_Log(R2D_INFO, "Controller connected (%i total)", SDL_NumJoysticks());
|
207
|
+
R2D_OpenControllers();
|
208
|
+
break;
|
209
|
+
|
210
|
+
case SDL_JOYDEVICEREMOVED:
|
211
|
+
if (R2D_IsController(e.jdevice.which)) {
|
212
|
+
R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_GameControllerName(SDL_GameControllerFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
|
213
|
+
SDL_GameControllerClose(SDL_GameControllerFromInstanceID(e.jdevice.which));
|
214
|
+
} else {
|
215
|
+
R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_JoystickName(SDL_JoystickFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
|
216
|
+
SDL_JoystickClose(SDL_JoystickFromInstanceID(e.jdevice.which));
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
|
220
|
+
case SDL_WINDOWEVENT:
|
221
|
+
switch (e.window.event) {
|
222
|
+
case SDL_WINDOWEVENT_RESIZED:
|
223
|
+
// Store new window size, set viewport
|
224
|
+
window->width = e.window.data1;
|
225
|
+
window->height = e.window.data2;
|
226
|
+
R2D_GL_SetViewport(window);
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
break;
|
230
|
+
|
231
|
+
case SDL_QUIT:
|
232
|
+
R2D_Close(window);
|
233
|
+
break;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
// Detect keys held down
|
238
|
+
int num_keys;
|
239
|
+
key_state = SDL_GetKeyboardState(&num_keys);
|
240
|
+
|
241
|
+
for (int i = 0; i < num_keys; i++) {
|
242
|
+
if (window->on_key) {
|
243
|
+
if (key_state[i] == 1) {
|
244
|
+
R2D_Event event = {
|
245
|
+
.type = R2D_KEY_HELD, .key = SDL_GetScancodeName(i)
|
246
|
+
};
|
247
|
+
window->on_key(event);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
// Get and store mouse position relative to the viewport
|
253
|
+
int wx, wy; // mouse x, y coordinates relative to the window
|
254
|
+
SDL_GetMouseState(&wx, &wy);
|
255
|
+
R2D_GetMouseOnViewport(window, wx, wy, &window->mouse.x, &window->mouse.y);
|
256
|
+
|
257
|
+
// Update Window State /////////////////////////////////////////////////////
|
258
|
+
|
259
|
+
// Store new values in the window
|
260
|
+
window->frames = frames;
|
261
|
+
window->elapsed_ms = elapsed_ms;
|
262
|
+
window->loop_ms = loop_ms;
|
263
|
+
window->delay_ms = delay_ms;
|
264
|
+
window->fps = fps;
|
265
|
+
|
266
|
+
// Call update and render callbacks
|
267
|
+
if (window->update) window->update();
|
268
|
+
if (window->render) window->render();
|
269
|
+
|
270
|
+
// Draw Frame //////////////////////////////////////////////////////////////
|
271
|
+
|
272
|
+
// Render and flush all OpenGL buffers
|
273
|
+
R2D_GL_FlushBuffers();
|
274
|
+
|
275
|
+
// Swap buffers to display drawn contents in the window
|
276
|
+
SDL_GL_SwapWindow(window->sdl);
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
53
290
|
/*
|
54
291
|
* Show the window
|
55
292
|
*/
|
56
|
-
int R2D_Show(R2D_Window *
|
293
|
+
int R2D_Show(R2D_Window *win) {
|
294
|
+
|
295
|
+
window = win;
|
57
296
|
|
58
297
|
if (!window) {
|
59
298
|
R2D_Error("R2D_Show", "Window cannot be shown (because it's NULL)");
|
@@ -99,19 +338,14 @@ int R2D_Show(R2D_Window *window) {
|
|
99
338
|
|
100
339
|
// Set Main Loop Data ////////////////////////////////////////////////////////
|
101
340
|
|
102
|
-
const Uint8 *key_state;
|
103
341
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Uint32 loop_ms; // Elapsed time of loop
|
112
|
-
int delay_ms; // Amount of delay to achieve desired frame rate
|
113
|
-
const double decay_rate = 0.5; // Determines how fast an average decays over time
|
114
|
-
double fps = window->fps_cap; // Moving average of actual FPS, initial value a guess
|
342
|
+
frames = 0; // Total frames since start
|
343
|
+
frames_last_sec = 0; // Frames in the last second
|
344
|
+
start_ms = SDL_GetTicks(); // Elapsed time since start
|
345
|
+
next_second_ms = SDL_GetTicks(); // The last time plus a second
|
346
|
+
begin_ms = start_ms; // Time at beginning of loop
|
347
|
+
decay_rate = 0.5; // Determines how fast an average decays over time
|
348
|
+
fps = window->fps_cap; // Moving average of actual FPS, initial value a guess
|
115
349
|
|
116
350
|
// Enable VSync
|
117
351
|
if (window->vsync) {
|
@@ -124,213 +358,17 @@ int R2D_Show(R2D_Window *window) {
|
|
124
358
|
|
125
359
|
// Main Loop /////////////////////////////////////////////////////////////////
|
126
360
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
// Set FPS /////////////////////////////////////////////////////////////////
|
134
|
-
|
135
|
-
frames++;
|
136
|
-
frames_last_sec++;
|
137
|
-
end_ms = SDL_GetTicks();
|
138
|
-
elapsed_ms = end_ms - start_ms;
|
139
|
-
|
140
|
-
// Calculate the frame rate using an exponential moving average
|
141
|
-
if (next_second_ms < end_ms) {
|
142
|
-
fps = decay_rate * fps + (1.0 - decay_rate) * frames_last_sec;
|
143
|
-
frames_last_sec = 0;
|
144
|
-
next_second_ms = SDL_GetTicks() + 1000;
|
145
|
-
}
|
146
|
-
|
147
|
-
loop_ms = end_ms - begin_ms;
|
148
|
-
delay_ms = (1000 / window->fps_cap) - loop_ms;
|
149
|
-
|
150
|
-
if (delay_ms < 0) delay_ms = 0;
|
151
|
-
|
152
|
-
// Note: `loop_ms + delay_ms` should equal `1000 / fps_cap`
|
153
|
-
|
154
|
-
SDL_Delay(delay_ms);
|
155
|
-
begin_ms = SDL_GetTicks();
|
156
|
-
|
157
|
-
// Handle Input and Window Events //////////////////////////////////////////
|
158
|
-
|
159
|
-
int mx, my; // mouse x, y coordinates
|
160
|
-
|
161
|
-
SDL_Event e;
|
162
|
-
while (SDL_PollEvent(&e)) {
|
163
|
-
switch (e.type) {
|
164
|
-
|
165
|
-
case SDL_KEYDOWN:
|
166
|
-
if (window->on_key && e.key.repeat == 0) {
|
167
|
-
R2D_Event event = {
|
168
|
-
.type = R2D_KEY_DOWN, .key = SDL_GetScancodeName(e.key.keysym.scancode)
|
169
|
-
};
|
170
|
-
window->on_key(event);
|
171
|
-
}
|
172
|
-
break;
|
173
|
-
|
174
|
-
case SDL_KEYUP:
|
175
|
-
if (window->on_key) {
|
176
|
-
R2D_Event event = {
|
177
|
-
.type = R2D_KEY_UP, .key = SDL_GetScancodeName(e.key.keysym.scancode)
|
178
|
-
};
|
179
|
-
window->on_key(event);
|
180
|
-
}
|
181
|
-
break;
|
182
|
-
|
183
|
-
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP:
|
184
|
-
if (window->on_mouse) {
|
185
|
-
R2D_GetMouseOnViewport(window, e.button.x, e.button.y, &mx, &my);
|
186
|
-
R2D_Event event = {
|
187
|
-
.button = e.button.button, .x = mx, .y = my
|
188
|
-
};
|
189
|
-
event.type = e.type == SDL_MOUSEBUTTONDOWN ? R2D_MOUSE_DOWN : R2D_MOUSE_UP;
|
190
|
-
event.dblclick = e.button.clicks == 2 ? true : false;
|
191
|
-
window->on_mouse(event);
|
192
|
-
}
|
193
|
-
break;
|
194
|
-
|
195
|
-
case SDL_MOUSEWHEEL:
|
196
|
-
if (window->on_mouse) {
|
197
|
-
R2D_Event event = {
|
198
|
-
.type = R2D_MOUSE_SCROLL, .direction = e.wheel.direction,
|
199
|
-
.delta_x = e.wheel.x, .delta_y = -e.wheel.y
|
200
|
-
};
|
201
|
-
window->on_mouse(event);
|
202
|
-
}
|
203
|
-
break;
|
204
|
-
|
205
|
-
case SDL_MOUSEMOTION:
|
206
|
-
if (window->on_mouse) {
|
207
|
-
R2D_GetMouseOnViewport(window, e.motion.x, e.motion.y, &mx, &my);
|
208
|
-
R2D_Event event = {
|
209
|
-
.type = R2D_MOUSE_MOVE,
|
210
|
-
.x = mx, .y = my, .delta_x = e.motion.xrel, .delta_y = e.motion.yrel
|
211
|
-
};
|
212
|
-
window->on_mouse(event);
|
213
|
-
}
|
214
|
-
break;
|
215
|
-
|
216
|
-
case SDL_CONTROLLERAXISMOTION:
|
217
|
-
if (window->on_controller) {
|
218
|
-
R2D_Event event = {
|
219
|
-
.which = e.caxis.which, .type = R2D_AXIS,
|
220
|
-
.axis = e.caxis.axis, .value = e.caxis.value
|
221
|
-
};
|
222
|
-
window->on_controller(event);
|
223
|
-
}
|
224
|
-
break;
|
225
|
-
|
226
|
-
case SDL_JOYAXISMOTION:
|
227
|
-
if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
|
228
|
-
R2D_Event event = {
|
229
|
-
.which = e.jaxis.which, .type = R2D_AXIS,
|
230
|
-
.axis = e.jaxis.axis, .value = e.jaxis.value
|
231
|
-
};
|
232
|
-
window->on_controller(event);
|
233
|
-
}
|
234
|
-
break;
|
235
|
-
|
236
|
-
case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP:
|
237
|
-
if (window->on_controller) {
|
238
|
-
R2D_Event event = {
|
239
|
-
.which = e.cbutton.which, .button = e.cbutton.button
|
240
|
-
};
|
241
|
-
event.type = e.type == SDL_CONTROLLERBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
|
242
|
-
window->on_controller(event);
|
243
|
-
}
|
244
|
-
break;
|
245
|
-
|
246
|
-
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP:
|
247
|
-
if (window->on_controller && !R2D_IsController(e.jbutton.which)) {
|
248
|
-
R2D_Event event = {
|
249
|
-
.which = e.jbutton.which, .button = e.jbutton.button
|
250
|
-
};
|
251
|
-
event.type = e.type == SDL_JOYBUTTONDOWN ? R2D_BUTTON_DOWN : R2D_BUTTON_UP;
|
252
|
-
window->on_controller(event);
|
253
|
-
}
|
254
|
-
break;
|
255
|
-
|
256
|
-
case SDL_JOYDEVICEADDED:
|
257
|
-
R2D_Log(R2D_INFO, "Controller connected (%i total)", SDL_NumJoysticks());
|
258
|
-
R2D_OpenControllers();
|
259
|
-
break;
|
260
|
-
|
261
|
-
case SDL_JOYDEVICEREMOVED:
|
262
|
-
if (R2D_IsController(e.jdevice.which)) {
|
263
|
-
R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_GameControllerName(SDL_GameControllerFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
|
264
|
-
SDL_GameControllerClose(SDL_GameControllerFromInstanceID(e.jdevice.which));
|
265
|
-
} else {
|
266
|
-
R2D_Log(R2D_INFO, "Controller #%i: %s removed (%i remaining)", e.jdevice.which, SDL_JoystickName(SDL_JoystickFromInstanceID(e.jdevice.which)), SDL_NumJoysticks());
|
267
|
-
SDL_JoystickClose(SDL_JoystickFromInstanceID(e.jdevice.which));
|
268
|
-
}
|
269
|
-
break;
|
270
|
-
|
271
|
-
case SDL_WINDOWEVENT:
|
272
|
-
switch (e.window.event) {
|
273
|
-
case SDL_WINDOWEVENT_RESIZED:
|
274
|
-
// Store new window size, set viewport
|
275
|
-
window->width = e.window.data1;
|
276
|
-
window->height = e.window.data2;
|
277
|
-
R2D_GL_SetViewport(window);
|
278
|
-
break;
|
279
|
-
}
|
280
|
-
break;
|
281
|
-
|
282
|
-
case SDL_QUIT:
|
283
|
-
R2D_Close(window);
|
284
|
-
break;
|
285
|
-
}
|
286
|
-
}
|
287
|
-
|
288
|
-
// Detect keys held down
|
289
|
-
int num_keys;
|
290
|
-
key_state = SDL_GetKeyboardState(&num_keys);
|
291
|
-
|
292
|
-
for (int i = 0; i < num_keys; i++) {
|
293
|
-
if (window->on_key) {
|
294
|
-
if (key_state[i] == 1) {
|
295
|
-
R2D_Event event = {
|
296
|
-
.type = R2D_KEY_HELD, .key = SDL_GetScancodeName(i)
|
297
|
-
};
|
298
|
-
window->on_key(event);
|
299
|
-
}
|
300
|
-
}
|
301
|
-
}
|
302
|
-
|
303
|
-
// Get and store mouse position relative to the viewport
|
304
|
-
int wx, wy; // mouse x, y coordinates relative to the window
|
305
|
-
SDL_GetMouseState(&wx, &wy);
|
306
|
-
R2D_GetMouseOnViewport(window, wx, wy, &window->mouse.x, &window->mouse.y);
|
307
|
-
|
308
|
-
// Update Window State /////////////////////////////////////////////////////
|
309
|
-
|
310
|
-
// Store new values in the window
|
311
|
-
window->frames = frames;
|
312
|
-
window->elapsed_ms = elapsed_ms;
|
313
|
-
window->loop_ms = loop_ms;
|
314
|
-
window->delay_ms = delay_ms;
|
315
|
-
window->fps = fps;
|
316
|
-
|
317
|
-
// Call update and render callbacks
|
318
|
-
if (window->update) window->update();
|
319
|
-
if (window->render) window->render();
|
320
|
-
|
321
|
-
// Draw Frame //////////////////////////////////////////////////////////////
|
322
|
-
|
323
|
-
// Render and flush all OpenGL buffers
|
324
|
-
R2D_GL_FlushBuffers();
|
325
|
-
|
326
|
-
// Swap buffers to display drawn contents in the window
|
327
|
-
SDL_GL_SwapWindow(window->sdl);
|
328
|
-
}
|
361
|
+
#ifdef __EMSCRIPTEN__
|
362
|
+
emscripten_set_main_loop(main_loop, 0, true);
|
363
|
+
#else
|
364
|
+
while (!window->close) main_loop();
|
365
|
+
#endif
|
329
366
|
|
330
367
|
return 0;
|
331
368
|
}
|
332
369
|
|
333
370
|
|
371
|
+
|
334
372
|
/*
|
335
373
|
* Set the icon for the window
|
336
374
|
*/
|