gosu 0.15.2 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +138 -0
  3. data/dependencies/SDL/include/SDL_assert.h +293 -0
  4. data/dependencies/SDL/include/SDL_atomic.h +295 -0
  5. data/dependencies/SDL/include/SDL_audio.h +859 -0
  6. data/dependencies/SDL/include/SDL_bits.h +121 -0
  7. data/dependencies/SDL/include/SDL_blendmode.h +123 -0
  8. data/dependencies/SDL/include/SDL_clipboard.h +71 -0
  9. data/dependencies/SDL/include/SDL_config.h +55 -0
  10. data/dependencies/SDL/include/SDL_config_android.h +182 -0
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
  12. data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
  13. data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
  14. data/dependencies/SDL/include/SDL_config_os2.h +188 -0
  15. data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
  16. data/dependencies/SDL/include/SDL_config_psp.h +165 -0
  17. data/dependencies/SDL/include/SDL_config_windows.h +288 -0
  18. data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
  19. data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
  20. data/dependencies/SDL/include/SDL_copying.h +20 -0
  21. data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
  22. data/dependencies/SDL/include/SDL_egl.h +1676 -0
  23. data/dependencies/SDL/include/SDL_endian.h +263 -0
  24. data/dependencies/SDL/include/SDL_error.h +112 -0
  25. data/dependencies/SDL/include/SDL_events.h +827 -0
  26. data/dependencies/SDL/include/SDL_filesystem.h +136 -0
  27. data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
  28. data/dependencies/SDL/include/SDL_gesture.h +87 -0
  29. data/dependencies/SDL/include/SDL_haptic.h +1247 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1578 -0
  31. data/dependencies/SDL/include/SDL_joystick.h +499 -0
  32. data/dependencies/SDL/include/SDL_keyboard.h +217 -0
  33. data/dependencies/SDL/include/SDL_keycode.h +351 -0
  34. data/dependencies/SDL/include/SDL_loadso.h +81 -0
  35. data/dependencies/SDL/include/SDL_locale.h +101 -0
  36. data/dependencies/SDL/include/SDL_log.h +211 -0
  37. data/dependencies/SDL/include/SDL_main.h +180 -0
  38. data/dependencies/SDL/include/SDL_messagebox.h +146 -0
  39. data/dependencies/SDL/include/SDL_metal.h +117 -0
  40. data/dependencies/SDL/include/SDL_misc.h +75 -0
  41. data/dependencies/SDL/include/SDL_mouse.h +302 -0
  42. data/dependencies/SDL/include/SDL_mutex.h +251 -0
  43. data/dependencies/SDL/include/SDL_name.h +33 -0
  44. data/dependencies/SDL/include/SDL_opengl.h +2183 -0
  45. data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
  46. data/dependencies/SDL/include/SDL_opengles.h +39 -0
  47. data/dependencies/SDL/include/SDL_opengles2.h +52 -0
  48. data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
  49. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
  50. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
  51. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
  52. data/dependencies/SDL/include/SDL_pixels.h +479 -0
  53. data/dependencies/SDL/include/SDL_platform.h +198 -0
  54. data/dependencies/SDL/include/SDL_power.h +75 -0
  55. data/dependencies/SDL/include/SDL_quit.h +58 -0
  56. data/dependencies/SDL/include/SDL_rect.h +174 -0
  57. data/dependencies/SDL/include/SDL_render.h +1158 -0
  58. data/dependencies/SDL/include/SDL_revision.h +2 -0
  59. data/dependencies/SDL/include/SDL_rwops.h +283 -0
  60. data/dependencies/SDL/include/SDL_scancode.h +413 -0
  61. data/dependencies/SDL/include/SDL_sensor.h +267 -0
  62. data/dependencies/SDL/include/SDL_shape.h +144 -0
  63. data/dependencies/SDL/include/SDL_stdinc.h +647 -0
  64. data/dependencies/SDL/include/SDL_surface.h +563 -0
  65. data/dependencies/SDL/include/SDL_system.h +325 -0
  66. data/dependencies/SDL/include/SDL_syswm.h +354 -0
  67. data/dependencies/SDL/include/SDL_test.h +69 -0
  68. data/dependencies/SDL/include/SDL_test_assert.h +105 -0
  69. data/dependencies/SDL/include/SDL_test_common.h +218 -0
  70. data/dependencies/SDL/include/SDL_test_compare.h +69 -0
  71. data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
  72. data/dependencies/SDL/include/SDL_test_font.h +81 -0
  73. data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
  74. data/dependencies/SDL/include/SDL_test_harness.h +134 -0
  75. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  76. data/dependencies/SDL/include/SDL_test_log.h +67 -0
  77. data/dependencies/SDL/include/SDL_test_md5.h +129 -0
  78. data/dependencies/SDL/include/SDL_test_memory.h +63 -0
  79. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  80. data/dependencies/SDL/include/SDL_thread.h +366 -0
  81. data/dependencies/SDL/include/SDL_timer.h +115 -0
  82. data/dependencies/SDL/include/SDL_touch.h +102 -0
  83. data/dependencies/SDL/include/SDL_types.h +29 -0
  84. data/dependencies/SDL/include/SDL_version.h +162 -0
  85. data/dependencies/SDL/include/SDL_video.h +1282 -0
  86. data/dependencies/SDL/include/SDL_vulkan.h +276 -0
  87. data/dependencies/SDL/include/begin_code.h +166 -0
  88. data/dependencies/SDL/include/close_code.h +40 -0
  89. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  90. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  91. data/dependencies/SDL_sound/SDL_sound.c +795 -0
  92. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  93. data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
  94. data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
  95. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
  96. data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
  97. data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
  98. data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
  99. data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
  100. data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
  101. data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
  102. data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
  103. data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
  104. data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
  105. data/dependencies/SDL_sound/dr_flac.h +5906 -0
  106. data/dependencies/SDL_sound/dr_mp3.h +2832 -0
  107. data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
  108. data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
  109. data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
  110. data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
  111. data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
  112. data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
  113. data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
  114. data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
  115. data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
  116. data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
  117. data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
  118. data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
  119. data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
  120. data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
  121. data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
  122. data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
  123. data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
  124. data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
  125. data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
  126. data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
  127. data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
  128. data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
  129. data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
  130. data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
  131. data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
  132. data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
  133. data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
  134. data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
  135. data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
  136. data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
  137. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
  138. data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
  139. data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
  140. data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
  141. data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
  142. data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
  143. data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
  144. data/dependencies/al_soft/AL/al.h +655 -0
  145. data/dependencies/al_soft/AL/alc.h +270 -0
  146. data/dependencies/al_soft/AL/alext.h +585 -0
  147. data/dependencies/al_soft/AL/efx-creative.h +3 -0
  148. data/dependencies/al_soft/AL/efx-presets.h +402 -0
  149. data/dependencies/al_soft/AL/efx.h +762 -0
  150. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  151. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  152. data/{src → dependencies/stb}/stb_image.h +330 -127
  153. data/{src → dependencies/stb}/stb_image_write.h +156 -85
  154. data/{src → dependencies/stb}/stb_truetype.h +192 -69
  155. data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
  156. data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
  157. data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
  158. data/ext/gosu/extconf.rb +56 -22
  159. data/{Gosu → include/Gosu}/Audio.hpp +6 -8
  160. data/{Gosu → include/Gosu}/AutoLink.hpp +0 -0
  161. data/include/Gosu/Bitmap.hpp +100 -0
  162. data/{Gosu → include/Gosu}/Buttons.hpp +94 -35
  163. data/{Gosu → include/Gosu}/Channel.h +0 -0
  164. data/{Gosu → include/Gosu}/Color.h +0 -0
  165. data/{Gosu → include/Gosu}/Color.hpp +0 -0
  166. data/{Gosu → include/Gosu}/Directories.hpp +0 -0
  167. data/{Gosu → include/Gosu}/Font.h +0 -0
  168. data/{Gosu → include/Gosu}/Font.hpp +0 -0
  169. data/{Gosu → include/Gosu}/Fwd.hpp +0 -0
  170. data/{Gosu → include/Gosu}/Gosu.h +3 -0
  171. data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
  172. data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
  173. data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
  174. data/{Gosu → include/Gosu}/IO.hpp +0 -0
  175. data/{Gosu → include/Gosu}/Image.h +0 -0
  176. data/{Gosu → include/Gosu}/Image.hpp +7 -6
  177. data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
  178. data/{Gosu → include/Gosu}/Input.hpp +30 -15
  179. data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
  180. data/{Gosu → include/Gosu}/Math.hpp +0 -0
  181. data/{Gosu → include/Gosu}/Platform.hpp +0 -0
  182. data/{Gosu → include/Gosu}/Sample.h +0 -0
  183. data/{Gosu → include/Gosu}/Song.h +0 -0
  184. data/{Gosu → include/Gosu}/Text.hpp +0 -0
  185. data/{Gosu → include/Gosu}/TextInput.h +0 -0
  186. data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
  187. data/{Gosu → include/Gosu}/Timing.hpp +0 -0
  188. data/{Gosu → include/Gosu}/Utility.hpp +1 -1
  189. data/{Gosu → include/Gosu}/Version.hpp +0 -0
  190. data/{Gosu → include/Gosu}/Window.h +2 -0
  191. data/{Gosu → include/Gosu}/Window.hpp +21 -13
  192. data/lib/OpenAL32.dll +0 -0
  193. data/lib/SDL2.dll +0 -0
  194. data/lib/gosu.rb +0 -3
  195. data/lib/gosu/patches.rb +0 -9
  196. data/lib/gosu/swig_patches.rb +3 -2
  197. data/lib/libmpg123.dll +0 -0
  198. data/lib/libsndfile.dll +0 -0
  199. data/lib64/OpenAL32.dll +0 -0
  200. data/lib64/SDL2.dll +0 -0
  201. data/lib64/libmpg123.dll +0 -0
  202. data/lib64/libsndfile.dll +0 -0
  203. data/rdoc/gosu.rb +95 -20
  204. data/src/Audio.cpp +50 -224
  205. data/src/AudioFile.hpp +17 -37
  206. data/src/AudioFileAudioToolbox.cpp +237 -0
  207. data/src/AudioFileSDLSound.cpp +147 -0
  208. data/src/AudioImpl.cpp +3 -12
  209. data/src/AudioImpl.hpp +3 -1
  210. data/src/Bitmap.cpp +85 -83
  211. data/src/BitmapIO.cpp +52 -58
  212. data/src/Constants.cpp +80 -33
  213. data/src/Font.cpp +3 -1
  214. data/src/GosuWrapper.cpp +19 -0
  215. data/src/Graphics.cpp +7 -4
  216. data/src/Image.cpp +13 -16
  217. data/src/Input.cpp +408 -159
  218. data/src/LargeImageData.cpp +1 -1
  219. data/src/MarkupParser.cpp +2 -1
  220. data/src/RubyGosu.cxx +349 -83
  221. data/src/RubyGosu.h +4 -2
  222. data/src/TexChunk.cpp +1 -1
  223. data/src/TextBuilder.cpp +3 -1
  224. data/src/Texture.cpp +1 -1
  225. data/src/TrueTypeFont.cpp +1 -1
  226. data/src/Utility.cpp +11 -7
  227. data/src/Window.cpp +30 -39
  228. data/src/WindowWrapper.cpp +28 -0
  229. metadata +207 -52
  230. data/Gosu/Bitmap.hpp +0 -113
  231. data/src/AudioToolboxFile.hpp +0 -210
  232. data/src/OggFile.hpp +0 -92
  233. data/src/SndFile.hpp +0 -174
  234. data/src/WinMain.cpp +0 -64
