gosu 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +108 -14
  3. data/dependencies/SDL/include/SDL_assert.h +81 -50
  4. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  5. data/dependencies/SDL/include/SDL_audio.h +960 -355
  6. data/dependencies/SDL/include/SDL_bits.h +11 -6
  7. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  8. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  9. data/dependencies/SDL/include/SDL_config.h +277 -27
  10. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  12. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  13. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  14. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  15. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  16. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  17. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  18. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  19. data/dependencies/SDL/include/SDL_copying.h +1 -1
  20. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  21. data/dependencies/SDL/include/SDL_egl.h +906 -280
  22. data/dependencies/SDL/include/SDL_endian.h +101 -47
  23. data/dependencies/SDL/include/SDL_error.h +70 -19
  24. data/dependencies/SDL/include/SDL_events.h +387 -79
  25. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  26. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  27. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  28. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  29. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  31. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  32. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  33. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  34. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  35. data/dependencies/SDL/include/SDL_locale.h +34 -32
  36. data/dependencies/SDL/include/SDL_log.h +212 -19
  37. data/dependencies/SDL/include/SDL_main.h +72 -17
  38. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  39. data/dependencies/SDL/include/SDL_metal.h +27 -32
  40. data/dependencies/SDL/include/SDL_misc.h +19 -15
  41. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  42. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  43. data/dependencies/SDL/include/SDL_name.h +1 -1
  44. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  47. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  48. data/dependencies/SDL/include/SDL_platform.h +39 -2
  49. data/dependencies/SDL/include/SDL_power.h +23 -10
  50. data/dependencies/SDL/include/SDL_quit.h +1 -1
  51. data/dependencies/SDL/include/SDL_rect.h +78 -28
  52. data/dependencies/SDL/include/SDL_render.h +1204 -472
  53. data/dependencies/SDL/include/SDL_revision.h +2 -2
  54. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  55. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  56. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  57. data/dependencies/SDL/include/SDL_shape.h +38 -27
  58. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  59. data/dependencies/SDL/include/SDL_surface.h +571 -139
  60. data/dependencies/SDL/include/SDL_system.h +339 -101
  61. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  62. data/dependencies/SDL/include/SDL_test.h +1 -1
  63. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  64. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  65. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  66. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  68. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  69. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  70. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  71. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  75. data/dependencies/SDL/include/SDL_thread.h +226 -128
  76. data/dependencies/SDL/include/SDL_timer.h +129 -22
  77. data/dependencies/SDL/include/SDL_touch.h +48 -8
  78. data/dependencies/SDL/include/SDL_types.h +1 -1
  79. data/dependencies/SDL/include/SDL_version.h +72 -46
  80. data/dependencies/SDL/include/SDL_video.h +1266 -460
  81. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  82. data/dependencies/SDL/include/begin_code.h +22 -1
  83. data/dependencies/SDL/include/close_code.h +1 -1
  84. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  85. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  87. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  88. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  89. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  90. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  91. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  92. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  93. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  94. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  95. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  96. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  97. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  98. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  99. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  100. data/dependencies/SDL_sound/dr_flac.h +618 -220
  101. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  102. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  103. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  104. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  105. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  106. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  107. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  108. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  109. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  110. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  111. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  112. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  113. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  114. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  115. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  116. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  117. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  118. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  119. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  120. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  121. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  122. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  123. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  124. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  125. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  126. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  127. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  128. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  129. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  130. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  131. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  132. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  133. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  134. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  135. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  136. data/dependencies/mojoAL/mojoal.c +4594 -0
  137. data/ext/gosu/extconf.rb +29 -30
  138. data/include/Gosu/Audio.hpp +70 -85
  139. data/include/Gosu/Color.hpp +19 -11
  140. data/include/Gosu/Font.hpp +40 -44
  141. data/include/Gosu/Graphics.hpp +58 -71
  142. data/include/Gosu/GraphicsBase.hpp +26 -33
  143. data/include/Gosu/Image.hpp +56 -62
  144. data/include/Gosu/ImageData.hpp +23 -27
  145. data/include/Gosu/Inspection.hpp +1 -4
  146. data/include/Gosu/TextInput.hpp +34 -40
  147. data/include/Gosu/Version.hpp +1 -1
  148. data/include/Gosu/Window.hpp +71 -70
  149. data/lib/SDL2.dll +0 -0
  150. data/lib/gosu/compat.rb +24 -37
  151. data/lib/gosu.rb +2 -2
  152. data/lib64/SDL2.dll +0 -0
  153. data/src/Audio.cpp +86 -86
  154. data/src/AudioFile.hpp +6 -6
  155. data/src/AudioFileAudioToolbox.cpp +1 -1
  156. data/src/AudioFileSDLSound.cpp +1 -1
  157. data/src/AudioImpl.hpp +5 -5
  158. data/src/BitmapIO.cpp +0 -20
  159. data/src/BlockAllocator.cpp +2 -1
  160. data/src/Channel.cpp +22 -20
  161. data/src/Color.cpp +12 -9
  162. data/src/EmptyImageData.hpp +15 -17
  163. data/src/FileUnix.cpp +1 -1
  164. data/src/FileWin.cpp +1 -1
  165. data/src/Font.cpp +48 -53
  166. data/src/Graphics.cpp +135 -143
  167. data/src/Image.cpp +41 -42
  168. data/src/Input.cpp +1 -1
  169. data/src/InputUIKit.cpp +1 -1
  170. data/src/LargeImageData.cpp +108 -101
  171. data/src/LargeImageData.hpp +17 -15
  172. data/src/Log.hpp +6 -6
  173. data/src/Macro.cpp +35 -37
  174. data/src/Macro.hpp +11 -11
  175. data/src/Math.cpp +8 -1
  176. data/src/Resolution.cpp +12 -7
  177. data/src/RubyGosu.cxx +5 -5
  178. data/src/TexChunk.cpp +50 -41
  179. data/src/TexChunk.hpp +22 -22
  180. data/src/Text.cpp +37 -37
  181. data/src/TextBuilder.cpp +60 -57
  182. data/src/TextBuilder.hpp +20 -20
  183. data/src/TextInput.cpp +127 -135
  184. data/src/TrueTypeFont.cpp +107 -107
  185. data/src/TrueTypeFont.hpp +39 -38
  186. data/src/TrueTypeFontApple.cpp +19 -22
  187. data/src/TrueTypeFontUnix.cpp +21 -26
  188. data/src/TrueTypeFontWin.cpp +30 -30
  189. data/src/Window.cpp +95 -86
  190. data/src/WindowUIKit.cpp +46 -49
  191. metadata +7 -17
  192. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  193. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  194. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  195. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  196. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  197. data/dependencies/al_soft/AL/alext.h +0 -585
  198. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  199. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  200. data/dependencies/al_soft/AL/efx.h +0 -762
  201. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  202. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  203. data/lib/OpenAL32.dll +0 -0
  204. 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 'The Gosu gem requires some libraries to be installed system-wide.'
