gosu 1.3.0 → 1.4.0
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 +108 -14
- data/dependencies/SDL/include/SDL_assert.h +81 -50
- data/dependencies/SDL/include/SDL_atomic.h +135 -35
- data/dependencies/SDL/include/SDL_audio.h +960 -355
- data/dependencies/SDL/include/SDL_bits.h +11 -6
- data/dependencies/SDL/include/SDL_blendmode.h +91 -14
- data/dependencies/SDL/include/SDL_clipboard.h +30 -7
- data/dependencies/SDL/include/SDL_config.h +277 -27
- data/dependencies/SDL/include/SDL_config_android.h +13 -38
- data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
- data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
- data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
- data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
- data/dependencies/SDL/include/SDL_config_psp.h +16 -37
- data/dependencies/SDL/include/SDL_config_windows.h +28 -91
- data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
- data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
- data/dependencies/SDL/include/SDL_copying.h +1 -1
- data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
- data/dependencies/SDL/include/SDL_egl.h +906 -280
- data/dependencies/SDL/include/SDL_endian.h +101 -47
- data/dependencies/SDL/include/SDL_error.h +70 -19
- data/dependencies/SDL/include/SDL_events.h +387 -79
- data/dependencies/SDL/include/SDL_filesystem.h +73 -64
- data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
- data/dependencies/SDL/include/SDL_gesture.h +36 -6
- data/dependencies/SDL/include/SDL_haptic.h +304 -210
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +1286 -897
- data/dependencies/SDL/include/SDL_joystick.h +577 -130
- data/dependencies/SDL/include/SDL_keyboard.h +162 -63
- data/dependencies/SDL/include/SDL_keycode.h +7 -5
- data/dependencies/SDL/include/SDL_loadso.h +42 -8
- data/dependencies/SDL/include/SDL_locale.h +34 -32
- data/dependencies/SDL/include/SDL_log.h +212 -19
- data/dependencies/SDL/include/SDL_main.h +72 -17
- data/dependencies/SDL/include/SDL_messagebox.h +70 -23
- data/dependencies/SDL/include/SDL_metal.h +27 -32
- data/dependencies/SDL/include/SDL_misc.h +19 -15
- data/dependencies/SDL/include/SDL_mouse.h +262 -110
- data/dependencies/SDL/include/SDL_mutex.h +286 -66
- data/dependencies/SDL/include/SDL_name.h +1 -1
- data/dependencies/SDL/include/SDL_opengl.h +1 -1
- data/dependencies/SDL/include/SDL_opengles.h +1 -1
- data/dependencies/SDL/include/SDL_opengles2.h +2 -2
- data/dependencies/SDL/include/SDL_pixels.h +199 -34
- data/dependencies/SDL/include/SDL_platform.h +39 -2
- data/dependencies/SDL/include/SDL_power.h +23 -10
- data/dependencies/SDL/include/SDL_quit.h +1 -1
- data/dependencies/SDL/include/SDL_rect.h +78 -28
- data/dependencies/SDL/include/SDL_render.h +1204 -472
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_rwops.h +605 -33
- data/dependencies/SDL/include/SDL_scancode.h +1 -1
- data/dependencies/SDL/include/SDL_sensor.h +76 -42
- data/dependencies/SDL/include/SDL_shape.h +38 -27
- data/dependencies/SDL/include/SDL_stdinc.h +96 -24
- data/dependencies/SDL/include/SDL_surface.h +571 -139
- data/dependencies/SDL/include/SDL_system.h +339 -101
- data/dependencies/SDL/include/SDL_syswm.h +50 -20
- data/dependencies/SDL/include/SDL_test.h +1 -1
- data/dependencies/SDL/include/SDL_test_assert.h +2 -2
- data/dependencies/SDL/include/SDL_test_common.h +23 -6
- data/dependencies/SDL/include/SDL_test_compare.h +1 -1
- data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
- data/dependencies/SDL/include/SDL_test_font.h +3 -3
- data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
- data/dependencies/SDL/include/SDL_test_harness.h +6 -6
- data/dependencies/SDL/include/SDL_test_images.h +1 -1
- data/dependencies/SDL/include/SDL_test_log.h +1 -1
- data/dependencies/SDL/include/SDL_test_md5.h +1 -1
- data/dependencies/SDL/include/SDL_test_memory.h +1 -1
- data/dependencies/SDL/include/SDL_test_random.h +2 -2
- data/dependencies/SDL/include/SDL_thread.h +226 -128
- data/dependencies/SDL/include/SDL_timer.h +129 -22
- data/dependencies/SDL/include/SDL_touch.h +48 -8
- data/dependencies/SDL/include/SDL_types.h +1 -1
- data/dependencies/SDL/include/SDL_version.h +72 -46
- data/dependencies/SDL/include/SDL_video.h +1266 -460
- data/dependencies/SDL/include/SDL_vulkan.h +100 -161
- data/dependencies/SDL/include/begin_code.h +22 -1
- data/dependencies/SDL/include/close_code.h +1 -1
- 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 +83 -7
- data/dependencies/SDL_sound/SDL_sound.h +4 -4
- data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
- data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
- data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
- data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
- data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
- data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
- data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
- data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
- data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
- data/dependencies/SDL_sound/dr_flac.h +618 -220
- data/dependencies/SDL_sound/dr_mp3.h +263 -94
- data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
- data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
- data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
- data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
- data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
- data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
- data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
- data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
- data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
- data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
- data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
- data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
- data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
- data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
- data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
- data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
- data/dependencies/SDL_sound/stb_vorbis.h +508 -325
- data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
- data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
- data/dependencies/mojoAL/mojoal.c +4594 -0
- data/ext/gosu/extconf.rb +29 -30
- data/include/Gosu/Audio.hpp +70 -85
- data/include/Gosu/Color.hpp +19 -11
- data/include/Gosu/Font.hpp +40 -44
- data/include/Gosu/Graphics.hpp +58 -71
- data/include/Gosu/GraphicsBase.hpp +26 -33
- data/include/Gosu/Image.hpp +56 -62
- data/include/Gosu/ImageData.hpp +23 -27
- data/include/Gosu/Inspection.hpp +1 -4
- data/include/Gosu/TextInput.hpp +34 -40
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +71 -70
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/compat.rb +24 -37
- data/lib/gosu.rb +2 -2
- data/lib64/SDL2.dll +0 -0
- data/src/Audio.cpp +86 -86
- data/src/AudioFile.hpp +6 -6
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.hpp +5 -5
- data/src/BitmapIO.cpp +0 -20
- data/src/BlockAllocator.cpp +2 -1
- data/src/Channel.cpp +22 -20
- data/src/Color.cpp +12 -9
- data/src/EmptyImageData.hpp +15 -17
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +48 -53
- data/src/Graphics.cpp +135 -143
- data/src/Image.cpp +41 -42
- data/src/Input.cpp +1 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/LargeImageData.cpp +108 -101
- data/src/LargeImageData.hpp +17 -15
- data/src/Log.hpp +6 -6
- data/src/Macro.cpp +35 -37
- data/src/Macro.hpp +11 -11
- data/src/Math.cpp +8 -1
- data/src/Resolution.cpp +12 -7
- data/src/RubyGosu.cxx +5 -5
- data/src/TexChunk.cpp +50 -41
- data/src/TexChunk.hpp +22 -22
- data/src/Text.cpp +37 -37
- data/src/TextBuilder.cpp +60 -57
- data/src/TextBuilder.hpp +20 -20
- data/src/TextInput.cpp +127 -135
- data/src/TrueTypeFont.cpp +107 -107
- data/src/TrueTypeFont.hpp +39 -38
- data/src/TrueTypeFontApple.cpp +19 -22
- data/src/TrueTypeFontUnix.cpp +21 -26
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Window.cpp +95 -86
- data/src/WindowUIKit.cpp +46 -49
- metadata +7 -17
- data/dependencies/SDL/include/SDL_config_os2.h +0 -188
- data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
- data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
- data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
- data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
- data/dependencies/al_soft/AL/alext.h +0 -585
- data/dependencies/al_soft/AL/efx-creative.h +0 -3
- data/dependencies/al_soft/AL/efx-presets.h +0 -402
- data/dependencies/al_soft/AL/efx.h +0 -762
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
data/ext/gosu/extconf.rb
CHANGED
@@ -8,17 +8,17 @@ when /^darwin/
|
|
8
8
|
end
|
9
9
|
|
10
10
|
if not windows
|
11
|
-
puts
|
12
|
-
puts
|
11
|
+
puts "The Gosu gem requires some libraries to be installed system-wide."
|
12
|
+
puts "See the following site for a list:"
|
13
13
|
if macos
|
14
|
-
puts
|
14
|
+
puts "https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X"
|
15
15
|
else
|
16
|
-
puts
|
16
|
+
puts "https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
20
|
+
require "mkmf"
|
21
|
+
require "fileutils"
|
22
22
|
|
23
23
|
# Silence internal deprecation warnings in Gosu.
|
24
24
|
$CFLAGS << " -DGOSU_DEPRECATED="
|
@@ -33,25 +33,25 @@ $CXXFLAGS ||= ""
|
|
33
33
|
$CXXFLAGS << " -std=gnu++17 -Dregister="
|
34
34
|
|
35
35
|
# Make Gosu's own header files and all of its dependencies available to C++ source files.
|
36
|
-
$INCFLAGS << " -I../../include -I../../dependencies/stb -I../../dependencies/utf8proc -I../../dependencies/SDL_sound"
|
36
|
+
$INCFLAGS << " -I../../include -I../../dependencies/stb -I../../dependencies/utf8proc -I../../dependencies/SDL_sound -I../../dependencies/mojoAL"
|
37
37
|
|
38
38
|
if windows
|
39
39
|
# We statically compile utf8proc into the Gosu binary.
|
40
40
|
# This macro is required to avoid errors about dllexport/dllimport mismatches.
|
41
|
-
$CFLAGS << " -DUTF8PROC_STATIC"
|
42
|
-
$CXXFLAGS << " -DUTF8PROC_STATIC"
|
41
|
+
$CFLAGS << " -DUTF8PROC_STATIC -DAL_LIBTYPE_STATIC"
|
42
|
+
$CXXFLAGS << " -DUTF8PROC_STATIC -DAL_LIBTYPE_STATIC"
|
43
43
|
|
44
44
|
# Define UNICODE to use the Unicode-aware variants of all Win32 API functions.
|
45
45
|
$CXXFLAGS << " -DUNICODE"
|
46
46
|
|
47
47
|
# Use the bundled versions of SDL 2 and open_al.
|
48
|
-
$INCFLAGS << " -I../../dependencies/
|
49
|
-
if RbConfig::CONFIG[
|
50
|
-
$LDFLAGS << " -L../../dependencies/
|
48
|
+
$INCFLAGS << " -I../../dependencies/SDL/include"
|
49
|
+
if RbConfig::CONFIG["arch"] =~ /x64-/
|
50
|
+
$LDFLAGS << " -L../../dependencies/SDL/lib/x64"
|
51
51
|
else
|
52
|
-
$LDFLAGS << " -L../../dependencies/
|
52
|
+
$LDFLAGS << " -L../../dependencies/SDL/lib/x86"
|
53
53
|
end
|
54
|
-
$LDFLAGS << " -lgdi32 -lwinmm -ldwmapi -lOpenGL32 -
|
54
|
+
$LDFLAGS << " -lgdi32 -lwinmm -ldwmapi -lOpenGL32 -lSDL2"
|
55
55
|
# Link libstdc++ statically to avoid having another DLL dependency when using Ocra.
|
56
56
|
$LDFLAGS << " -static-libstdc++"
|
57
57
|
elsif macos
|
@@ -66,49 +66,48 @@ elsif macos
|
|
66
66
|
# Disable an error that is disabled by default and prevents Gosu from building with universal Ruby:
|
67
67
|
# https://trac.macports.org/ticket/58255 / https://github.com/gosu/gosu/issues/424
|
68
68
|
$CXXFLAGS << " -Wno-reserved-user-defined-literal"
|
69
|
-
|
69
|
+
|
70
70
|
# Dependencies.
|
71
71
|
$CFLAGS << " #{`sdl2-config --cflags`.chomp}"
|
72
72
|
$CXXFLAGS << " #{`sdl2-config --cflags`.chomp}"
|
73
73
|
# Prefer statically linking SDL 2.
|
74
|
-
$LDFLAGS
|
74
|
+
$LDFLAGS << " #{`sdl2-config --static-libs`.chomp} -framework OpenGL -framework Metal"
|
75
75
|
# And yet another hack: `sdl2-config --static-libs` uses `-lSDL2` instead of linking to the static library,
|
76
76
|
# even if it exists. -> Manually replace it. (Ugh!)
|
77
|
-
|
78
|
-
|
77
|
+
%w(/usr/local/lib/libSDL2.a /opt/homebrew/opt/sdl2/lib/libSDL2.a).each do |static_lib|
|
78
|
+
$LDFLAGS.sub! " -lSDL2 ", " #{static_lib} " if File.exist? static_lib
|
79
|
+
end
|
80
|
+
|
79
81
|
# Disable building of 32-bit slices in Apple's Ruby.
|
80
82
|
# (RbConfig::CONFIG['CXXFLAGS'] on 10.11: -arch x86_64 -arch i386 -g -Os -pipe)
|
81
83
|
$CFLAGS.gsub! "-arch i386", ""
|
82
84
|
$CXXFLAGS.gsub! "-arch i386", ""
|
83
85
|
$LDFLAGS.gsub! "-arch i386", ""
|
84
86
|
$ARCH_FLAG.gsub! "-arch i386", ""
|
85
|
-
CONFIG[
|
87
|
+
CONFIG["LDSHARED"].gsub! "-arch i386", ""
|
86
88
|
else
|
87
89
|
if /BCM2708/ =~ `cat /proc/cpuinfo`
|
88
90
|
$INCFLAGS << " -I/opt/vc/include/GLES"
|
89
91
|
$INCFLAGS << " -I/opt/vc/include"
|
90
92
|
$LDFLAGS << " -L/opt/vc/lib"
|
91
93
|
$LDFLAGS << " -lGLESv1_CM"
|
92
|
-
$CFLAGS
|
94
|
+
$CFLAGS << " -DGOSU_IS_OPENGLES"
|
93
95
|
$CXXFLAGS << " -DGOSU_IS_OPENGLES"
|
94
96
|
else
|
95
|
-
pkg_config
|
97
|
+
pkg_config "gl"
|
96
98
|
end
|
97
99
|
|
98
|
-
pkg_config
|
99
|
-
pkg_config
|
100
|
-
pkg_config
|
101
|
-
pkg_config
|
102
|
-
pkg_config
|
103
|
-
pkg_config 'fontconfig'
|
104
|
-
|
105
|
-
have_header 'AL/al.h' if have_library('openal')
|
100
|
+
pkg_config "sdl2"
|
101
|
+
pkg_config "vorbisfile"
|
102
|
+
pkg_config "sndfile"
|
103
|
+
pkg_config "libmpg123"
|
104
|
+
pkg_config "fontconfig"
|
106
105
|
end
|
107
106
|
|
108
107
|
# Because Ruby will only compile source file in the src/ folder, but our dependencies are
|
109
108
|
# stored in dependencies/, we need to create symlinks for all the .c files. This is terrible,
|
110
109
|
# but still seems better than putting everything into the same folder to begin with.
|
111
|
-
Dir.glob(
|
110
|
+
Dir.glob("../../dependencies/**/*.c").each do |dep|
|
112
111
|
File.open("../../src/#{File.basename dep}", "w") do |shim|
|
113
112
|
shim.puts "#include \"#{File.expand_path dep}\""
|
114
113
|
end
|
data/include/Gosu/Audio.hpp
CHANGED
@@ -1,141 +1,126 @@
|
|
1
|
-
//! \file Audio.hpp
|
2
|
-
//! Contains all the classes of Gosu's audio system.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
#include <Gosu/Fwd.hpp>
|
7
4
|
#include <Gosu/IO.hpp>
|
8
5
|
#include <Gosu/Platform.hpp>
|
6
|
+
#include <Gosu/Utility.hpp>
|
9
7
|
#include <memory>
|
10
8
|
#include <string>
|
11
9
|
|
12
10
|
namespace Gosu
|
13
11
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
/// Sample::play returns a Channel that represents the sound being played.
|
13
|
+
/// This object can be used to stop or influence sounds as they are played, or to check whether
|
14
|
+
/// playback has finished.
|
17
15
|
class Channel
|
18
16
|
{
|
19
|
-
mutable int
|
17
|
+
mutable int m_channel, m_token;
|
20
18
|
|
21
19
|
public:
|
22
|
-
|
20
|
+
/// This creates an "empty" Channel which is expired and cannot be resumed.
|
23
21
|
Channel();
|
24
|
-
|
22
|
+
/// For internal use only.
|
25
23
|
Channel(int channel, int token);
|
26
|
-
|
27
|
-
|
24
|
+
|
25
|
+
/// For internal use only.
|
28
26
|
int current_channel() const;
|
29
|
-
|
27
|
+
|
30
28
|
bool playing() const;
|
31
29
|
bool paused() const;
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
/// Pauses this instance to be resumed afterwards.
|
31
|
+
/// Avoid leaving samples paused for too long, as they will still occupy one of Gosu's
|
32
|
+
/// limited channels.
|
35
33
|
void pause();
|
36
34
|
void resume();
|
37
|
-
|
38
|
-
|
35
|
+
/// Stops this m_channel if the sample is still being played.
|
36
|
+
/// If this method is called when playback has finished, it has no effect.
|
39
37
|
void stop();
|
40
38
|
|
41
|
-
|
39
|
+
/// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
|
42
40
|
void set_volume(double volume);
|
43
|
-
|
41
|
+
/// @param pan Can be anything from -1.0 (left) to 1.0 (right).
|
44
42
|
void set_pan(double pan);
|
45
|
-
|
43
|
+
/// @param speed Use 1.0 for normal playback speed.
|
46
44
|
void set_speed(double speed);
|
47
45
|
};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
//! parameters. Use samples for everything that's not music.
|
46
|
+
|
47
|
+
/// A sample is a short sound that is completely loaded in memory, can be played multiple times
|
48
|
+
/// at once, and offers very flexible playback parameters.
|
52
49
|
class Sample
|
53
50
|
{
|
54
51
|
struct Impl;
|
55
|
-
std::shared_ptr<Impl>
|
52
|
+
std::shared_ptr<Impl> m_impl;
|
56
53
|
|
57
54
|
public:
|
58
|
-
|
55
|
+
/// Constructs an empty sample that is inaudible when played.
|
59
56
|
Sample();
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
|
58
|
+
/// Constructs a sample that can be played on the specified audio
|
59
|
+
/// system and loads the sample from a file.
|
63
60
|
explicit Sample(const std::string& filename);
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
|
62
|
+
/// Constructs a sample that can be played on the specified audio
|
63
|
+
/// system and loads the sample data from a stream.
|
67
64
|
explicit Sample(Reader reader);
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
//! and can accept very high
|
85
|
-
//! or low values. Use 1.0 for normal playback speed.
|
86
|
-
Channel play_pan(double pan, double volume = 1, double speed = 1,
|
87
|
-
bool looping = false) const;
|
65
|
+
|
66
|
+
/// Plays the sample without panning.
|
67
|
+
/// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
|
68
|
+
/// @param speed Playback speed is only limited by the underlying audio library,
|
69
|
+
/// and can accept very high or low values. Use 1.0 for normal playback speed.
|
70
|
+
Channel play(double volume = 1.0, double speed = 1.0, bool looping = false) const;
|
71
|
+
|
72
|
+
/// Plays the sample with panning. Even if pan is 0.0, the sample will
|
73
|
+
/// not be as loud as if it were played by calling play() due to the
|
74
|
+
/// way the panning works.
|
75
|
+
/// @param pan Can be anything from -1.0 (left) to 1.0 (right).
|
76
|
+
/// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
|
77
|
+
/// @param speed Playback speed is only limited by by the underlying audio library,
|
78
|
+
/// and can accept very high or low values. Use 1.0 for normal playback speed.
|
79
|
+
Channel play_pan(double pan, double volume = 1.0, double speed = 1.0,
|
80
|
+
bool looping = false) const;
|
88
81
|
};
|
89
82
|
|
90
|
-
|
91
|
-
|
92
|
-
class Song
|
83
|
+
/// Songs are less flexible than Samples. Only one Song can be played at any given time,
|
84
|
+
/// and there is no way to control its pan (stereo position) or speed.
|
85
|
+
class Song : private Noncopyable
|
93
86
|
{
|
94
87
|
struct Impl;
|
95
|
-
std::unique_ptr<Impl>
|
96
|
-
|
97
|
-
// Non-movable to avoid dangling internal references.
|
98
|
-
Song(Song&&) = delete;
|
99
|
-
// Non-movable to avoid dangling internal references.
|
100
|
-
Song& operator=(Song&&) = delete;
|
88
|
+
std::unique_ptr<Impl> m_impl;
|
101
89
|
|
102
90
|
public:
|
103
|
-
|
104
|
-
|
105
|
-
//! The file type is determined by the filename.
|
91
|
+
/// Constructs a song that can be played on the provided audio system and loads the song
|
92
|
+
/// from a file. The file type is determined by the filename.
|
106
93
|
explicit Song(const std::string& filename);
|
107
|
-
|
108
|
-
|
109
|
-
|
94
|
+
|
95
|
+
/// Constructs a song of the specified type that can be played on the
|
96
|
+
/// provided audio system and loads the song data from a stream.
|
110
97
|
explicit Song(Reader reader);
|
111
|
-
|
98
|
+
|
112
99
|
~Song();
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
//! playing.
|
100
|
+
|
101
|
+
/// Returns the song currently being played or paused, or 0 if no song has been played yet
|
102
|
+
/// or the last song has finished playing.
|
117
103
|
static Song* current_song();
|
118
104
|
|
119
|
-
|
120
|
-
|
105
|
+
/// Starts or resumes playback of the song. This will stop all other songs and set the
|
106
|
+
/// current song to this object.
|
121
107
|
void play(bool looping = false);
|
122
|
-
|
123
|
-
|
108
|
+
/// Pauses playback of the song. Song::current_song() will still refer to this song, but
|
109
|
+
/// playing() will return false.
|
124
110
|
void pause();
|
125
|
-
|
126
|
-
//! mode.
|
111
|
+
/// Returns true if the song is the current song, but in paused mode.
|
127
112
|
bool paused() const;
|
128
|
-
|
129
|
-
|
113
|
+
/// Stops playback of this song if it is currently played or paused.
|
114
|
+
/// Afterwards, current_song will return nullptr.
|
130
115
|
void stop();
|
131
|
-
|
116
|
+
/// Returns true if the song is currently playing.
|
132
117
|
bool playing() const;
|
133
|
-
|
118
|
+
/// Returns the current volume of the song.
|
134
119
|
double volume() const;
|
135
|
-
|
120
|
+
/// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
|
136
121
|
void set_volume(double volume);
|
137
|
-
|
138
|
-
|
122
|
+
|
123
|
+
/// Called every tick by Window to feed new audio data to OpenAL.
|
139
124
|
static void update();
|
140
125
|
};
|
141
126
|
}
|
data/include/Gosu/Color.hpp
CHANGED
@@ -16,20 +16,28 @@ namespace Gosu
|
|
16
16
|
Channel red, green, blue, alpha;
|
17
17
|
|
18
18
|
constexpr Color()
|
19
|
-
: red{0},
|
19
|
+
: red{0},
|
20
|
+
green{0},
|
21
|
+
blue{0},
|
22
|
+
alpha{0}
|
20
23
|
{
|
21
24
|
}
|
22
25
|
|
23
26
|
/// Conversion constructor for literals of the form 0xaarrggbb.
|
24
27
|
// NOLINTNEXTLINE: We want to allow implicit conversions.
|
25
28
|
constexpr Color(std::uint32_t argb)
|
26
|
-
: red{static_cast<Channel>(argb >> 16)},
|
27
|
-
|
29
|
+
: red{static_cast<Channel>(argb >> 16)},
|
30
|
+
green{static_cast<Channel>(argb >> 8)},
|
31
|
+
blue{static_cast<Channel>(argb >> 0)},
|
32
|
+
alpha{static_cast<Channel>(argb >> 24)}
|
28
33
|
{
|
29
34
|
}
|
30
35
|
|
31
36
|
constexpr Color(Channel red, Channel green, Channel blue)
|
32
|
-
: red{red},
|
37
|
+
: red{red},
|
38
|
+
green{green},
|
39
|
+
blue{blue},
|
40
|
+
alpha{255}
|
33
41
|
{
|
34
42
|
}
|
35
43
|
|
@@ -46,19 +54,19 @@ namespace Gosu
|
|
46
54
|
|
47
55
|
/// Returns the hue of the color, in the usual range of 0..360.
|
48
56
|
double hue() const;
|
49
|
-
|
57
|
+
|
50
58
|
/// Changes the current color so hue() will return h.
|
51
59
|
void set_hue(double h);
|
52
|
-
|
60
|
+
|
53
61
|
/// Returns the saturation of the color, in the range of 0..1.
|
54
62
|
double saturation() const;
|
55
|
-
|
63
|
+
|
56
64
|
/// Changes the current color so saturation() will return s.
|
57
65
|
void set_saturation(double s);
|
58
|
-
|
66
|
+
|
59
67
|
/// Returns the value (brightness) of the color, in the range of 0..1.
|
60
68
|
double value() const;
|
61
|
-
|
69
|
+
|
62
70
|
/// Changes the current color so value() will return v.
|
63
71
|
void set_value(double v);
|
64
72
|
|
@@ -92,7 +100,7 @@ namespace Gosu
|
|
92
100
|
|
93
101
|
// Ensure that we can pass vectors of Gosu::Color straight to OpenGL and back.
|
94
102
|
static_assert(sizeof(Color) == sizeof(std::uint32_t));
|
95
|
-
|
103
|
+
|
96
104
|
#ifndef SWIG
|
97
105
|
inline bool operator<(Color a, Color b) { return a.gl() < b.gl(); }
|
98
106
|
inline bool operator==(Color a, Color b) { return a.gl() == b.gl(); }
|
@@ -101,7 +109,7 @@ namespace Gosu
|
|
101
109
|
/// Interpolates linearly between two colors, with a given weight towards
|
102
110
|
/// the second color.
|
103
111
|
Color lerp(Color a, Color b, double t = 0.5);
|
104
|
-
|
112
|
+
|
105
113
|
/// Combines two colors as if their channels were mapped to the 0..1 range
|
106
114
|
/// and then multiplied with each other.
|
107
115
|
Color multiply(Color a, Color b);
|
data/include/Gosu/Font.hpp
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
//! \file Font.hpp
|
2
|
-
//! Interface of the Font class.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
#include <Gosu/Fwd.hpp>
|
@@ -13,66 +10,65 @@
|
|
13
10
|
|
14
11
|
namespace Gosu
|
15
12
|
{
|
16
|
-
|
17
|
-
|
13
|
+
/// A simple bitmap font that renders and caches glyphs on demand.
|
14
|
+
/// For large, static texts you should use Gosu::layout_text and turn the result into an image.
|
18
15
|
class Font
|
19
16
|
{
|
20
17
|
struct Impl;
|
21
|
-
std::shared_ptr<Impl>
|
18
|
+
std::shared_ptr<Impl> m_impl;
|
22
19
|
|
23
20
|
public:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
21
|
+
/// @param name Name of a system font, or path to a TTF file (must contain '/').
|
22
|
+
/// @param height Height of the font, in pixels.
|
23
|
+
/// @param flags Flags used to render individual characters of the font (FontFlags enum).
|
24
|
+
explicit Font(int height, const std::string& name = default_font_name(),
|
25
|
+
unsigned flags = 0);
|
26
|
+
|
27
|
+
/// Returns the name of the font that was used to create it, i.e. the filename, nor the
|
28
|
+
/// internal TTF name. (TODO: Why not?)
|
31
29
|
const std::string& name() const;
|
32
|
-
|
33
|
-
|
30
|
+
|
31
|
+
/// Returns the height of the font, in pixels.
|
34
32
|
int height() const;
|
35
|
-
|
36
|
-
|
33
|
+
|
34
|
+
/// Returns the flags used to render the characters of the font (FontFlags enum).
|
37
35
|
unsigned flags() const;
|
38
|
-
|
39
|
-
|
36
|
+
|
37
|
+
/// Returns the width, in pixels, that the given text would occupy if drawn.
|
40
38
|
double text_width(const std::string& text) const;
|
41
|
-
|
39
|
+
/// Returns the width, in pixels, that the given markup would occupy if drawn.
|
42
40
|
double markup_width(const std::string& markup) const;
|
43
|
-
|
44
|
-
|
45
|
-
void draw_text(const std::string& text, double x, double y, ZPos z,
|
41
|
+
|
42
|
+
/// Draws text so the top left corner of the text is at (x; y).
|
43
|
+
void draw_text(const std::string& text, double x, double y, ZPos z, //
|
46
44
|
double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
|
47
45
|
BlendMode mode = BM_DEFAULT) const;
|
48
|
-
|
49
|
-
void draw_markup(const std::string& markup, double x, double y, ZPos z,
|
46
|
+
/// Draws markup so the top left corner of the text is at (x; y).
|
47
|
+
void draw_markup(const std::string& markup, double x, double y, ZPos z, //
|
50
48
|
double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
|
51
49
|
BlendMode mode = BM_DEFAULT) const;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
void draw_text_rel(const std::string& text, double x, double y, ZPos z,
|
50
|
+
|
51
|
+
/// Draws text at a position relative to (x; y).
|
52
|
+
/// @param rel_x Determines where the text is drawn horizontally. If rel_x is 0.0, the text
|
53
|
+
/// will be to the right of x, if it is 1.0, the text will be to the left of x, if it is
|
54
|
+
/// 0.5, it will be centered on x.
|
55
|
+
/// @param rel_y See rel_x.
|
56
|
+
void draw_text_rel(const std::string& text, double x, double y, ZPos z, //
|
60
57
|
double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
|
61
58
|
Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
void draw_markup_rel(const std::string& markup, double x, double y, ZPos z,
|
59
|
+
/// Draws markup at a position relative to (x; y).
|
60
|
+
/// @param rel_x Determines where the text is drawn horizontally. If rel_x is 0.0, the text
|
61
|
+
/// will be to the right of x, if it is 1.0, the text will be to the left of x, if it is
|
62
|
+
/// 0.5, it will be centered on x.
|
63
|
+
/// @param rel_y See rel_x.
|
64
|
+
void draw_markup_rel(const std::string& markup, double x, double y, ZPos z, //
|
69
65
|
double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
|
70
66
|
Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
|
68
|
+
/// Maps a letter to a specific image, instead of generating one using Gosu's built-in text
|
69
|
+
/// rendering.
|
74
70
|
void set_image(std::string codepoint, unsigned font_flags, const Gosu::Image& image);
|
75
|
-
|
71
|
+
/// A shortcut for mapping a character to an image regardless of font_flags.
|
76
72
|
void set_image(std::string codepoint, const Gosu::Image& image);
|
77
73
|
};
|
78
74
|
}
|