@@ -1,36 +1,60 @@
1
- #!/usr/bin/env ruby
1
+ require "rbconfig"
2
2
 
3
- if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/
4
- platform = (RUBY_PLATFORM =~ /^x64-/ ? 'x64-mingw32' : 'i386-mingw32')
5
-
6
- puts "This gem is not meant to be installed on Windows. Instead, please use:"
7
- puts "gem install gosu --platform=#{platform}"
8
- exit 1
3
+ case RbConfig::CONFIG["host_os"]
4
+ when /^mingw/
5
+ windows = true
6
+ when /^darwin/
7
+ macos = true
8
+ when /linux/
9
+ linux = true
9
10
  end
10
11
 
11
- puts 'The Gosu gem requires some libraries to be installed system-wide.'
12
- puts 'See the following site for a list:'
13
- if `uname`.chomp == 'Darwin'
14
- puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X'
15
- else
16
- puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux'
12
+ if macos or linux
13
+ puts 'The Gosu gem requires some libraries to be installed system-wide.'
14
+ puts 'See the following site for a list:'
15
+ if macos
16
+ puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X'
17
+ else
18
+ puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux'
19
+ end
17
20
  end
18
21
 
19
22
  require 'mkmf'
20
23
  require 'fileutils'
21
24
 