12
- puts 'See the following site for a list:'
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 'https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X'
14
+ puts "https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X"
15
15
  else
16
- puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux'
16
+ puts "https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux"
17
17
  end
18
18
  end
19
19
 
20
- require 'mkmf'
21
- require 'fileutils'
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/al_soft -I../../dependencies/SDL/include"
49
- if RbConfig::CONFIG['arch'] =~ /x64-/
50
- $LDFLAGS << " -L../../dependencies/al_soft/x64 -L../../dependencies/SDL/lib/x64"
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/al_soft/x86 -L../../dependencies/SDL/lib/x86"
52
+ $LDFLAGS << " -L../../dependencies/SDL/lib/x86"
53
53
  end
54
- $LDFLAGS << " -lgdi32 -lwinmm -ldwmapi -lOpenGL32 -lOpenAL32 -lSDL2"
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 << " #{`sdl2-config --static-libs`.chomp} -framework OpenGL -framework Metal -framework OpenAL"
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
- $LDFLAGS.sub! " -lSDL2 ", " /usr/local/lib/libSDL2.a " if File.exist? "/usr/local/lib/libSDL2.a"
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['LDSHARED'].gsub! "-arch i386", ""
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 << " -DGOSU_IS_OPENGLES"
94
+ $CFLAGS << " -DGOSU_IS_OPENGLES"
93
95
  $CXXFLAGS << " -DGOSU_IS_OPENGLES"
