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/ext/ruby2d/gles.c
CHANGED
@@ -1,24 +1,18 @@
|
|
1
|
-
// OpenGL ES
|
1
|
+
// OpenGL ES
|
2
2
|
|
3
3
|
#include "ruby2d.h"
|
4
4
|
|
5
5
|
#if GLES
|
6
6
|
|
7
|
-
//
|
8
|
-
static GLuint
|
9
|
-
static
|
10
|
-
static
|
11
|
-
|
12
|
-
//
|
13
|
-
static GLuint
|
14
|
-
static GLuint
|
15
|
-
static GLuint
|
16
|
-
static GLuint texCoordLocation;
|
17
|
-
static GLuint samplerLocation;
|
18
|
-
|
19
|
-
static GLushort indices[] =
|
20
|
-
{ 0, 1, 2,
|
21
|
-
2, 3, 0 };
|
7
|
+
static GLuint vbo; // our primary vertex buffer object (VBO)
|
8
|
+
static GLuint vboSize; // size of the VBO in bytes
|
9
|
+
static GLfloat *vboData; // pointer to the VBO data
|
10
|
+
static GLfloat *vboDataCurrent; // pointer to the data for the current vertices
|
11
|
+
static GLuint vboDataIndex = 0; // index of the current object being rendered
|
12
|
+
static GLuint vboObjCapacity = 7500; // number of objects the VBO can store
|
13
|
+
static GLuint verticesTextureIds[7500]; // store the texture_id of each vertices
|
14
|
+
static GLuint shaderProgram; // triangle shader program
|
15
|
+
static GLuint texShaderProgram; // texture shader program
|
22
16
|
|
23
17
|
|
24
18
|
/*
|
@@ -29,6 +23,7 @@ void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
|
|
29
23
|
// Use the program object
|
30
24
|
glUseProgram(shaderProgram);
|
31
25
|
|
26
|
+
// Apply the projection matrix to the triangle shader
|
32
27
|
glUniformMatrix4fv(
|
33
28
|
glGetUniformLocation(shaderProgram, "u_mvpMatrix"),
|
34
29
|
1, GL_FALSE, orthoMatrix
|
@@ -37,6 +32,7 @@ void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
|
|
37
32
|
// Use the texture program object
|
38
33
|
glUseProgram(texShaderProgram);
|
39
34
|
|
35
|
+
// Apply the projection matrix to the texture shader
|
40
36
|
glUniformMatrix4fv(
|
41
37
|
glGetUniformLocation(texShaderProgram, "u_mvpMatrix"),
|
42
38
|
1, GL_FALSE, orthoMatrix
|
@@ -45,7 +41,7 @@ void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
|
|
45
41
|
|
46
42
|
|
47
43
|
/*
|
48
|
-
* Initalize OpenGL
|
44
|
+
* Initalize OpenGL
|
49
45
|
*/
|
50
46
|
int R2D_GLES_Init() {
|
51
47
|
|
@@ -76,7 +72,9 @@ int R2D_GLES_Init() {
|
|
76
72
|
|
77
73
|
// Fragment shader source string
|
78
74
|
GLchar fragmentSource[] =
|
75
|
+
#ifdef __EMSCRIPTEN__
|
79
76
|
"precision mediump float;"
|
77
|
+
#endif
|
80
78
|
// input vertex color from vertex shader
|
81
79
|
"varying vec4 v_color;"
|
82
80
|
|
@@ -87,7 +85,9 @@ int R2D_GLES_Init() {
|
|
87
85
|
|
88
86
|
// Fragment shader source string for textures
|
89
87
|
GLchar texFragmentSource[] =
|
88
|
+
#ifdef __EMSCRIPTEN__
|
90
89
|
"precision mediump float;"
|
90
|
+
#endif
|
91
91
|
// input vertex color from vertex shader
|
92
92
|
"varying vec4 v_color;"
|
93
93
|
"varying vec2 v_texcoord;"
|
@@ -98,6 +98,23 @@ int R2D_GLES_Init() {
|
|
98
98
|
" gl_FragColor = texture2D(s_texture, v_texcoord) * v_color;"
|
99
99
|
"}";
|
100
100
|
|
101
|
+
// // Create a vertex array object
|
102
|
+
// GLuint vao;
|
103
|
+
// glGenVertexArrays(1, &vao);
|
104
|
+
// glBindVertexArray(vao);
|
105
|
+
|
106
|
+
// Create a vertex buffer object and allocate data
|
107
|
+
glGenBuffers(1, &vbo);
|
108
|
+
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
109
|
+
vboSize = vboObjCapacity * sizeof(GLfloat) * 8;
|
110
|
+
vboData = (GLfloat *) malloc(vboSize);
|
111
|
+
vboDataCurrent = vboData;
|
112
|
+
|
113
|
+
// Create an element buffer object
|
114
|
+
GLuint ebo;
|
115
|
+
glGenBuffers(1, &ebo);
|
116
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
|
117
|
+
|
101
118
|
// Load the vertex and fragment shaders
|
102
119
|
GLuint vertexShader = R2D_GL_LoadShader( GL_VERTEX_SHADER, vertexSource, "GLES Vertex");
|
103
120
|
GLuint fragmentShader = R2D_GL_LoadShader(GL_FRAGMENT_SHADER, fragmentSource, "GLES Fragment");
|
@@ -124,9 +141,15 @@ int R2D_GLES_Init() {
|
|
124
141
|
// Check if linked
|
125
142
|
R2D_GL_CheckLinked(shaderProgram, "GLES shader");
|
126
143
|
|
127
|
-
//
|
128
|
-
|
129
|
-
|
144
|
+
// Specify the layout of the position vertex data...
|
145
|
+
GLint posAttrib = glGetAttribLocation(shaderProgram, "a_position");
|
146
|
+
glEnableVertexAttribArray(posAttrib);
|
147
|
+
glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);
|
148
|
+
|
149
|
+
// ...and the color vertex data
|
150
|
+
GLint colAttrib = glGetAttribLocation(shaderProgram, "a_color");
|
151
|
+
glEnableVertexAttribArray(colAttrib);
|
152
|
+
glVertexAttribPointer(colAttrib, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));
|
130
153
|
|
131
154
|
// Texture Shader //
|
132
155
|
|
@@ -149,175 +172,131 @@ int R2D_GLES_Init() {
|
|
149
172
|
// Check if linked
|
150
173
|
R2D_GL_CheckLinked(texShaderProgram, "GLES texture shader");
|
151
174
|
|
152
|
-
//
|
153
|
-
|
154
|
-
|
155
|
-
|
175
|
+
// Specify the layout of the position vertex data...
|
176
|
+
posAttrib = glGetAttribLocation(texShaderProgram, "a_position");
|
177
|
+
glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);
|
178
|
+
glEnableVertexAttribArray(posAttrib);
|
156
179
|
|
157
|
-
//
|
158
|
-
|
180
|
+
// ...and the color vertex data...
|
181
|
+
colAttrib = glGetAttribLocation(texShaderProgram, "a_color");
|
182
|
+
glVertexAttribPointer(colAttrib, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));
|
183
|
+
glEnableVertexAttribArray(colAttrib);
|
184
|
+
|
185
|
+
// ...and the texture coordinates
|
186
|
+
GLint texAttrib = glGetAttribLocation(texShaderProgram, "a_texcoord");
|
187
|
+
glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(6 * sizeof(GLfloat)));
|
188
|
+
glEnableVertexAttribArray(texAttrib);
|
159
189
|
|
160
190
|
// Clean up
|
161
191
|
glDeleteShader(vertexShader);
|
162
192
|
glDeleteShader(fragmentShader);
|
163
193
|
glDeleteShader(texFragmentShader);
|
164
194
|
|
195
|
+
// If successful, return true
|
165
196
|
return GL_TRUE;
|
166
197
|
}
|
167
198
|
|
168
199
|
|
169
200
|
/*
|
170
|
-
*
|
201
|
+
* Render the vertex buffer and reset it
|
171
202
|
*/
|
172
|
-
void
|
173
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
174
|
-
GLfloat x2, GLfloat y2,
|
175
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
176
|
-
GLfloat x3, GLfloat y3,
|
177
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3) {
|
203
|
+
void R2D_GLES_FlushBuffers() {
|
178
204
|
|
179
|
-
|
180
|
-
|
181
|
-
x2, y2, 0.f,
|
182
|
-
x3, y3, 0.f };
|
205
|
+
// Bind to the vertex buffer object and update its data
|
206
|
+
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
183
207
|
|
184
|
-
|
185
|
-
|
186
|
-
r2, g2, b2, a2,
|
187
|
-
r3, g3, b3, a3 };
|
208
|
+
glBufferData(GL_ARRAY_BUFFER, vboSize, NULL, GL_DYNAMIC_DRAW);
|
209
|
+
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * vboDataIndex * 8, vboData);
|
188
210
|
|
189
|
-
|
211
|
+
GLuint verticesOffset = 0;
|
212
|
+
GLuint lastTextureId = verticesTextureIds[0];
|
190
213
|
|
191
|
-
|
192
|
-
|
193
|
-
|
214
|
+
for (GLuint i = 0; i <= vboDataIndex; i++) {
|
215
|
+
if (lastTextureId != verticesTextureIds[i] || i == vboDataIndex) {
|
216
|
+
// A texture ID of 0 represents no texture (render a triangle)
|
217
|
+
if (lastTextureId == 0) {
|
194
218
|
|
195
|
-
|
196
|
-
|
197
|
-
glEnableVertexAttribArray(colorLocation);
|
219
|
+
// Use the triangle shader program
|
220
|
+
glUseProgram(shaderProgram);
|
198
221
|
|
199
|
-
|
200
|
-
|
201
|
-
}
|
222
|
+
// A number other than 0 represents a texture_id
|
223
|
+
} else {
|
202
224
|
|
225
|
+
// Use the texture shader program
|
226
|
+
glUseProgram(texShaderProgram);
|
203
227
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
static void R2D_GLES_DrawTexture(int x, int y, int w, int h,
|
208
|
-
GLfloat angle, GLfloat rx, GLfloat ry,
|
209
|
-
GLfloat r, GLfloat g, GLfloat b, GLfloat a,
|
210
|
-
GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
|
211
|
-
GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4,
|
212
|
-
GLuint texture_id) {
|
213
|
-
|
214
|
-
R2D_GL_Point v1 = { .x = x, .y = y };
|
215
|
-
R2D_GL_Point v2 = { .x = x + w, .y = y };
|
216
|
-
R2D_GL_Point v3 = { .x = x + w, .y = y + h };
|
217
|
-
R2D_GL_Point v4 = { .x = x, .y = y + h };
|
218
|
-
|
219
|
-
// Rotate vertices
|
220
|
-
if (angle != 0) {
|
221
|
-
v1 = R2D_RotatePoint(v1, angle, rx, ry);
|
222
|
-
v2 = R2D_RotatePoint(v2, angle, rx, ry);
|
223
|
-
v3 = R2D_RotatePoint(v3, angle, rx, ry);
|
224
|
-
v4 = R2D_RotatePoint(v4, angle, rx, ry);
|
225
|
-
}
|
226
|
-
|
227
|
-
GLfloat vertices[] =
|
228
|
-
// x, y coords | x, y texture coords
|
229
|
-
{ v1.x, v1.y, 0.f, tx1, ty1,
|
230
|
-
v2.x, v2.y, 0.f, tx2, ty2,
|
231
|
-
v3.x, v3.y, 0.f, tx3, ty3,
|
232
|
-
v4.x, v4.y, 0.f, tx4, ty4 };
|
233
|
-
|
234
|
-
GLfloat colors[] =
|
235
|
-
{ r, g, b, a,
|
236
|
-
r, g, b, a,
|
237
|
-
r, g, b, a,
|
238
|
-
r, g, b, a };
|
239
|
-
|
240
|
-
glUseProgram(texShaderProgram);
|
228
|
+
// Bind the texture using the provided ID
|
229
|
+
glBindTexture(GL_TEXTURE_2D, lastTextureId);
|
230
|
+
}
|
241
231
|
|
242
|
-
|
243
|
-
glVertexAttribPointer(texPositionLocation, 3, GL_FLOAT, GL_FALSE,
|
244
|
-
5 * sizeof(GLfloat), vertices);
|
245
|
-
glEnableVertexAttribArray(texPositionLocation);
|
232
|
+
glDrawArrays(GL_TRIANGLES, verticesOffset, i - verticesOffset);
|
246
233
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
// Load the texture coordinate
|
252
|
-
glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE,
|
253
|
-
5 * sizeof(GLfloat), &vertices[3]);
|
254
|
-
glEnableVertexAttribArray(texCoordLocation);
|
255
|
-
|
256
|
-
// Bind the texture
|
257
|
-
glActiveTexture(GL_TEXTURE0);
|
258
|
-
glBindTexture(GL_TEXTURE_2D, texture_id);
|
259
|
-
|
260
|
-
// Set the sampler texture unit to 0
|
261
|
-
glUniform1i(samplerLocation, 0);
|
234
|
+
lastTextureId = verticesTextureIds[i];
|
235
|
+
verticesOffset = i;
|
236
|
+
}
|
237
|
+
}
|
262
238
|
|
263
|
-
|
239
|
+
// Reset the buffer object index and data pointer
|
240
|
+
vboDataIndex = 0;
|
241
|
+
vboDataCurrent = vboData;
|
264
242
|
}
|
265
243
|
|
266
244
|
|
267
245
|
/*
|
268
|
-
* Draw
|
246
|
+
* Draw triangle
|
269
247
|
*/
|
270
|
-
void
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
img->texture_id
|
277
|
-
);
|
278
|
-
}
|
248
|
+
void R2D_GLES_DrawTriangle(GLfloat x1, GLfloat y1,
|
249
|
+
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
250
|
+
GLfloat x2, GLfloat y2,
|
251
|
+
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
252
|
+
GLfloat x3, GLfloat y3,
|
253
|
+
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3) {
|
279
254
|
|
255
|
+
// If buffer is full, flush it
|
256
|
+
if (vboDataIndex + 3 >= vboObjCapacity) R2D_GLES_FlushBuffers();
|
280
257
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
spr->x, spr->y, spr->width, spr->height,
|
287
|
-
spr->rotate, spr->rx, spr->ry,
|
288
|
-
spr->color.r, spr->color.g, spr->color.b, spr->color.a,
|
289
|
-
spr->tx1, spr->ty1, spr->tx2, spr->ty2, spr->tx3, spr->ty3, spr->tx4, spr->ty4,
|
290
|
-
spr->img->texture_id
|
291
|
-
);
|
292
|
-
}
|
258
|
+
// Set the triangle data into a formatted array
|
259
|
+
GLfloat vertices[24] =
|
260
|
+
{ x1, y1, r1, g1, b1, a1, 0, 0,
|
261
|
+
x2, y2, r2, g2, b2, a2, 0, 0,
|
262
|
+
x3, y3, r3, g3, b3, a3, 0, 0 };
|
293
263
|
|
264
|
+
// Copy the vertex data into the current position of the buffer
|
265
|
+
memcpy(vboDataCurrent, vertices, sizeof(vertices));
|
294
266
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
|
300
|
-
R2D_GLES_DrawTexture(
|
301
|
-
x, y, tw, th,
|
302
|
-
img->rotate, img->rx, img->ry,
|
303
|
-
img->color.r, img->color.g, img->color.b, img->color.a,
|
304
|
-
tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
|
305
|
-
img->texture_id
|
306
|
-
);
|
267
|
+
// Increment the buffer object index and the vertex data pointer for next use
|
268
|
+
verticesTextureIds[vboDataIndex] = verticesTextureIds[vboDataIndex + 1] = verticesTextureIds[vboDataIndex + 2] = 0;
|
269
|
+
vboDataIndex += 3;
|
270
|
+
vboDataCurrent = (GLfloat *)((char *)vboDataCurrent + (sizeof(GLfloat) * 24));
|
307
271
|
}
|
308
272
|
|
309
273
|
|
310
274
|
/*
|
311
|
-
* Draw
|
275
|
+
* Draw a texture (New method with vertices pre-calculated)
|
312
276
|
*/
|
313
|
-
void
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
277
|
+
void R2D_GLES_DrawTexture(GLfloat coordinates[], GLfloat texture_coordinates[], GLfloat color[], int texture_id) {
|
278
|
+
// If buffer is full, flush it
|
279
|
+
if (vboDataIndex + 6 >= vboObjCapacity) R2D_GLES_FlushBuffers();
|
280
|
+
|
281
|
+
// There are 6 vertices for a square as we are rendering two Triangles to make up our square:
|
282
|
+
// Triangle one: Top left, Top right, Bottom right
|
283
|
+
// Triangle two: Bottom right, Bottom left, Top left
|
284
|
+
GLfloat vertices[48] = {
|
285
|
+
coordinates[0], coordinates[1], color[0], color[1], color[2], color[3], texture_coordinates[0], texture_coordinates[1],
|
286
|
+
coordinates[2], coordinates[3], color[0], color[1], color[2], color[3], texture_coordinates[2], texture_coordinates[3],
|
287
|
+
coordinates[4], coordinates[5], color[0], color[1], color[2], color[3], texture_coordinates[4], texture_coordinates[5],
|
288
|
+
coordinates[4], coordinates[5], color[0], color[1], color[2], color[3], texture_coordinates[4], texture_coordinates[5],
|
289
|
+
coordinates[6], coordinates[7], color[0], color[1], color[2], color[3], texture_coordinates[6], texture_coordinates[7],
|
290
|
+
coordinates[0], coordinates[1], color[0], color[1], color[2], color[3], texture_coordinates[0], texture_coordinates[1],
|
291
|
+
};
|
292
|
+
|
293
|
+
// Copy the vertex data into the current position of the buffer
|
294
|
+
memcpy(vboDataCurrent, vertices, sizeof(vertices));
|
295
|
+
|
296
|
+
verticesTextureIds[vboDataIndex] = verticesTextureIds[vboDataIndex + 1] = verticesTextureIds[vboDataIndex + 2] = verticesTextureIds[vboDataIndex + 3] = verticesTextureIds[vboDataIndex + 4] = verticesTextureIds[vboDataIndex + 5] = texture_id;
|
297
|
+
vboDataIndex += 6;
|
298
|
+
vboDataCurrent = (GLfloat *)((char *)vboDataCurrent + (sizeof(GLfloat) * 48));
|
321
299
|
}
|
322
300
|
|
301
|
+
|
323
302
|
#endif
|
data/ext/ruby2d/image.c
CHANGED
@@ -3,75 +3,39 @@
|
|
3
3
|
#include "ruby2d.h"
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
* Create an image, given a file path
|
8
|
-
*/
|
9
|
-
R2D_Image *R2D_CreateImage(const char *path) {
|
6
|
+
SDL_Surface *R2D_CreateImageSurface(const char *path) {
|
10
7
|
R2D_Init();
|
11
8
|
|
12
9
|
// Check if image file exists
|
13
10
|
if (!R2D_FileExists(path)) {
|
14
|
-
R2D_Error("
|
15
|
-
return NULL;
|
16
|
-
}
|
17
|
-
|
18
|
-
// Allocate the image structure
|
19
|
-
R2D_Image *img = (R2D_Image *) malloc(sizeof(R2D_Image));
|
20
|
-
if (!img) {
|
21
|
-
R2D_Error("R2D_CreateImage", "Out of memory!");
|
11
|
+
R2D_Error("R2D_CreateImageSurface", "Image file `%s` not found", path);
|
22
12
|
return NULL;
|
23
13
|
}
|
24
14
|
|
25
15
|
// Load image from file as SDL_Surface
|
26
|
-
|
27
|
-
if (!img->surface) {
|
28
|
-
R2D_Error("IMG_Load", IMG_GetError());
|
29
|
-
free(img);
|
30
|
-
return NULL;
|
31
|
-
}
|
16
|
+
SDL_Surface *surface = IMG_Load(path);
|
32
17
|
|
33
|
-
int bits_per_color =
|
34
|
-
|
35
|
-
|
18
|
+
int bits_per_color = surface->format->Amask == 0 ?
|
19
|
+
surface->format->BitsPerPixel / 3 :
|
20
|
+
surface->format->BitsPerPixel / 4;
|
36
21
|
|
37
22
|
if (bits_per_color < 8) {
|
38
23
|
R2D_Log(R2D_WARN, "`%s` has less than 8 bits per color and will likely not render correctly", path, bits_per_color);
|
39
24
|
}
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
img->x = 0;
|
44
|
-
img->y = 0;
|
45
|
-
img->color.r = 1.f;
|
46
|
-
img->color.g = 1.f;
|
47
|
-
img->color.b = 1.f;
|
48
|
-
img->color.a = 1.f;
|
49
|
-
img->orig_width = img->surface->w;
|
50
|
-
img->orig_height = img->surface->h;
|
51
|
-
img->width = img->orig_width;
|
52
|
-
img->height = img->orig_height;
|
53
|
-
img->rotate = 0;
|
54
|
-
img->rx = 0;
|
55
|
-
img->ry = 0;
|
56
|
-
img->texture_id = 0;
|
57
|
-
|
58
|
-
// Detect image mode
|
59
|
-
img->format = GL_RGB;
|
60
|
-
if (img->surface->format->BytesPerPixel == 4) {
|
61
|
-
img->format = GL_RGBA;
|
62
|
-
}
|
63
|
-
|
64
|
-
// Flip image bits if BGA
|
26
|
+
return surface;
|
27
|
+
}
|
65
28
|
|
66
|
-
|
67
|
-
Uint32
|
68
|
-
Uint32
|
29
|
+
void R2D_ImageConvertToRGB(SDL_Surface *surface) {
|
30
|
+
Uint32 r = surface->format->Rmask;
|
31
|
+
Uint32 g = surface->format->Gmask;
|
32
|
+
Uint32 a = surface->format->Amask;
|
69
33
|
|
70
34
|
if (r&0xFF000000 || r&0xFF0000) {
|
71
|
-
char *p = (char *)
|
72
|
-
int bpp =
|
73
|
-
int w =
|
74
|
-
int h =
|
35
|
+
char *p = (char *)surface->pixels;
|
36
|
+
int bpp = surface->format->BytesPerPixel;
|
37
|
+
int w = surface->w;
|
38
|
+
int h = surface->h;
|
75
39
|
char tmp;
|
76
40
|
for (int i = 0; i < bpp * w * h; i += bpp) {
|
77
41
|
if (a&0xFF) {
|
@@ -91,48 +55,4 @@ R2D_Image *R2D_CreateImage(const char *path) {
|
|
91
55
|
}
|
92
56
|
}
|
93
57
|
}
|
94
|
-
|
95
|
-
return img;
|
96
|
-
}
|
97
|
-
|
98
|
-
|
99
|
-
/*
|
100
|
-
* Rotate an image
|
101
|
-
*/
|
102
|
-
void R2D_RotateImage(R2D_Image *img, GLfloat angle, int position) {
|
103
|
-
|
104
|
-
R2D_GL_Point p = R2D_GetRectRotationPoint(
|
105
|
-
img->x, img->y, img->width, img->height, position
|
106
|
-
);
|
107
|
-
|
108
|
-
img->rotate = angle;
|
109
|
-
img->rx = p.x;
|
110
|
-
img->ry = p.y;
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
/*
|
115
|
-
* Draw an image
|
116
|
-
*/
|
117
|
-
void R2D_DrawImage(R2D_Image *img) {
|
118
|
-
if (!img) return;
|
119
|
-
|
120
|
-
if (img->texture_id == 0) {
|
121
|
-
R2D_GL_CreateTexture(&img->texture_id, img->format,
|
122
|
-
img->orig_width, img->orig_height,
|
123
|
-
img->surface->pixels, GL_NEAREST);
|
124
|
-
SDL_FreeSurface(img->surface);
|
125
|
-
}
|
126
|
-
|
127
|
-
R2D_GL_DrawImage(img);
|
128
|
-
}
|
129
|
-
|
130
|
-
|
131
|
-
/*
|
132
|
-
* Free an image
|
133
|
-
*/
|
134
|
-
void R2D_FreeImage(R2D_Image *img) {
|
135
|
-
if (!img) return;
|
136
|
-
R2D_GL_FreeTexture(&img->texture_id);
|
137
|
-
free(img);
|
138
58
|
}
|