22
- # Silence internal deprecation warnings in Gosu
25
+ # Silence internal deprecation warnings in Gosu.
23
26
  $CFLAGS << " -DGOSU_DEPRECATED="
24
27
 
28
+ # Disable assertions in C code.
29
+ $CFLAGS << " -DNDEBUG"
30
+
25
31
  $CXXFLAGS ||= ""
26
- $CXXFLAGS << " -std=gnu++11"
32
+ # Enable C++17, but at the same time make the compiler more permissive to avoid this error:
33
+ # https://stackoverflow.com/a/31899029 (triggered by ruby.h, which uses register variables)
34
+ # The "register" macro can be removed when support for Ruby 2.6 and older has been dropped.
35
+ $CXXFLAGS << " -std=gnu++17 -Dregister="
36
+
37
+ # Make Gosu's own header files and all of its dependencies available to C++ source files.
38
+ $INCFLAGS << " -I../../include -I../../dependencies/stb -I../../dependencies/utf8proc -I../../dependencies/SDL_sound"
39
+
40
+ if windows
41
+ # We statically compile utf8proc into the Gosu binary.
42
+ # This macro is required to avoid errors about dllexport/dllimport mismatches.
43
+ $CFLAGS << " -DUTF8PROC_STATIC"
44
+ $CXXFLAGS << " -DUTF8PROC_STATIC"
27
45
 