94
96
  else
95
- pkg_config 'gl'
97
+ pkg_config "gl"
96
98
  end
97
99
 
98
- pkg_config 'sdl2'
99
- pkg_config 'vorbisfile'
100
- pkg_config 'openal'
101
- pkg_config 'sndfile'
102
- pkg_config 'libmpg123'
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('../../dependencies/**/*.c').each do |dep|
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
@@ -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
- //! Sample::play returns a Channel that represents the sound being played.
15
- //! This object can be used to stop sounds dynamically, or to check whether playback has
16
- //! finished.
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 channel, token;
17
+ mutable int m_channel, m_token;
20
18
 
21
19
  public:
22
- //! This creates an "empty" Channel which is expired and cannot be resumed.
20
+ /// This creates an "empty" Channel which is expired and cannot be resumed.
23
21
  Channel();
24
- //! For internal use only.
22
+ /// For internal use only.
25
23
  Channel(int channel, int token);
26
-
27
- //! For internal use only.
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
- //! Pauses this instance to be resumed afterwards.
33
- //! Avoid leaving samples paused for too long, as they will still occupy one of Gosu's
34
- //! limited channels.
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
- //! Stops this channel if the sample is still being played.
38
- //! If this method is called when playback has finished, it has no effect.
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
- //! \param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
39
+ /// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
42
40
  void set_volume(double volume);
43
- //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
41
+ /// @param pan Can be anything from -1.0 (left) to 1.0 (right).
44
42
  void set_pan(double pan);
45
- //! \param speed Use 1.0 for normal playback speed.
43
+ /// @param speed Use 1.0 for normal playback speed.
46
44
  void set_speed(double speed);
47
45
  };
48
-
49
- //! A sample is a short sound that is completely loaded in memory, can be
50
- //! played multiple times at once and offers very flexible playback
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> pimpl;
52
+ std::shared_ptr<Impl> m_impl;
56
53
 
57
54
  public:
58
- //! Constructs an empty sample that is inaudible when played.
55
+ /// Constructs an empty sample that is inaudible when played.
59
56
  Sample();
60
-
61
- //! Constructs a sample that can be played on the specified audio
62
- //! system and loads the sample from a file.
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
- //! Constructs a sample that can be played on the specified audio
66
- //! system and loads the sample data from a stream.
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
- //! Plays the sample without panning.
70
- //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
71
- //! volume).
72
- //! \param speed Playback speed is only limited by the underlying audio library,
73
- //! and can accept very high or low values. Use 1.0 for
74
- //! normal playback speed.
75
- Channel play(double volume = 1, double speed = 1, bool looping = false) const;
76
-
77
- //! Plays the sample with panning. Even if pan is 0.0, the sample will
78
- //! not be as loud as if it were played by calling play() due to the
79
- //! way the panning works.
80
- //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
81
- //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
82
- //! volume).
83
- //! \param speed Playback speed is only limited by by the underlying audio library,
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
- //! Songs are less flexible than samples. Only one Song can be played at any given time,
91
- //! and there is no way to control its pan (stereo position) or speed.
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> pimpl;
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
- //! Constructs a song that can be played on the provided audio system
104
- //! and loads the song from a file.
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
- //! Constructs a song of the specified type that can be played on the
109
- //! provided audio system and loads the song data from a stream.
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
- //! Returns the song currently being played or paused, or 0 if
115
- //! no song has been played yet or the last song has finished
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
- //! Starts or resumes playback of the song. This will stop all other
120
- //! songs and set the current song to this object.
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
- //! Pauses playback of the song. It is not considered being played.
123
- //! current_song will stay the same.
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
- //! Returns true if the song is the current song, but in paused
126
- //! mode.
111
+ /// Returns true if the song is the current song, but in paused mode.
127
112
  bool paused() const;
