gosu 0.15.2 → 1.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +138 -0
- data/dependencies/SDL/include/SDL_assert.h +293 -0
- data/dependencies/SDL/include/SDL_atomic.h +295 -0
- data/dependencies/SDL/include/SDL_audio.h +859 -0
- data/dependencies/SDL/include/SDL_bits.h +121 -0
- data/dependencies/SDL/include/SDL_blendmode.h +123 -0
- data/dependencies/SDL/include/SDL_clipboard.h +71 -0
- data/dependencies/SDL/include/SDL_config.h +55 -0
- data/dependencies/SDL/include/SDL_config_android.h +182 -0
- data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
- data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
- data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
- data/dependencies/SDL/include/SDL_config_os2.h +188 -0
- data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
- data/dependencies/SDL/include/SDL_config_psp.h +165 -0
- data/dependencies/SDL/include/SDL_config_windows.h +288 -0
- data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
- data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
- data/dependencies/SDL/include/SDL_copying.h +20 -0
- data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
- data/dependencies/SDL/include/SDL_egl.h +1676 -0
- data/dependencies/SDL/include/SDL_endian.h +263 -0
- data/dependencies/SDL/include/SDL_error.h +112 -0
- data/dependencies/SDL/include/SDL_events.h +827 -0
- data/dependencies/SDL/include/SDL_filesystem.h +136 -0
- data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
- data/dependencies/SDL/include/SDL_gesture.h +87 -0
- data/dependencies/SDL/include/SDL_haptic.h +1247 -0
- data/dependencies/SDL/include/SDL_hints.h +1578 -0
- data/dependencies/SDL/include/SDL_joystick.h +499 -0
- data/dependencies/SDL/include/SDL_keyboard.h +217 -0
- data/dependencies/SDL/include/SDL_keycode.h +351 -0
- data/dependencies/SDL/include/SDL_loadso.h +81 -0
- data/dependencies/SDL/include/SDL_locale.h +101 -0
- data/dependencies/SDL/include/SDL_log.h +211 -0
- data/dependencies/SDL/include/SDL_main.h +180 -0
- data/dependencies/SDL/include/SDL_messagebox.h +146 -0
- data/dependencies/SDL/include/SDL_metal.h +117 -0
- data/dependencies/SDL/include/SDL_misc.h +75 -0
- data/dependencies/SDL/include/SDL_mouse.h +302 -0
- data/dependencies/SDL/include/SDL_mutex.h +251 -0
- data/dependencies/SDL/include/SDL_name.h +33 -0
- data/dependencies/SDL/include/SDL_opengl.h +2183 -0
- data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
- data/dependencies/SDL/include/SDL_opengles.h +39 -0
- data/dependencies/SDL/include/SDL_opengles2.h +52 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
- data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
- data/dependencies/SDL/include/SDL_pixels.h +479 -0
- data/dependencies/SDL/include/SDL_platform.h +198 -0
- data/dependencies/SDL/include/SDL_power.h +75 -0
- data/dependencies/SDL/include/SDL_quit.h +58 -0
- data/dependencies/SDL/include/SDL_rect.h +174 -0
- data/dependencies/SDL/include/SDL_render.h +1158 -0
- data/dependencies/SDL/include/SDL_revision.h +2 -0
- data/dependencies/SDL/include/SDL_rwops.h +283 -0
- data/dependencies/SDL/include/SDL_scancode.h +413 -0
- data/dependencies/SDL/include/SDL_sensor.h +267 -0
- data/dependencies/SDL/include/SDL_shape.h +144 -0
- data/dependencies/SDL/include/SDL_stdinc.h +647 -0
- data/dependencies/SDL/include/SDL_surface.h +563 -0
- data/dependencies/SDL/include/SDL_system.h +325 -0
- data/dependencies/SDL/include/SDL_syswm.h +354 -0
- data/dependencies/SDL/include/SDL_test.h +69 -0
- data/dependencies/SDL/include/SDL_test_assert.h +105 -0
- data/dependencies/SDL/include/SDL_test_common.h +218 -0
- data/dependencies/SDL/include/SDL_test_compare.h +69 -0
- data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
- data/dependencies/SDL/include/SDL_test_font.h +81 -0
- data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
- data/dependencies/SDL/include/SDL_test_harness.h +134 -0
- data/dependencies/SDL/include/SDL_test_images.h +78 -0
- data/dependencies/SDL/include/SDL_test_log.h +67 -0
- data/dependencies/SDL/include/SDL_test_md5.h +129 -0
- data/dependencies/SDL/include/SDL_test_memory.h +63 -0
- data/dependencies/SDL/include/SDL_test_random.h +115 -0
- data/dependencies/SDL/include/SDL_thread.h +366 -0
- data/dependencies/SDL/include/SDL_timer.h +115 -0
- data/dependencies/SDL/include/SDL_touch.h +102 -0
- data/dependencies/SDL/include/SDL_types.h +29 -0
- data/dependencies/SDL/include/SDL_version.h +162 -0
- data/dependencies/SDL/include/SDL_video.h +1282 -0
- data/dependencies/SDL/include/SDL_vulkan.h +276 -0
- data/dependencies/SDL/include/begin_code.h +166 -0
- data/dependencies/SDL/include/close_code.h +40 -0
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +795 -0
- data/dependencies/SDL_sound/SDL_sound.h +725 -0
- data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
- data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
- data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
- data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
- data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
- data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
- data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
- data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
- data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
- data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
- data/dependencies/SDL_sound/dr_flac.h +5906 -0
- data/dependencies/SDL_sound/dr_mp3.h +2832 -0
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
- data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
- data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
- data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
- data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
- data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
- data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
- data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
- data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
- data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
- data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
- data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
- data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
- data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
- data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
- data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
- data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
- data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
- data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
- data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
- data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
- data/dependencies/al_soft/AL/al.h +655 -0
- data/dependencies/al_soft/AL/alc.h +270 -0
- data/dependencies/al_soft/AL/alext.h +585 -0
- data/dependencies/al_soft/AL/efx-creative.h +3 -0
- data/dependencies/al_soft/AL/efx-presets.h +402 -0
- data/dependencies/al_soft/AL/efx.h +762 -0
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/{src → dependencies/stb}/stb_image.h +330 -127
- data/{src → dependencies/stb}/stb_image_write.h +156 -85
- data/{src → dependencies/stb}/stb_truetype.h +192 -69
- data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
- data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
- data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
- data/ext/gosu/extconf.rb +53 -39
- data/{Gosu → include/Gosu}/Audio.hpp +6 -8
- data/include/Gosu/Bitmap.hpp +100 -0
- data/{Gosu → include/Gosu}/Buttons.hpp +104 -44
- data/{Gosu → include/Gosu}/Color.hpp +0 -0
- data/{Gosu → include/Gosu}/Directories.hpp +0 -0
- data/{Gosu → include/Gosu}/Font.hpp +1 -1
- data/{Gosu → include/Gosu}/Fwd.hpp +0 -5
- data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
- data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
- data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
- data/{Gosu → include/Gosu}/IO.hpp +0 -0
- data/{Gosu → include/Gosu}/Image.hpp +7 -6
- data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
- data/{Gosu → include/Gosu}/Input.hpp +39 -51
- data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
- data/{Gosu → include/Gosu}/Math.hpp +0 -0
- data/{Gosu → include/Gosu}/Platform.hpp +0 -0
- data/{Gosu → include/Gosu}/Text.hpp +0 -0
- data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
- data/{Gosu → include/Gosu}/Timing.hpp +0 -0
- data/{Gosu → include/Gosu}/Utility.hpp +15 -4
- data/{Gosu → include/Gosu}/Version.hpp +3 -3
- data/{Gosu → include/Gosu}/Window.hpp +46 -34
- data/lib/OpenAL32.dll +0 -0
- data/lib/SDL2.dll +0 -0
- data/lib/gosu.rb +0 -3
- data/lib/gosu/patches.rb +0 -23
- data/lib/gosu/preview.rb +1 -3
- data/lib/gosu/swig_patches.rb +14 -12
- data/lib64/OpenAL32.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +112 -23
- data/src/Audio.cpp +50 -224
- data/src/AudioFile.hpp +20 -37
- data/src/AudioFileAudioToolbox.cpp +237 -0
- data/src/AudioFileSDLSound.cpp +147 -0
- data/src/AudioImpl.cpp +3 -12
- data/src/AudioImpl.hpp +3 -1
- data/src/Bitmap.cpp +85 -83
- data/src/BitmapIO.cpp +52 -58
- data/src/Font.cpp +3 -1
- data/src/Graphics.cpp +7 -4
- data/src/Image.cpp +13 -16
- data/src/Input.cpp +412 -164
- data/src/LargeImageData.cpp +1 -1
- data/src/MarkupParser.cpp +2 -1
- data/src/Resolution.cpp +8 -8
- data/src/RubyGosu.cxx +1017 -196
- data/src/RubyGosu.h +4 -2
- data/src/TexChunk.cpp +1 -1
- data/src/TextBuilder.cpp +3 -1
- data/src/Texture.cpp +1 -1
- data/src/TrueTypeFont.cpp +1 -1
- data/src/TrueTypeFontWin.cpp +3 -3
- data/src/Utility.cpp +11 -7
- data/src/Window.cpp +90 -62
- data/src/WindowUIKit.cpp +21 -9
- metadata +194 -65
- data/Gosu/AutoLink.hpp +0 -14
- data/Gosu/Bitmap.hpp +0 -113
- data/Gosu/Channel.h +0 -25
- data/Gosu/Color.h +0 -38
- data/Gosu/Font.h +0 -36
- data/Gosu/Gosu.h +0 -79
- data/Gosu/Image.h +0 -54
- data/Gosu/Sample.h +0 -19
- data/Gosu/Song.h +0 -24
- data/Gosu/TextInput.h +0 -30
- data/Gosu/Window.h +0 -61
- data/lib/gosu/zen.rb +0 -89
- data/src/AudioToolboxFile.hpp +0 -210
- data/src/ChannelWrapper.cpp +0 -50
- data/src/ColorWrapper.cpp +0 -126
- data/src/Constants.cpp +0 -287
- data/src/FontWrapper.cpp +0 -74
- data/src/GosuWrapper.cpp +0 -232
- data/src/ImageWrapper.cpp +0 -168
- data/src/MPEGFile.hpp +0 -90
- data/src/OggFile.hpp +0 -92
- data/src/SampleWrapper.cpp +0 -30
- data/src/SndFile.hpp +0 -174
- data/src/SongWrapper.cpp +0 -52
- data/src/TextInputWrapper.cpp +0 -101
- data/src/WinMain.cpp +0 -64
- data/src/WindowWrapper.cpp +0 -289
data/lib/OpenAL32.dll
ADDED
Binary file
|
data/lib/SDL2.dll
ADDED
Binary file
|
data/lib/gosu.rb
CHANGED
@@ -17,9 +17,6 @@ if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/
|
|
17
17
|
path_encoding = ENV["PATH"].encoding
|
18
18
|
ENV["PATH"] = "#{binary_path.encode(path_encoding)};#{ENV["PATH"]}"
|
19
19
|
end
|
20
|
-
|
21
|
-
# Add the correct lib directory for the current version of Ruby (major.minor).
|
22
|
-
$LOAD_PATH.unshift File.join(binary_path, RUBY_VERSION[/^\d+.\d+/])
|
23
20
|
end
|
24
21
|
|
25
22
|
require "gosu.#{RbConfig::CONFIG["DLEXT"]}"
|
data/lib/gosu/patches.rb
CHANGED
@@ -18,26 +18,12 @@ class ::Numeric
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
class Gosu::Font
|
22
|
-
# draw_text will stop parsing markup in Gosu 1.0.
|
23
|
-
alias_method :draw_text, :draw_markup
|
24
|
-
# draw_text_rel will stop parsing markup in Gosu 1.0.
|
25
|
-
alias_method :draw_text_rel, :draw_markup_rel
|
26
|
-
# text_width will stop parsing markup in Gosu 1.0.
|
27
|
-
alias_method :text_width, :markup_width
|
28
|
-
end
|
29
|
-
|
30
21
|
class Gosu::Image
|
31
22
|
BlobHelper = Struct.new(:columns, :rows, :to_blob)
|
32
23
|
|
33
24
|
def self.from_blob(width, height, rgba = "\0\0\0\0" * (width * height))
|
34
25
|
self.new(BlobHelper.new(width, height, rgba))
|
35
26
|
end
|
36
|
-
|
37
|
-
# from_markup will stop parsing markup in Gosu 1.0.
|
38
|
-
def self.from_markup(*args)
|
39
|
-
self.from_text(*args)
|
40
|
-
end
|
41
27
|
end
|
42
28
|
|
43
29
|
# Color constants.
|
@@ -78,12 +64,3 @@ class Gosu::Window
|
|
78
64
|
_tick
|
79
65
|
end
|
80
66
|
end
|
81
|
-
|
82
|
-
# Release OpenAL resources during Ruby's shutdown, not Gosu's.
|
83
|
-
at_exit do
|
84
|
-
begin
|
85
|
-
Gosu::Song.current_song.stop if Gosu::Song.current_song
|
86
|
-
Gosu._release_all_openal_resources
|
87
|
-
rescue
|
88
|
-
end
|
89
|
-
end
|
data/lib/gosu/preview.rb
CHANGED
@@ -3,8 +3,6 @@ warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
|
|
3
3
|
"Notable differences:\n" +
|
4
4
|
"• no global $window variable\n" +
|
5
5
|
"• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
|
6
|
-
"• Image#initialize et.al. use an options hash now
|
7
|
-
"If you cannot update your code base right now, you should require \n" +
|
8
|
-
"Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
|
6
|
+
"• Image#initialize et.al. use an options hash now";
|
9
7
|
|
10
8
|
require 'gosu'
|
data/lib/gosu/swig_patches.rb
CHANGED
@@ -3,23 +3,25 @@
|
|
3
3
|
# compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
|
4
4
|
# custom debugging help:
|
5
5
|
class Gosu::Window
|
6
|
-
alias_method :
|
6
|
+
alias_method :initialize_with_bitmask, :initialize
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def initialize(width, height, *args)
|
9
|
+
$gosu_gl_blocks = nil
|
10
|
+
|
11
|
+
if args.first.is_a? Hash
|
12
|
+
flags = 0
|
13
|
+
flags |= 1 if args.first[:fullscreen]
|
14
|
+
flags |= 2 if args.first[:resizable]
|
15
|
+
flags |= 4 if args.first[:borderless]
|
16
|
+
initialize_with_bitmask(width, height, flags, args.first[:update_interval] || 16.666666)
|
14
17
|
else
|
15
|
-
|
18
|
+
initialize_with_bitmask(width, height, args[0] ? 1 : 0, args[1] || 16.666666)
|
16
19
|
end
|
17
|
-
$gosu_gl_blocks = nil
|
18
|
-
initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666, !!resizable
|
19
20
|
end
|
20
21
|
|
21
22
|
%w(update draw needs_redraw? needs_cursor?
|
22
|
-
lose_focus button_down button_up
|
23
|
+
lose_focus button_down button_up
|
24
|
+
gamepad_connected gamepad_disconnected drop).each do |callback|
|
23
25
|
define_method "protected_#{callback}" do |*args|
|
24
26
|
begin
|
25
27
|
# If there has been an exception, don't do anything as to not make matters worse.
|
@@ -47,7 +49,7 @@ class Gosu::Window
|
|
47
49
|
# doing here.
|
48
50
|
if defined? @_exception
|
49
51
|
if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen?
|
50
|
-
@_exception.backtrace.reject! { |line| line.include?
|
52
|
+
@_exception.backtrace.reject! { |line| line.include? "lib/gosu/swig_patches.rb" }
|
51
53
|
end
|
52
54
|
raise @_exception
|
53
55
|
end
|
data/lib64/OpenAL32.dll
ADDED
Binary file
|
data/lib64/SDL2.dll
ADDED
Binary file
|
data/rdoc/gosu.rb
CHANGED
@@ -32,6 +32,10 @@ module Gosu
|
|
32
32
|
KB_DOWN = :an_integer
|
33
33
|
KB_END = :an_integer
|
34
34
|
|
35
|
+
KB_PRINT_SCREEN = :an_integer
|
36
|
+
KB_SCROLL_LOCK = :an_integer
|
37
|
+
KB_PAUSE = :an_integer
|
38
|
+
|
35
39
|
##
|
36
40
|
# This is the key on the numpad.
|
37
41
|
KB_ENTER = :an_integer
|
@@ -71,6 +75,7 @@ module Gosu
|
|
71
75
|
KB_RIGHT_SHIFT = :an_integer
|
72
76
|
KB_SEMICOLON = :an_integer
|
73
77
|
KB_SLASH = :an_integer
|
78
|
+
KB_CAPS_LOCK = :an_integer
|
74
79
|
KB_SPACE = :an_integer
|
75
80
|
KB_TAB = :an_integer
|
76
81
|
KB_UP = :an_integer
|
@@ -83,12 +88,32 @@ module Gosu
|
|
83
88
|
MS_OTHER_0…MS_OTHER_7 = :an_integer
|
84
89
|
|
85
90
|
GP_BUTTON_0…GP_BUTTON_15 = :an_integer
|
91
|
+
GP_LEFT_STICK_X_AXIS = :an_integer
|
92
|
+
GP_RIGHT_STICK_X_AXIS = :an_integer
|
93
|
+
GP_LEFT_STICK_Y_AXIS = :an_integer
|
94
|
+
GP_RIGHT_STICK_Y_AXIS = :an_integer
|
95
|
+
GP_LEFT_TRIGGER_AXIS = :an_integer
|
96
|
+
GP_RIGHT_TRIGGER_AXIS = :an_integer
|
97
|
+
GP_DPAD_DOWN = :an_integer
|
98
|
+
GP_DPAD_LEFT = :an_integer
|
99
|
+
GP_DPAD_RIGHT = :an_integer
|
100
|
+
GP_DPAD_UP = :an_integer
|
86
101
|
GP_DOWN = :an_integer
|
87
102
|
GP_LEFT = :an_integer
|
88
103
|
GP_RIGHT = :an_integer
|
89
104
|
GP_UP = :an_integer
|
90
105
|
|
91
106
|
GP_0_BUTTON_0…GP_3_BUTTON_15 = :an_integer
|
107
|
+
GP_0_LEFT_STICK_X_AXIS…GP_3_LEFT_STICK_X_AXIS = :an_integer
|
108
|
+
GP_0_RIGHT_STICK_X_AXIS…GP_3_RIGHT_STICK_X_AXIS = :an_integer
|
109
|
+
GP_0_LEFT_STICK_Y_AXIS…GP_3_LEFT_STICK_Y_AXIS = :an_integer
|
110
|
+
GP_0_RIGHT_STICK_Y_AXIS…GP_3_RIGHT_STICK_Y_AXIS = :an_integer
|
111
|
+
GP_0_LEFT_TRIGGER_AXIS…GP_3_LEFT_TRIGGER_AXIS = :an_integer
|
112
|
+
GP_0_RIGHT_TRIGGER_AXIS…GP_3_RIGHT_TRIGGER_AXIS = :an_integer
|
113
|
+
GP_0_DPAD_DOWN…GP_3_DPAD_DOWN = :an_integer
|
114
|
+
GP_0_DPAD_LEFT…GP_3_DPAD_LEFT = :an_integer
|
115
|
+
GP_0_DPAD_RIGHT…GP_3_DPAD_RIGHT = :an_integer
|
116
|
+
GP_0_DPAD_UP…GP_3_DPAD_UP = :an_integer
|
92
117
|
GP_0_DOWN…GP_3_DOWN = :an_integer
|
93
118
|
GP_0_LEFT…GP_3_LEFT = :an_integer
|
94
119
|
GP_0_RIGHT…GP_3_RIGHT = :an_integer
|
@@ -193,14 +218,14 @@ module Gosu
|
|
193
218
|
##
|
194
219
|
# @return [Integer] a 32-bit representation of the color in 0xAARRGGBB format.
|
195
220
|
def argb; end
|
196
|
-
|
221
|
+
|
197
222
|
alias_method :to_i, :argb
|
198
223
|
|
199
224
|
# Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed format in memory and its integer value may vary depending on your system's byte order.
|
200
225
|
#
|
201
226
|
# @return [Integer] a 32-bit OpenGL color.
|
202
227
|
def gl; end
|
203
|
-
|
228
|
+
|
204
229
|
# Returns an OpenGL integer constant that identifies the RGBA color format that Gosu uses.
|
205
230
|
GL_FORMAT = :some_integer
|
206
231
|
|
@@ -316,7 +341,7 @@ module Gosu
|
|
316
341
|
# @return [Integer] the width of the text, in pixels.
|
317
342
|
# @param text [String]
|
318
343
|
def text_width(text, scale_x=1); end
|
319
|
-
|
344
|
+
|
320
345
|
##
|
321
346
|
# Like {#text_width}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
|
322
347
|
def markup_width(markup, scale_x=1); end
|
@@ -420,13 +445,13 @@ module Gosu
|
|
420
445
|
|
421
446
|
##
|
422
447
|
# Returns an image that is a smaller, rectangular view of this {Image}.
|
423
|
-
#
|
448
|
+
#
|
424
449
|
# This is a very fast operation, and no new textures will be allocated.
|
425
450
|
# If you update this {Image} or the {#subimage} using {#insert}, the other {Image} will be affected as well.
|
426
|
-
#
|
451
|
+
#
|
427
452
|
# Caveats:
|
428
453
|
# * If you stretch or rotate a {#subimage}, the pixels adjacent to it might bleed into it, as Gosu does not manage the 'tileability' of subimages.
|
429
|
-
#
|
454
|
+
#
|
430
455
|
# @return [Image?] an image that represents a portion of the containing image
|
431
456
|
def subimage(left, top, width, height); end
|
432
457
|
|
@@ -450,7 +475,7 @@ module Gosu
|
|
450
475
|
# @see #draw_as_quad
|
451
476
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
452
477
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
453
|
-
def draw(x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
478
|
+
def draw(x, y, z=0, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
454
479
|
|
455
480
|
##
|
456
481
|
# Draws the image rotated, with its rotational center at (x, y).
|
@@ -464,7 +489,7 @@ module Gosu
|
|
464
489
|
# @see #draw
|
465
490
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
466
491
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
467
|
-
def draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
492
|
+
def draw_rot(x, y, z=0, angle=0, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
468
493
|
|
469
494
|
##
|
470
495
|
# Draws the image as an arbitrary quad. This method can be used for advanced non-rectangular drawing techniques, e.g., faking perspective or isometric projection.
|
@@ -576,16 +601,16 @@ module Gosu
|
|
576
601
|
# @param [Float]
|
577
602
|
# @return [Float]
|
578
603
|
attr_writer :volume
|
579
|
-
|
604
|
+
|
580
605
|
##
|
581
606
|
# Sets the playback speed. A value of 2.0 will play the sample at 200% speed and one octave higher. A value of 0.5 will play the sample at 50% speed and one octave lower. The valid range of this property depends on the operating system, but values up to 8.0 should work.
|
582
|
-
# @param [Float]
|
607
|
+
# @param [Float]
|
583
608
|
# @return [Float]
|
584
609
|
attr_writer :speed
|
585
|
-
|
610
|
+
|
586
611
|
##
|
587
612
|
# Set the amount of panning, i.e. the position of the sound when using stereo speakers. 0.0 is the centre, negative values are to the left, positive values are to the right. If something happens on the edge of the screen, a good value for pan would be ±0.1.
|
588
|
-
# @param [Float]
|
613
|
+
# @param [Float]
|
589
614
|
# @return [Float]
|
590
615
|
attr_writer :pan
|
591
616
|
|
@@ -781,11 +806,23 @@ module Gosu
|
|
781
806
|
##
|
782
807
|
# Toggles between windowed mode and fullscreen.
|
783
808
|
attr_writer :fullscreen
|
784
|
-
|
809
|
+
|
785
810
|
##
|
786
811
|
# @return [true, false] whether this window is resizable.
|
787
812
|
def resizable?; end
|
788
813
|
|
814
|
+
##
|
815
|
+
# Toggles between resizable and fixed modes.
|
816
|
+
attr_writer :resizable
|
817
|
+
|
818
|
+
##
|
819
|
+
# @return [true, false] whether this window is borderless.
|
820
|
+
def borderless?; end
|
821
|
+
|
822
|
+
##
|
823
|
+
# Toggles between borderless mode and having window chrome.
|
824
|
+
attr_writer :borderless
|
825
|
+
|
789
826
|
##
|
790
827
|
# @return [Float] the interval between calls to {#update}, in milliseconds.
|
791
828
|
attr_accessor :update_interval
|
@@ -795,7 +832,7 @@ module Gosu
|
|
795
832
|
#
|
796
833
|
# Resizable fullscreen windows always use the full desktop resolution.
|
797
834
|
# Windows that are larger than the desktop resolution will be shrunk.
|
798
|
-
#
|
835
|
+
#
|
799
836
|
# @overload initialize(width, height, options = {})
|
800
837
|
# @overload initialize(width, height, fullscreen, update_interval = 16.666666)
|
801
838
|
#
|
@@ -803,7 +840,8 @@ module Gosu
|
|
803
840
|
# @param height [Integer] the desired window height.
|
804
841
|
# @param [Hash] options
|
805
842
|
# @option options [true, false] :fullscreen (false) whether to present the window in fullscreen mode.
|
806
|
-
# @option options [true, false] :resizable (false) whether the window can be resized by the user.
|
843
|
+
# @option options [true, false] :resizable (false) whether the window can be resized by the user. Not useful if the window is either fullscreen or borderless.
|
844
|
+
# @option options [true, false] :borderless (false) whether the window should hide all its window chrome. Does not affect fullscreen windows.
|
807
845
|
# @option options [Float] :update_interval (16.666666) the interval between frames, in milliseconds.
|
808
846
|
def initialize(width, height, options); end
|
809
847
|
|
@@ -812,18 +850,18 @@ module Gosu
|
|
812
850
|
#
|
813
851
|
# @return [void]
|
814
852
|
def show; end
|
815
|
-
|
853
|
+
|
816
854
|
##
|
817
855
|
# EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
|
818
|
-
#
|
856
|
+
#
|
819
857
|
# Performs a single step in the main loop.
|
820
858
|
# This can be useful for integrating Gosu with other libraries that have their own main loop, e.g. Ruby/Tk.
|
821
|
-
#
|
859
|
+
#
|
822
860
|
# See: https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=1218
|
823
|
-
#
|
861
|
+
#
|
824
862
|
# If you find a good way to use {#tick}, please let us know on the forum and we can make this a part of Gosu's stable interface.
|
825
863
|
# Thank you!
|
826
|
-
#
|
864
|
+
#
|
827
865
|
# @return [true, false] whether the {Window} should still be shown after this tick
|
828
866
|
def tick; end
|
829
867
|
|
@@ -850,7 +888,7 @@ module Gosu
|
|
850
888
|
def draw; end
|
851
889
|
|
852
890
|
##
|
853
|
-
# This method can be
|
891
|
+
# This method can be overridden to give the game a chance to opt out of a call to {#draw}; however, the operating system can still force a redraw for any reason.
|
854
892
|
#
|
855
893
|
# @return [true, false] whether the window needs to be redrawn.
|
856
894
|
#
|
@@ -858,7 +896,8 @@ module Gosu
|
|
858
896
|
def needs_redraw?; end
|
859
897
|
|
860
898
|
##
|
861
|
-
# This method can be
|
899
|
+
# This method can be overridden to control the visibility of the system cursor over your window.
|
900
|
+
# The base class implementation returns true.
|
862
901
|
#
|
863
902
|
# @return [true, false] whether the system cursor should be shown.
|
864
903
|
def needs_cursor?; end
|
@@ -871,7 +910,7 @@ module Gosu
|
|
871
910
|
#
|
872
911
|
# @return [bool]
|
873
912
|
def close; end
|
874
|
-
|
913
|
+
|
875
914
|
##
|
876
915
|
# This method is called before {#update} if a button is pressed while the window has focus.
|
877
916
|
#
|
@@ -903,6 +942,24 @@ module Gosu
|
|
903
942
|
# @param filename [String] the filename of the dropped file. When multiple files are dropped, this method will be called several times.
|
904
943
|
def drop(filename); end
|
905
944
|
|
945
|
+
##
|
946
|
+
# Called when a gamepad is connected.
|
947
|
+
# If a gamepad is momentarily disconnected and then reconnected, before another gamepad, it will have the same index.
|
948
|
+
#
|
949
|
+
# @param index [integer] index for looking up gamepad.
|
950
|
+
#
|
951
|
+
# @see Gosu.gamepad_name
|
952
|
+
def gamepad_connected(index); end
|
953
|
+
|
954
|
+
##
|
955
|
+
# Called when a gamepad is disconnected.
|
956
|
+
#
|
957
|
+
# @param index [integer] index for looking up gamepad.
|
958
|
+
#
|
959
|
+
# @see #gamepad_connected
|
960
|
+
# @see Gosu.gamepad_name
|
961
|
+
def gamepad_disconnected(index); end
|
962
|
+
|
906
963
|
# @!endgroup
|
907
964
|
end
|
908
965
|
|
@@ -945,6 +1002,38 @@ module Gosu
|
|
945
1002
|
# @see Window#button_up
|
946
1003
|
def button_down?(id); end
|
947
1004
|
|
1005
|
+
##
|
1006
|
+
# Returns the name of a Gosu::KB_{*} constant. Returns nil if no name is found.
|
1007
|
+
#
|
1008
|
+
# @example
|
1009
|
+
# Gosu.button_name(Gosu::KB_SPACE) #=> "Space"
|
1010
|
+
#
|
1011
|
+
# @return [String, nil]
|
1012
|
+
# @param id [Integer]
|
1013
|
+
#
|
1014
|
+
def button_name(id); end
|
1015
|
+
|
1016
|
+
##
|
1017
|
+
# Returns the name for gamepad at `index` or nil if there is no connected at the specified index.
|
1018
|
+
#
|
1019
|
+
# @example
|
1020
|
+
# Gosu.gamepad_name(0) #=> "PS4 Controller"
|
1021
|
+
#
|
1022
|
+
# @return [String, nil]
|
1023
|
+
# @param index [Integer]
|
1024
|
+
def gamepad_name(index); end
|
1025
|
+
|
1026
|
+
##
|
1027
|
+
# Returns the value for the specified gamepad axis in the range -1.0..1.0 for joysticks and 0.0..1.0 for triggers.
|
1028
|
+
#
|
1029
|
+
# @example
|
1030
|
+
# Gosu.axis(Gosu::GP_0_LEFT_STICK_Y_AXIS) #=> 0.75
|
1031
|
+
#
|
1032
|
+
# @return [Float]
|
1033
|
+
# @param id [Integer]
|
1034
|
+
#
|
1035
|
+
def axis(id); end
|
1036
|
+
|
948
1037
|
# @!group Drawing primitives
|
949
1038
|
|
950
1039
|
##
|
data/src/Audio.cpp
CHANGED
@@ -1,51 +1,25 @@
|
|
1
1
|
#include "AudioImpl.hpp"
|
2
|
-
#include "
|
2
|
+
#include "AudioFile.hpp"
|
3
|
+
|
3
4
|
#include <Gosu/Audio.hpp>
|
4
5
|
#include <Gosu/Math.hpp>
|
5
6
|
#include <Gosu/IO.hpp>
|
6
7
|
#include <Gosu/Platform.hpp>
|
7
8
|
#include <Gosu/Utility.hpp>
|
9
|
+
|
8
10
|
#include <cassert>
|
9
11
|
#include <cstdlib>
|
10
12
|
#include <algorithm>
|
11
|
-
|
12
|
-
#ifdef GOSU_IS_MAC
|
13
|
-
#import <Foundation/Foundation.h>
|
14
|
-
#include "AudioToolboxFile.hpp"
|
15
|
-
#else
|
16
|
-
#include "MPEGFile.hpp"
|
17
|
-
#include "SndFile.hpp"
|
18
|
-
#endif
|
19
|
-
|
20
|
-
#ifdef GOSU_IS_IPHONE
|
21
|
-
#import <AVFoundation/AVFoundation.h>
|
22
|
-
#endif
|
23
|
-
|
24
13
|
using namespace std;
|
25
14
|
|
26
|
-
static bool is_ogg_file(Gosu::Reader reader)
|
27
|
-
{
|
28
|
-
if (reader.resource().size() < 4) return false;
|
29
|
-
|
30
|
-
char bytes[4];
|
31
|
-
reader.read(bytes, 4);
|
32
|
-
return bytes[0] == 'O' && bytes[1] == 'g' && bytes[2] == 'g' && bytes[3] == 'S';
|
33
|
-
}
|
34
|
-
|
35
|
-
static bool is_ogg_file(const string& filename)
|
36
|
-
{
|
37
|
-
Gosu::File file(filename);
|
38
|
-
return is_ogg_file(file.front_reader());
|
39
|
-
}
|
40
|
-
|
41
15
|
static Gosu::Song* cur_song = nullptr;
|
42
16
|
static bool cur_song_looping;
|
43
17
|
|
44
|
-
struct Gosu::Sample::
|
18
|
+
struct Gosu::Sample::Impl
|
45
19
|
{
|
46
20
|
ALuint buffer;
|
47
21
|
|
48
|
-
|
22
|
+
Impl(AudioFile&& audio_file)
|
49
23
|
{
|
50
24
|
al_initialize();
|
51
25
|
alGenBuffers(1, &buffer);
|
@@ -54,7 +28,7 @@ struct Gosu::Sample::SampleData
|
|
54
28
|
audio_file.sample_rate());
|
55
29
|
}
|
56
30
|
|
57
|
-
~
|
31
|
+
~Impl()
|
58
32
|
{
|
59
33
|
// It's hard to free things in the right order in Ruby/Gosu.
|
60
34
|
// Make sure buffer isn't deleted after the context/device are shut down.
|
@@ -70,43 +44,12 @@ Gosu::Sample::Sample()
|
|
70
44
|
|
71
45
|
Gosu::Sample::Sample(const string& filename)
|
72
46
|
{
|
73
|
-
|
74
|
-
File file(filename);
|
75
|
-
data.reset(new SampleData(OggFile(file.front_reader())));
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
|
79
|
-
#ifdef GOSU_IS_MAC
|
80
|
-
File file(filename);
|
81
|
-
data.reset(new SampleData(AudioToolboxFile(file.front_reader())));
|
82
|
-
#else
|
83
|
-
try {
|
84
|
-
data.reset(new SampleData(SndFile(filename)));
|
85
|
-
}
|
86
|
-
catch (const runtime_error& ex) {
|
87
|
-
File file(filename);
|
88
|
-
data.reset(new SampleData(MPEGFile(file.front_reader())));
|
89
|
-
}
|
90
|
-
#endif
|
47
|
+
pimpl.reset(new Impl(AudioFile(filename)));
|
91
48
|
}
|
92
49
|
|
93
50
|
Gosu::Sample::Sample(Gosu::Reader reader)
|
94
51
|
{
|
95
|
-
|
96
|
-
data.reset(new SampleData(OggFile(reader)));
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
|
100
|
-
#ifdef GOSU_IS_MAC
|
101
|
-
data.reset(new SampleData(AudioToolboxFile(reader)));
|
102
|
-
#else
|
103
|
-
try {
|
104
|
-
data.reset(new SampleData(SndFile(reader)));
|
105
|
-
}
|
106
|
-
catch (const runtime_error& ex) {
|
107
|
-
data.reset(new SampleData(MPEGFile(reader)));
|
108
|
-
}
|
109
|
-
#endif
|
52
|
+
pimpl.reset(new Impl(AudioFile(reader)));
|
110
53
|
}
|
111
54
|
|
112
55
|
Gosu::Channel Gosu::Sample::play(double volume, double speed, bool looping) const
|
@@ -116,7 +59,7 @@ Gosu::Channel Gosu::Sample::play(double volume, double speed, bool looping) cons
|
|
116
59
|
|
117
60
|
Gosu::Channel Gosu::Sample::play_pan(double pan, double volume, double speed, bool looping) const
|
118
61
|
{
|
119
|
-
if (!
|
62
|
+
if (!pimpl) return Channel();
|
120
63
|
|
121
64
|
Channel channel = allocate_channel();
|
122
65
|
|
@@ -124,7 +67,7 @@ Gosu::Channel Gosu::Sample::play_pan(double pan, double volume, double speed, bo
|
|
124
67
|
if (channel.current_channel() == NO_CHANNEL) return channel;
|
125
68
|
|
126
69
|
ALuint source = al_source_for_channel(channel.current_channel());
|
127
|
-
alSourcei(source, AL_BUFFER,
|
70
|
+
alSourcei(source, AL_BUFFER, pimpl->buffer);
|
128
71
|
alSource3f(source, AL_POSITION, pan * 10, 0, 0);
|
129
72
|
alSourcef(source, AL_GAIN, max(volume, 0.0));
|
130
73
|
alSourcef(source, AL_PITCH, speed);
|
@@ -133,112 +76,22 @@ Gosu::Channel Gosu::Sample::play_pan(double pan, double volume, double speed, bo
|
|
133
76
|
return channel;
|
134
77
|
}
|
135
78
|
|
136
|
-
class Gosu::Song::BaseData
|
137
|
-
{
|
138
|
-
BaseData(const BaseData&) = delete;
|
139
|
-
BaseData& operator=(const BaseData&) = delete;
|
140
|
-
|
141
|
-
double volume_;
|
142
|
-
|
143
|
-
protected:
|
144
|
-
BaseData() : volume_(1) {}
|
145
|
-
virtual void apply_volume() = 0;
|
146
|
-
|
147
|
-
public:
|
148
|
-
virtual ~BaseData() {}
|
149
|
-
virtual void play(bool looping) = 0;
|
150
|
-
virtual void pause() = 0;
|
151
|
-
virtual void resume() = 0;
|
152
|
-
virtual bool paused() const = 0;
|
153
|
-
virtual void stop() = 0;
|
154
|
-
virtual void update() = 0;
|
155
|
-
|
156
|
-
double volume() const
|
157
|
-
{
|
158
|
-
return volume_;
|
159
|
-
}
|
160
|
-
|
161
|
-
void set_volume(double volume)
|
162
|
-
{
|
163
|
-
volume_ = clamp(volume, 0.0, 1.0);
|
164
|
-
apply_volume();
|
165
|
-
}
|
166
|
-
};
|
167
|
-
|
168
|
-
#ifdef GOSU_IS_IPHONE
|
169
|
-
// AVAudioPlayer impl
|
170
|
-
class Gosu::Song::ModuleData : public BaseData
|
171
|
-
{
|
172
|
-
AVAudioPlayer* player;
|
173
|
-
|
174
|
-
void apply_volume() override
|
175
|
-
{
|
176
|
-
player.volume = volume();
|
177
|
-
}
|
178
|
-
|
179
|
-
public:
|
180
|
-
ModuleData(const string& filename)
|
181
|
-
{
|
182
|
-
NSURL* URL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:filename.c_str()]];
|
183
|
-
player = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:nil];
|
184
|
-
}
|
185
|
-
|
186
|
-
void play(bool looping) override
|
187
|
-
{
|
188
|
-
if (paused()) {
|
189
|
-
stop();
|
190
|
-
}
|
191
|
-
player.numberOfLoops = looping ? -1 : 0;
|
192
|
-
[player play];
|
193
|
-
}
|
194
|
-
|
195
|
-
void pause() override
|
196
|
-
{
|
197
|
-
[player pause];
|
198
|
-
}
|
199
|
-
|
200
|
-
void resume() override
|
201
|
-
{
|
202
|
-
[player play];
|
203
|
-
}
|
204
|
-
|
205
|
-
bool paused() const override
|
206
|
-
{
|
207
|
-
return !player.playing;
|
208
|
-
}
|
209
|
-
|
210
|
-
void stop() override
|
211
|
-
{
|
212
|
-
[player stop];
|
213
|
-
player.currentTime = 0;
|
214
|
-
}
|
215
|
-
|
216
|
-
void update() override
|
217
|
-
{
|
218
|
-
}
|
219
|
-
};
|
220
|
-
#endif
|
221
|
-
|
222
79
|
// AudioFile impl
|
223
|
-
|
80
|
+
struct Gosu::Song::Impl
|
224
81
|
{
|
82
|
+
double volume_ = 1.0;
|
225
83
|
unique_ptr<AudioFile> file;
|
226
84
|
ALuint buffers[2];
|
227
85
|
|
228
|
-
void apply_volume()
|
86
|
+
void apply_volume()
|
229
87
|
{
|
230
88
|
alSourcef(al_source_for_songs(), AL_GAIN, max(volume(), 0.0));
|
231
89
|
}
|
232
90
|
|
233
91
|
bool stream_to_buffer(ALuint buffer)
|
234
92
|
{
|
235
|
-
|
236
|
-
|
237
|
-
#else
|
238
|
-
static const unsigned BUFFER_SIZE = 4096 * 8;
|
239
|
-
#endif
|
240
|
-
char audio_data[BUFFER_SIZE];
|
241
|
-
size_t read_bytes = file->read_data(audio_data, BUFFER_SIZE);
|
93
|
+
char audio_data[4096 * 8];
|
94
|
+
size_t read_bytes = file->read_data(audio_data, sizeof audio_data);
|
242
95
|
if (read_bytes > 0) {
|
243
96
|
alBufferData(buffer, file->format(), audio_data,
|
244
97
|
static_cast<ALsizei>(read_bytes), file->sample_rate());
|
@@ -247,53 +100,23 @@ class Gosu::Song::StreamData : public BaseData
|
|
247
100
|
}
|
248
101
|
|
249
102
|
public:
|
250
|
-
|
103
|
+
explicit Impl(const string& filename)
|
251
104
|
{
|
252
|
-
|
253
|
-
|
254
|
-
file.reset(new OggFile(source_file.front_reader()));
|
255
|
-
}
|
256
|
-
else {
|
257
|
-
#ifdef GOSU_IS_MAC
|
258
|
-
file.reset(new AudioToolboxFile(filename));
|
259
|
-
#else
|
260
|
-
try {
|
261
|
-
file.reset(new SndFile(filename));
|
262
|
-
}
|
263
|
-
catch (const runtime_error& ex) {
|
264
|
-
File source_file(filename);
|
265
|
-
file.reset(new MPEGFile(source_file.front_reader()));
|
266
|
-
}
|
267
|
-
#endif
|
268
|
-
}
|
269
|
-
|
105
|
+
file.reset(new AudioFile(filename));
|
106
|
+
|
270
107
|
al_initialize();
|
271
108
|
alGenBuffers(2, buffers);
|
272
109
|
}
|
273
110
|
|
274
|
-
|
111
|
+
explicit Impl(Reader reader)
|
275
112
|
{
|
276
|
-
|
277
|
-
|
278
|
-
}
|
279
|
-
else {
|
280
|
-
#ifdef GOSU_IS_MAC
|
281
|
-
file.reset(new AudioToolboxFile(reader));
|
282
|
-
#else
|
283
|
-
try {
|
284
|
-
file.reset(new SndFile(reader));
|
285
|
-
}
|
286
|
-
catch (const runtime_error& ex) {
|
287
|
-
file.reset(new MPEGFile(reader));
|
288
|
-
}
|
289
|
-
#endif
|
290
|
-
}
|
291
|
-
|
113
|
+
file.reset(new AudioFile(reader));
|
114
|
+
|
292
115
|
al_initialize();
|
293
116
|
alGenBuffers(2, buffers);
|
294
117
|
}
|
295
118
|
|
296
|
-
~
|
119
|
+
~Impl()
|
297
120
|
{
|
298
121
|
// It's hard to free things in the right order in Ruby/Gosu.
|
299
122
|
// Make sure buffers aren't deleted after the context/device are shut down.
|
@@ -302,7 +125,7 @@ public:
|
|
302
125
|
alDeleteBuffers(2, buffers);
|
303
126
|
}
|
304
127
|
|
305
|
-
void play(bool looping)
|
128
|
+
void play(bool looping)
|
306
129
|
{
|
307
130
|
ALuint source = al_source_for_songs();
|
308
131
|
|
@@ -319,7 +142,7 @@ public:
|
|
319
142
|
alSourcePlay(source);
|
320
143
|
}
|
321
144
|
|
322
|
-
void stop()
|
145
|
+
void stop()
|
323
146
|
{
|
324
147
|
ALuint source = al_source_for_songs();
|
325
148
|
|
@@ -338,24 +161,24 @@ public:
|
|
338
161
|
file->rewind();
|
339
162
|
}
|
340
163
|
|
341
|
-
void pause()
|
164
|
+
void pause()
|
342
165
|
{
|
343
166
|
alSourcePause(al_source_for_songs());
|
344
167
|
}
|
345
168
|
|
346
|
-
void resume()
|
169
|
+
void resume()
|
347
170
|
{
|
348
171
|
alSourcePlay(al_source_for_songs());
|
349
172
|
}
|
350
173
|
|
351
|
-
bool paused() const
|
174
|
+
bool paused() const
|
352
175
|
{
|
353
176
|
ALint state;
|
354
177
|
alGetSourcei(al_source_for_songs(), AL_SOURCE_STATE, &state);
|
355
178
|
return state == AL_PAUSED;
|
356
179
|
}
|
357
180
|
|
358
|
-
void update()
|
181
|
+
void update()
|
359
182
|
{
|
360
183
|
ALuint source = al_source_for_songs();
|
361
184
|
|
@@ -390,24 +213,27 @@ public:
|
|
390
213
|
}
|
391
214
|
}
|
392
215
|
}
|
216
|
+
|
217
|
+
double volume() const
|
218
|
+
{
|
219
|
+
return volume_;
|
220
|
+
}
|
221
|
+
|
222
|
+
void set_volume(double volume)
|
223
|
+
{
|
224
|
+
volume_ = clamp(volume, 0.0, 1.0);
|
225
|
+
apply_volume();
|
226
|
+
}
|
393
227
|
};
|
394
228
|
|
395
229
|
Gosu::Song::Song(const string& filename)
|
396
230
|
{
|
397
|
-
|
398
|
-
if (has_extension(filename, ".mp3") ||
|
399
|
-
has_extension(filename, ".aac") ||
|
400
|
-
has_extension(filename, ".m4a")) {
|
401
|
-
data.reset(new ModuleData(filename));
|
402
|
-
return;
|
403
|
-
}
|
404
|
-
#endif
|
405
|
-
data.reset(new StreamData(filename));
|
231
|
+
pimpl.reset(new Impl(filename));
|
406
232
|
}
|
407
233
|
|
408
234
|
Gosu::Song::Song(Reader reader)
|
409
235
|
{
|
410
|
-
|
236
|
+
pimpl.reset(new Impl(reader));
|
411
237
|
}
|
412
238
|
|
413
239
|
Gosu::Song::~Song()
|
@@ -423,7 +249,7 @@ Gosu::Song* Gosu::Song::current_song()
|
|
423
249
|
void Gosu::Song::play(bool looping)
|
424
250
|
{
|
425
251
|
if (paused()) {
|
426
|
-
|
252
|
+
pimpl->resume();
|
427
253
|
}
|
428
254
|
|
429
255
|
if (cur_song && cur_song != this) {
|
@@ -432,7 +258,7 @@ void Gosu::Song::play(bool looping)
|
|
432
258
|
}
|
433
259
|
|
434
260
|
if (cur_song == nullptr) {
|
435
|
-
|
261
|
+
pimpl->play(looping);
|
436
262
|
}
|
437
263
|
|
438
264
|
cur_song = this;
|
@@ -442,41 +268,41 @@ void Gosu::Song::play(bool looping)
|
|
442
268
|
void Gosu::Song::pause()
|
443
269
|
{
|
444
270
|
if (cur_song == this) {
|
445
|
-
|
271
|
+
pimpl->pause();
|
446
272
|
}
|
447
273
|
}
|
448
274
|
|
449
275
|
bool Gosu::Song::paused() const
|
450
276
|
{
|
451
|
-
return cur_song == this &&
|
277
|
+
return cur_song == this && pimpl->paused();
|
452
278
|
}
|
453
279
|
|
454
280
|
void Gosu::Song::stop()
|
455
281
|
{
|
456
282
|
if (cur_song == this) {
|
457
|
-
|
283
|
+
pimpl->stop();
|
458
284
|
cur_song = nullptr;
|
459
285
|
}
|
460
286
|
}
|
461
287
|
|
462
288
|
bool Gosu::Song::playing() const
|
463
289
|
{
|
464
|
-
return cur_song == this && !
|
290
|
+
return cur_song == this && !pimpl->paused();
|
465
291
|
}
|
466
292
|
|
467
293
|
double Gosu::Song::volume() const
|
468
294
|
{
|
469
|
-
return
|
295
|
+
return pimpl->volume();
|
470
296
|
}
|
471
297
|
|
472
298
|
void Gosu::Song::set_volume(double volume)
|
473
299
|
{
|
474
|
-
|
300
|
+
pimpl->set_volume(volume);
|
475
301
|
}
|
476
302
|
|
477
303
|
void Gosu::Song::update()
|
478
304
|
{
|
479
305
|
if (current_song()) {
|
480
|
-
current_song()->
|
306
|
+
current_song()->pimpl->update();
|
481
307
|
}
|
482
308
|
}
|