28
- # For #include <Gosu/...>
29
- $INCFLAGS << " -I../.."
46
+ # Define UNICODE to use the Unicode-aware variants of all Win32 API functions.
47
+ $CXXFLAGS << " -DUNICODE"
30
48
 
31
- if `uname`.chomp == 'Darwin'
32
- # Disable assertions in C code.
33
- $CFLAGS << " -DNDEBUG"
49
+ # Use the bundled versions of SDL 2 and open_al.
50
+ $INCFLAGS << " -I../../dependencies/al_soft -I../../dependencies/SDL/include"
51
+ if RbConfig::CONFIG['arch'] =~ /x64-/
52
+ $LDFLAGS << " -L../../dependencies/al_soft/x64 -L../../dependencies/SDL/lib/x64"
53
+ else
54
+ $LDFLAGS << " -L../../dependencies/al_soft/x86 -L../../dependencies/SDL/lib/x86"
55
+ end
56
+ $LDFLAGS << " -lgdi32 -lwinmm -lOpenGL32 -lOpenAL32 -lSDL2"
57
+ elsif macos
34
58
  # Compile all C++ files as Objective C++ on macOS since mkmf does not support .mm files.
35
59
  $CXXFLAGS << " -x objective-c++ -fobjc-arc -DNDEBUG"
36
60
  # Prevents issues with Apple's pre-installed Ruby 2.3 on macOS 10.13.
@@ -43,6 +67,7 @@ if `uname`.chomp == 'Darwin'
43
67
  $CXXFLAGS << " -stdlib=libc++"