128
- //! Stops playback of this song if it is currently played or paused.
129
- //! Afterwards, current_song will return nullptr.
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
- //! Returns true if the song is currently playing.
116
+ /// Returns true if the song is currently playing.
132
117
  bool playing() const;
133
- //! Returns the current volume of the song.
118
+ /// Returns the current volume of the song.
134
119
  double volume() const;
135
- //! \param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
120
+ /// @param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
136
121
  void set_volume(double volume);
137
-
138
- //! Called every tick by Window to feed new audio data to OpenAL.
122
+
123
+ /// Called every tick by Window to feed new audio data to OpenAL.
139
124
  static void update();
140
125
  };
141
126
  }
@@ -16,20 +16,28 @@ namespace Gosu
16
16
  Channel red, green, blue, alpha;
17
17
 
18
18
  constexpr Color()
19
- : red{0}, green{0}, blue{0}, alpha{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)}, green{static_cast<Channel>(argb >> 8)},
27
- blue{static_cast<Channel>(argb >> 0)}, alpha{static_cast<Channel>(argb >> 24)}
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}, green{green}, blue{blue}, alpha{255}
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);
@@ -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
- //! Fonts are ideal for drawing short, dynamic strings.
17
- //! For large, static texts you should use Gosu::layout_text and turn the result into an image.
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> pimpl;
18
+ std::shared_ptr<Impl> m_impl;
22
19
 
23
20
  public:
24
- //! Constructs a font that can be drawn onto the graphics object.
25
- //! \param name Name of a system font, or a filename to a TTF file.
26
- //! \param height Height of the font, in pixels.
27
- //! \param flags Flags used to render individual characters of the font.
28
- Font(int height, const std::string& name = default_font_name(), unsigned flags = 0);
29
-
30
- //! Returns the name of the font that was used to create it.
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
- //! Returns the height of the font, in pixels.
30
+
31
+ /// Returns the height of the font, in pixels.
34
32
  int height() const;
35
-
36
- //! Returns the flags used to create the font characters.
33
+
34
+ /// Returns the flags used to render the characters of the font (FontFlags enum).
37
35
  unsigned flags() const;
38
-
39
- //! Returns the width, in pixels, the given text would occupy if drawn.
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
- //! Returns the width, in pixels, the given markup would occupy if drawn.
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
- //! Draws text so the top left corner of the text is at (x; y).
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
- //! Draws markup so the top left corner of the text is at (x; y).
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
- //! Draws text at a position relative to (x; y).
54
- //! \param rel_x Determines where the text is drawn horizontally. If
55
- //! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
56
- //! the text will be to the left of x, if it is 0.5, it will be
57
- //! centered on x. All real numbers are possible values.
58
- //! \param rel_y See rel_x.
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
- //! Draws text at a position relative to (x; y).
63
- //! \param rel_x Determines where the text is drawn horizontally. If
64
- //! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
65
- //! the text will be to the left of x, if it is 0.5, it will be
66
- //! centered on x. All real numbers are possible values.
67
- //! \param rel_y See rel_x.
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
- //! Maps a letter to a specific image, instead of generating one using
73
- //! Gosu's built-in text rendering.
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
- //! A shortcut for mapping a character to an image regardless of font_flags.
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
  }