44
68
 
45
69
  # Dependencies.
70
+ $CFLAGS << " #{`sdl2-config --cflags`.chomp}"
46
71
  $CXXFLAGS << " #{`sdl2-config --cflags`.chomp}"
47
72
  # Prefer statically linking SDL 2.
48
73
  $LDFLAGS << " #{`sdl2-config --static-libs`.chomp} -framework OpenGL -framework Metal -framework OpenAL"
@@ -57,7 +82,7 @@ if `uname`.chomp == 'Darwin'
57
82
  $LDFLAGS.gsub! "-arch i386", ""
58
83
  $ARCH_FLAG.gsub! "-arch i386", ""
59
84
  CONFIG['LDSHARED'].gsub! "-arch i386", ""
60
- else
85
+ elsif linux
61
86
  if /BCM2708/ =~ `cat /proc/cpuinfo`
62
87
  $INCFLAGS << " -I/opt/vc/include/GLES"
63
88
  $INCFLAGS << " -I/opt/vc/include"
@@ -76,7 +101,16 @@ else
76
101
  pkg_config 'libmpg123'
77
102
  pkg_config 'fontconfig'
78
103
 
79
- have_header 'AL/al.h' if have_library('openal')
104
+ have_header 'AL/al.h' if have_library('openal')
105
+ end
106
+
107
+ # Because Ruby will only compile source file in the src/ folder, but our dependencies are
108
+ # stored in dependencies/, we need to create symlinks for all the .c files. This is terrible,
109
+ # but still seems better than putting everything into the same folder to begin with.
110
+ Dir.glob('../../dependencies/**/*.c').each do |dep|
111
+ File.open("../../src/#{File.basename dep}", "w") do |shim|
112
+ shim.puts "#include \"#{File.expand_path dep}\""
113
+ end
80
114
  end
81
115
 
82
116
  # Gem::Version#initialize is apparently broken in some versions of Ruby, so use a local helper.
@@ -51,8 +51,8 @@ namespace Gosu
51
51
  //! parameters. Use samples for everything that's not music.
52
52
  class Sample
53
53
  {
54
- struct SampleData;
55
- std::shared_ptr<SampleData> data;
54
+ struct Impl;
55
+ std::shared_ptr<Impl> pimpl;
56
56
 
57
57
  public:
58
58
  //! Constructs an empty sample that is inaudible when played.
@@ -91,10 +91,8 @@ namespace Gosu
91
91
  //! and there is no way to control its pan (stereo position) or speed.
92
92
  class Song
93
93
  {
94
- class BaseData;
95
- class ModuleData;
96
- class StreamData;
97
- std::unique_ptr<BaseData> data;
94
+ struct Impl;
95
+ std::unique_ptr<Impl> pimpl;
98
96
 
99
97
  // Non-movable to avoid dangling internal references.
100
98
  Song(Song&&) = delete;
@@ -117,7 +115,7 @@ namespace Gosu
117
115
  //! no song has been played yet or the last song has finished
118
116
  //! playing.
119
117
  static Song* current_song();
120
-
118
+
121
119
  //! Starts or resumes playback of the song. This will stop all other
122
120
  //! songs and set the current song to this object.
123
121
  void play(bool looping = false);
@@ -137,7 +135,7 @@ namespace Gosu
137
135
  //! \param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
138
136
  void set_volume(double volume);
139
137
 
140
- //! Called every tick by Window for management purposes.
138
+ //! Called every tick by Window to feed new audio data to OpenAL.
141
139
  static void update();
142
140
  };
143
141
  }
File without changes
@@ -0,0 +1,100 @@
1
+ #pragma once
2
+
3
+ #include <Gosu/Color.hpp>
4
+ #include <Gosu/IO.hpp>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ namespace Gosu
9
+ {
10
+ /// A two-dimensional array area of pixels, each represented by a Color value.
11
+ /// Bitmaps are typically created only as an intermediate step between loading image files, and
12
+ /// creating Gosu::Image objects from them (i.e. transferring the image into video RAM).
13
+ /// Has (expensive) value semantics.
14
+ class Bitmap
15
+ {
16
+ int m_width = 0, m_height = 0;
17
+ std::vector<Color> m_pixels;
18
+
19
+ public:
20
+ Bitmap() = default;
21
+
22
+ Bitmap(int width, int height, Color c = Color::NONE);
23
+
24
+ int width() const
25
+ {
26
+ return m_width;
27
+ }
28
+
29
+ int height() const
30
+ {
31
+ return m_height;
32
+ }
33
+
34
+ void swap(Bitmap& other);
35
+
36
+ void resize(int width, int height, Color c = Color::NONE);
37
+
38
+ /// Returns the color at the specified position without any bounds checking.
39
+ Color get_pixel(int x, int y) const
40
+ {
41
+ return m_pixels[y * m_width + x];
42
+ }
43
+
44
+ /// Sets the pixel at the specified position without any bounds checking.
45
+ void set_pixel(int x, int y, Color c)
46
+ {
47
+ m_pixels[y * m_width + x] = c;
48
+ }
49
+
50
+ /// This updates a pixel using the "over" alpha compositing operator, see:
51
+ /// https://en.wikipedia.org/wiki/Alpha_compositing
52
+ void blend_pixel(int x, int y, Color c);
53
+
54
+ /// Inserts a bitmap at the given position. Parts of the inserted bitmap that would be
55
+ /// outside of the target bitmap will be clipped away.
56
+ void insert(int x, int y, const Bitmap& source);
57
+
58
+ /// Inserts a portion of a bitmap at the given position. Parts of the inserted bitmap that
59
+ /// would be outside of the target bitmap will be clipped away.
60
+ void insert(int x, int y, const Bitmap& source,
61
+ int src_x, int src_y, int src_width, int src_height);
62
+
63
+ /// Direct access to the array of color values.
64
+ /// The return value is undefined if this bitmap is empty.
65
+ const Color* data() const
66
+ {
67
+ return &m_pixels[0];
68
+ }
69
+
70
+ /// Direct access to the array of color values.
71
+ /// The return value is undefined if this bitmap is empty.
72
+ Color* data()
73
+ {
74
+ return &m_pixels[0];
75
+ }
76
+
77
+ #ifdef FRIEND_TEST
78
+ FRIEND_TEST(BitmapTests, MemoryManagement);
79
+ #endif
80
+ };
81
+
82
+ /// Loads any supported image into a Bitmap.
83
+ Bitmap load_image_file(const std::string& filename);
84
+ /// Loads any supported image into a Bitmap.
85
+ Bitmap load_image_file(Reader input);
86
+
87
+ /// Saves a Bitmap to a file.
88
+ void save_image_file(const Bitmap& bitmap, const std::string& filename);
89
+ /// Saves a Bitmap to an arbitrary resource.
90
+ void save_image_file(const Bitmap& bitmap, Writer writer,
91
+ const std::string_view& format_hint = "png");
92
+
93
+ /// Set the alpha value of all pixels which are equal to the color key to zero.
94
+ /// To reduce interpolation artefacts when stretching or rotating the resulting image, the color
95
+ /// value of these pixels will also be adjusted to the average of their surrounding pixels.
96
+ void apply_color_key(Bitmap& bitmap, Color key);
97
+
98
+ Bitmap apply_border_flags(unsigned image_flags, const Bitmap& source,
99
+ int src_x, int src_y, int src_width, int src_height);
100
+ }
@@ -51,6 +51,9 @@ namespace Gosu
51
51
  KB_DOWN = 81,
52
52
  KB_HOME = 74,
53
53
  KB_END = 77,
54
+ KB_PRINTSCREEN = 70,
55
+ KB_SCROLLLOCK = 71,
56
+ KB_PAUSE = 72,
54
57
  KB_INSERT = 73,
55
58
  KB_DELETE = 76,
56
59
  KB_PAGE_UP = 75,
@@ -67,6 +70,7 @@ namespace Gosu
67
70
  KB_COMMA = 54,
68
71
  KB_PERIOD = 55,
69
72
  KB_SLASH = 56,
73
+ KB_CAPSLOCK = 57,
70
74
  KB_A = 4,
71
75
  KB_B = 5,
72
76
  KB_C = 6,
@@ -126,12 +130,12 @@ namespace Gosu
126
130
  MS_OTHER_6,
127
131
  MS_OTHER_7,
128
132
  MS_RANGE_END = 0x110,
129
-
133
+
130
134
  GP_RANGE_BEGIN,
131
- GP_LEFT = GP_RANGE_BEGIN,
132
- GP_RIGHT,
133
- GP_UP,
134
- GP_DOWN,
135
+ GP_DPAD_LEFT = GP_RANGE_BEGIN,
136
+ GP_DPAD_RIGHT,
137
+ GP_DPAD_UP,
138
+ GP_DPAD_DOWN,
135
139
  GP_BUTTON_0,
136
140
  GP_BUTTON_1,
137
141
  GP_BUTTON_2,
@@ -149,10 +153,10 @@ namespace Gosu
149
153
  GP_BUTTON_14,
150
154
  GP_BUTTON_15,
151
155
 
152
- GP_0_LEFT,
153
- GP_0_RIGHT,
154
- GP_0_UP,
155
- GP_0_DOWN,
156
+ GP_0_DPAD_LEFT,
157
+ GP_0_DPAD_RIGHT,
158
+ GP_0_DPAD_UP,
159
+ GP_0_DPAD_DOWN,
156
160
  GP_0_BUTTON_0,
157
161
  GP_0_BUTTON_1,
158
162
  GP_0_BUTTON_2,
@@ -169,11 +173,11 @@ namespace Gosu
169
173
  GP_0_BUTTON_13,
170
174
  GP_0_BUTTON_14,
171
175
  GP_0_BUTTON_15,
172
-
173
- GP_1_LEFT,
174
- GP_1_RIGHT,
175
- GP_1_UP,
176
- GP_1_DOWN,
176
+
177
+ GP_1_DPAD_LEFT,
178
+ GP_1_DPAD_RIGHT,
179
+ GP_1_DPAD_UP,
180
+ GP_1_DPAD_DOWN,
177
181
  GP_1_BUTTON_0,
178
182
  GP_1_BUTTON_1,
179
183
  GP_1_BUTTON_2,
@@ -190,11 +194,11 @@ namespace Gosu
190
194
  GP_1_BUTTON_13,
191
195
  GP_1_BUTTON_14,
192
196
  GP_1_BUTTON_15,
193
-
194
- GP_2_LEFT,
195
- GP_2_RIGHT,
196
- GP_2_UP,
197
- GP_2_DOWN,
197
+
198
+ GP_2_DPAD_LEFT,
199
+ GP_2_DPAD_RIGHT,
200
+ GP_2_DPAD_UP,
201
+ GP_2_DPAD_DOWN,
198
202
  GP_2_BUTTON_0,
199
203
  GP_2_BUTTON_1,
200
204
  GP_2_BUTTON_2,
@@ -211,11 +215,11 @@ namespace Gosu
211
215
  GP_2_BUTTON_13,
212
216
  GP_2_BUTTON_14,
213
217
  GP_2_BUTTON_15,
214
-
215
- GP_3_LEFT,
216
- GP_3_RIGHT,
217
- GP_3_UP,
218
- GP_3_DOWN,
218
+
219
+ GP_3_DPAD_LEFT,
220
+ GP_3_DPAD_RIGHT,
221
+ GP_3_DPAD_UP,
222
+ GP_3_DPAD_DOWN,
219
223
  GP_3_BUTTON_0,
220
224
  GP_3_BUTTON_1,
221
225
  GP_3_BUTTON_2,
@@ -232,16 +236,71 @@ namespace Gosu
232
236
  GP_3_BUTTON_13,
233
237
  GP_3_BUTTON_14,
234
238
  GP_3_BUTTON_15,
235
-
236
- GP_RANGE_END = GP_3_BUTTON_15,
237
-
238
- NUM_BUTTONS = GP_RANGE_END + 1,
239
- NUM_GAMEPADS = 4,
240
- NO_BUTTON = 0xffffffff,
241
-
242
- KB_NUM = KB_RANGE_END - KB_RANGE_BEGIN + 1,
243
- MS_NUM = MS_RANGE_END - MS_RANGE_BEGIN + 1,
244
- GP_NUM = GP_RANGE_END - GP_RANGE_BEGIN + 1,
245
- GP_NUM_PER_GAMEPAD = GP_NUM / (NUM_GAMEPADS + 1)
239
+
240
+ GP_LEFT,
241
+ GP_RIGHT,
242
+ GP_UP,
243
+ GP_DOWN,
244
+
245
+ GP_0_LEFT,
246
+ GP_0_RIGHT,
247
+ GP_0_UP,
248
+ GP_0_DOWN,
249
+
250
+ GP_1_LEFT,
251
+ GP_1_RIGHT,
252
+ GP_1_UP,
253
+ GP_1_DOWN,
254
+
255
+ GP_2_LEFT,
256
+ GP_2_RIGHT,
257
+ GP_2_UP,
258
+ GP_2_DOWN,
259
+
260
+ GP_3_LEFT,
261
+ GP_3_RIGHT,
262
+ GP_3_UP,
263
+ GP_3_DOWN,
264
+ GP_RANGE_END = GP_3_DOWN,
265
+
266
+ GP_AXES_RANGE_BEGIN,
267
+ GP_LEFT_STICK_X_AXIS = GP_AXES_RANGE_BEGIN,
268
+ GP_LEFT_STICK_Y_AXIS,
269
+ GP_RIGHT_STICK_X_AXIS,
270
+ GP_RIGHT_STICK_Y_AXIS,
271
+ GP_LEFT_TRIGGER_AXIS,
272
+ GP_RIGHT_TRIGGER_AXIS,
273
+
274
+ GP_0_LEFT_STICK_X_AXIS,
275
+ GP_0_LEFT_STICK_Y_AXIS,
276
+ GP_0_RIGHT_STICK_X_AXIS,
277
+ GP_0_RIGHT_STICK_Y_AXIS,
278
+ GP_0_LEFT_TRIGGER_AXIS,
279
+ GP_0_RIGHT_TRIGGER_AXIS,
280
+
281
+ GP_1_LEFT_STICK_X_AXIS,
282
+ GP_1_LEFT_STICK_Y_AXIS,
283
+ GP_1_RIGHT_STICK_X_AXIS,
284
+ GP_1_RIGHT_STICK_Y_AXIS,
285
+ GP_1_LEFT_TRIGGER_AXIS,
286
+ GP_1_RIGHT_TRIGGER_AXIS,
287
+
288
+ GP_2_LEFT_STICK_X_AXIS,
289
+ GP_2_LEFT_STICK_Y_AXIS,
290
+ GP_2_RIGHT_STICK_X_AXIS,
291
+ GP_2_RIGHT_STICK_Y_AXIS,
292
+ GP_2_LEFT_TRIGGER_AXIS,
293
+ GP_2_RIGHT_TRIGGER_AXIS,
294
+
295
+ GP_3_LEFT_STICK_X_AXIS,
296
+ GP_3_LEFT_STICK_Y_AXIS,
297
+ GP_3_RIGHT_STICK_X_AXIS,
298
+ GP_3_RIGHT_STICK_Y_AXIS,
299
+ GP_3_LEFT_TRIGGER_AXIS,
300
+ GP_3_RIGHT_TRIGGER_AXIS,
301
+ GP_AXES_RANGE_END = GP_3_RIGHT_TRIGGER_AXIS,
302
+
303
+ NUM_GAMEPADS = 4,
304
+ NO_BUTTON = 0xffffffff,
246
305
  };
247
306
  }
File without changes
File without changes