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
@@ -66,201 +66,140 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */
66
66
  /* @{ */
67
67
 
68
68
  /**
69
- * \brief Dynamically load a Vulkan loader library.
70
- *
71
- * \param [in] path The platform dependent Vulkan loader library name, or
72
- * \c NULL.
73
- *
74
- * \return \c 0 on success, or \c -1 if the library couldn't be loaded.
75
- *
76
- * If \a path is NULL SDL will use the value of the environment variable
77
- * \c SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan
78
- * loader library.
79
- *
80
- * This should be called after initializing the video driver, but before
81
- * creating any Vulkan windows. If no Vulkan loader library is loaded, the
82
- * default library will be loaded upon creation of the first Vulkan window.
83
- *
84
- * \note It is fairly common for Vulkan applications to link with \a libvulkan
85
- * instead of explicitly loading it at run time. This will work with
86
- * SDL provided the application links to a dynamic library and both it
87
- * and SDL use the same search path.
88
- *
89
- * \note If you specify a non-NULL \c path, an application should retrieve all
90
- * of the Vulkan functions it uses from the dynamic library using
91
- * \c SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee
92
- * \c path points to the same vulkan loader library the application
93
- * linked to.
94
- *
95
- * \note On Apple devices, if \a path is NULL, SDL will attempt to find
96
- * the vkGetInstanceProcAddr address within all the mach-o images of
97
- * the current process. This is because it is fairly common for Vulkan
98
- * applications to link with libvulkan (and historically MoltenVK was
99
- * provided as a static library). If it is not found then, on macOS, SDL
100
- * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib,
101
- * followed by \c libvulkan.dylib, in that order.
102
- * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications
103
- * using a dynamic framework or .dylib must ensure it is included in its
104
- * application bundle.
105
- *
106
- * \note On non-Apple devices, application linking with a static libvulkan is
107
- * not supported. Either do not link to the Vulkan loader or link to a
108
- * dynamic library version.
109
- *
110
- * \note This function will fail if there are no working Vulkan drivers
111
- * installed.
112
- *
113
- * \sa SDL_Vulkan_GetVkGetInstanceProcAddr()
114
- * \sa SDL_Vulkan_UnloadLibrary()
69
+ * Dynamically load the Vulkan loader library.
70
+ *
71
+ * This should be called after initializing the video driver, but before
72
+ * creating any Vulkan windows. If no Vulkan loader library is loaded, the
73
+ * default library will be loaded upon creation of the first Vulkan window.
74
+ *
75
+ * It is fairly common for Vulkan applications to link with libvulkan instead
76
+ * of explicitly loading it at run time. This will work with SDL provided the
77
+ * application links to a dynamic library and both it and SDL use the same
78
+ * search path.
79
+ *
80
+ * If you specify a non-NULL `path`, an application should retrieve all of the
81
+ * Vulkan functions it uses from the dynamic library using
82
+ * SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` points
83
+ * to the same vulkan loader library the application linked to.
84
+ *
85
+ * On Apple devices, if `path` is NULL, SDL will attempt to find the
86
+ * `vkGetInstanceProcAddr` address within all the Mach-O images of the current
87
+ * process. This is because it is fairly common for Vulkan applications to
88
+ * link with libvulkan (and historically MoltenVK was provided as a static
89
+ * library). If it is not found, on macOS, SDL will attempt to load
90
+ * `vulkan.framework/vulkan`, `libvulkan.1.dylib`,
91
+ * `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that order. On
92
+ * iOS, SDL will attempt to load `libMoltenVK.dylib`. Applications using a
93
+ * dynamic framework or .dylib must ensure it is included in its application
94
+ * bundle.
95
+ *
96
+ * On non-Apple devices, application linking with a static libvulkan is not
97
+ * supported. Either do not link to the Vulkan loader or link to a dynamic
98
+ * library version.
99
+ *
100
+ * \param path The platform dependent Vulkan loader library name or NULL
101
+ * \returns 0 on success or -1 if the library couldn't be loaded; call
102
+ * SDL_GetError() for more information.
103
+ *
104
+ * \since This function is available since SDL 2.0.6.
105
+ *
106
+ * \sa SDL_Vulkan_GetVkInstanceProcAddr
107
+ * \sa SDL_Vulkan_UnloadLibrary
115
108
  */
116
109
  extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
117
110
 
118
111
  /**
119
- * \brief Get the address of the \c vkGetInstanceProcAddr function.
112
+ * Get the address of the `vkGetInstanceProcAddr` function.
113
+ *
114
+ * This should be called after either calling SDL_Vulkan_LoadLibrary() or
115
+ * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
120
116
  *
121
- * \note This should be called after either calling SDL_Vulkan_LoadLibrary
122
- * or creating an SDL_Window with the SDL_WINDOW_VULKAN flag.
117
+ * \returns the function pointer for `vkGetInstanceProcAddr` or NULL on error.
118
+ *
119
+ * \since This function is available since SDL 2.0.6.
123
120
  */
124
121
  extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
125
122
 
126
123
  /**
127
- * \brief Unload the Vulkan loader library previously loaded by
128
- * \c SDL_Vulkan_LoadLibrary().
124
+ * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary()
125
+ *
126
+ * \since This function is available since SDL 2.0.6.
129
127
  *
130
- * \sa SDL_Vulkan_LoadLibrary()
128
+ * \sa SDL_Vulkan_LoadLibrary
131
129
  */
132
130
  extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
133
131
 
134
132
  /**
135
- * \brief Get the names of the Vulkan instance extensions needed to create
136
- * a surface with \c SDL_Vulkan_CreateSurface().
137
- *
138
- * \param [in] \c NULL or window Window for which the required Vulkan instance
139
- * extensions should be retrieved
140
- * \param [in,out] pCount pointer to an \c unsigned related to the number of
141
- * required Vulkan instance extensions
142
- * \param [out] pNames \c NULL or a pointer to an array to be filled with the
143
- * required Vulkan instance extensions
144
- *
145
- * \return \c SDL_TRUE on success, \c SDL_FALSE on error.
146
- *
147
- * If \a pNames is \c NULL, then the number of required Vulkan instance
148
- * extensions is returned in pCount. Otherwise, \a pCount must point to a
149
- * variable set to the number of elements in the \a pNames array, and on
150
- * return the variable is overwritten with the number of names actually
151
- * written to \a pNames. If \a pCount is less than the number of required
152
- * extensions, at most \a pCount structures will be written. If \a pCount
153
- * is smaller than the number of required extensions, \c SDL_FALSE will be
154
- * returned instead of \c SDL_TRUE, to indicate that not all the required
155
- * extensions were returned.
156
- *
157
- * \note If \c window is not NULL, it will be checked against its creation
158
- * flags to ensure that the Vulkan flag is present. This parameter
159
- * will be removed in a future major release.
160
- *
161
- * \note The returned list of extensions will contain \c VK_KHR_surface
162
- * and zero or more platform specific extensions
163
- *
164
- * \note The extension names queried here must be enabled when calling
165
- * VkCreateInstance, otherwise surface creation will fail.
166
- *
167
- * \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag
168
- * or be \c NULL
169
- *
170
- * \code
171
- * unsigned int count;
172
- * // get count of required extensions
173
- * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL))
174
- * handle_error();
175
- *
176
- * static const char *const additionalExtensions[] =
177
- * {
178
- * VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension
179
- * };
180
- * size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]);
181
- * size_t extensionCount = count + additionalExtensionsCount;
182
- * const char **names = malloc(sizeof(const char *) * extensionCount);
183
- * if(!names)
184
- * handle_error();
185
- *
186
- * // get names of required extensions
187
- * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names))
188
- * handle_error();
189
- *
190
- * // copy additional extensions after required extensions
191
- * for(size_t i = 0; i < additionalExtensionsCount; i++)
192
- * names[i + count] = additionalExtensions[i];
193
- *
194
- * VkInstanceCreateInfo instanceCreateInfo = {};
195
- * instanceCreateInfo.enabledExtensionCount = extensionCount;
196
- * instanceCreateInfo.ppEnabledExtensionNames = names;
197
- * // fill in rest of instanceCreateInfo
198
- *
199
- * VkInstance instance;
200
- * // create the Vulkan instance
201
- * VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance);
202
- * free(names);
203
- * \endcode
204
- *
205
- * \sa SDL_Vulkan_CreateSurface()
133
+ * Get the names of the Vulkan instance extensions needed to create a surface
134
+ * with SDL_Vulkan_CreateSurface.
135
+ *
136
+ * If `pNames` is NULL, then the number of required Vulkan instance extensions
137
+ * is returned in `pCount`. Otherwise, `pCount` must point to a variable set
138
+ * to the number of elements in the `pNames` array, and on return the variable
139
+ * is overwritten with the number of names actually written to `pNames`. If
140
+ * `pCount` is less than the number of required extensions, at most `pCount`
141
+ * structures will be written. If `pCount` is smaller than the number of
142
+ * required extensions, SDL_FALSE will be returned instead of SDL_TRUE, to
143
+ * indicate that not all the required extensions were returned.
144
+ *
145
+ * The `window` parameter is currently needed to be valid as of SDL 2.0.8,
146
+ * however, this parameter will likely be removed in future releases
147
+ *
148
+ * \param window A window for which the required Vulkan instance extensions
149
+ * should be retrieved (will be deprecated in a future release)
150
+ * \param pCount A pointer to an unsigned int corresponding to the number of
151
+ * extensions to be returned
152
+ * \param pNames NULL or a pointer to an array to be filled with required
153
+ * Vulkan instance extensions
154
+ * \returns SDL_TRUE on success, SDL_FALSE on error.
155
+ *
156
+ * \since This function is available since SDL 2.0.6.
157
+ *
158
+ * \sa SDL_Vulkan_CreateSurface
206
159
  */
207
160
  extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window *window,
208
161
  unsigned int *pCount,
209
162
  const char **pNames);
210
163
 
211
164
  /**
212
- * \brief Create a Vulkan rendering surface for a window.
213
- *
214
- * \param [in] window SDL_Window to which to attach the rendering surface.
215
- * \param [in] instance handle to the Vulkan instance to use.
216
- * \param [out] surface pointer to a VkSurfaceKHR handle to receive the
217
- * handle of the newly created surface.
218
- *
219
- * \return \c SDL_TRUE on success, \c SDL_FALSE on error.
165
+ * Create a Vulkan rendering surface for a window.
220
166
  *
221
- * \code
222
- * VkInstance instance;
223
- * SDL_Window *window;
167
+ * The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and
168
+ * `instance` must have been created with extensions returned by
169
+ * SDL_Vulkan_GetInstanceExtensions() enabled.
224
170
  *
225
- * // create instance and window
171
+ * \param window The window to which to attach the Vulkan surface
172
+ * \param instance The Vulkan instance handle
173
+ * \param surface A pointer to a VkSurfaceKHR handle to output the newly
174
+ * created surface
175
+ * \returns SDL_TRUE on success, SDL_FALSE on error.
226
176
  *
227
- * // create the Vulkan surface
228
- * VkSurfaceKHR surface;
229
- * if(!SDL_Vulkan_CreateSurface(window, instance, &surface))
230
- * handle_error();
231
- * \endcode
177
+ * \since This function is available since SDL 2.0.6.
232
178
  *
233
- * \note \a window should have been created with the \c SDL_WINDOW_VULKAN flag.
234
- *
235
- * \note \a instance should have been created with the extensions returned
236
- * by \c SDL_Vulkan_CreateSurface() enabled.
237
- *
238
- * \sa SDL_Vulkan_GetInstanceExtensions()
179
+ * \sa SDL_Vulkan_GetInstanceExtensions
180
+ * \sa SDL_Vulkan_GetDrawableSize
239
181
  */
240
182
  extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
241
183
  VkInstance instance,
242
184
  VkSurfaceKHR* surface);
243
185
 
244
186
  /**
245
- * \brief Get the size of a window's underlying drawable in pixels (for use
246
- * with setting viewport, scissor & etc).
247
- *
248
- * \param window SDL_Window from which the drawable size should be queried
249
- * \param w Pointer to variable for storing the width in pixels,
250
- * may be NULL
251
- * \param h Pointer to variable for storing the height in pixels,
252
- * may be NULL
187
+ * Get the size of the window's underlying drawable dimensions in pixels.
253
188
  *
254
189
  * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI
255
- * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a
256
- * platform with high-DPI support (Apple calls this "Retina"), and not disabled
257
- * by the \c SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.
190
+ * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a
191
+ * platform with high-DPI support (Apple calls this "Retina"), and not
192
+ * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint.
193
+ *
194
+ * \param window an SDL_Window for which the size is to be queried
195
+ * \param w Pointer to the variable to write the width to or NULL
196
+ * \param h Pointer to the variable to write the height to or NULL
258
197
  *
259
- * \note On macOS high-DPI support must be enabled for an application by
260
- * setting NSHighResolutionCapable to true in its Info.plist.
198
+ * \since This function is available since SDL 2.0.6.
261
199
  *
262
- * \sa SDL_GetWindowSize()
263
- * \sa SDL_CreateWindow()
200
+ * \sa SDL_GetWindowSize
201
+ * \sa SDL_CreateWindow
202
+ * \sa SDL_Vulkan_CreateSurface
264
203
  */
265
204
  extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window,
266
205
  int *w, int *h);
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -164,3 +164,24 @@
164
164
  #endif
165
165
  #endif /* NULL */
166
166
  #endif /* ! Mac OS X - breaks precompiled headers */
167
+
168
+ #ifndef SDL_FALLTHROUGH
169
+ #if (defined(__cplusplus) && __cplusplus >= 201703L) || \
170
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L)
171
+ #define SDL_FALLTHROUGH [[fallthrough]]
172
+ #else
173
+ #if defined(__has_attribute)
174
+ #define _HAS_FALLTHROUGH __has_attribute(__fallthrough__)
175
+ #else
176
+ #define _HAS_FALLTHROUGH 0
177
+ #endif /* __has_attribute */
178
+ #if _HAS_FALLTHROUGH && \
179
+ ((defined(__GNUC__) && __GNUC__ >= 7) || \
180
+ (defined(__clang_major__) && __clang_major__ >= 10))
181
+ #define SDL_FALLTHROUGH __attribute__((__fallthrough__))
182
+ #else
183
+ #define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
184
+ #endif /* _HAS_FALLTHROUGH */
185
+ #undef _HAS_FALLTHROUGH
186
+ #endif /* C++17 or C2x */
187
+ #endif /* SDL_FALLTHROUGH not defined */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
Binary file
Binary file
@@ -19,6 +19,7 @@
19
19
  /* The various decoder drivers... */
20
20
 
21
21
  /* All these externs may be missing; we check SOUND_SUPPORTS_xxx before use. */
22
+ extern const Sound_DecoderFunctions __Sound_DecoderFunctions_MIDI;
22
23
  extern const Sound_DecoderFunctions __Sound_DecoderFunctions_MODPLUG;
23
24
  extern const Sound_DecoderFunctions __Sound_DecoderFunctions_MP3;
24
25
  extern const Sound_DecoderFunctions __Sound_DecoderFunctions_WAV;
@@ -40,6 +41,9 @@ typedef struct
40
41
 
41
42
  static decoder_element decoders[] =
42
43
  {
44
+ #if SOUND_SUPPORTS_MIDI
45
+ { 0, &__Sound_DecoderFunctions_MIDI },
46
+ #endif
43
47
  #if SOUND_SUPPORTS_MODPLUG
44
48
  { 0, &__Sound_DecoderFunctions_MODPLUG },
45
49
  #endif
@@ -348,8 +352,7 @@ static Sound_Sample *alloc_sample(SDL_RWops *rw, Sound_AudioInfo *desired,
348
352
  #if (defined DEBUG_CHATTER)
349
353
  static SDL_INLINE const char *fmt_to_str(Uint16 fmt)
350
354
  {
351
- switch(fmt)
352
- {
355
+ switch(fmt) {
353
356
  case AUDIO_U8:
354
357
  return "U8";
355
358
  case AUDIO_S8:
@@ -371,7 +374,6 @@ static SDL_INLINE const char *fmt_to_str(Uint16 fmt)
371
374
  case AUDIO_F32MSB:
372
375
  return "F32MSB";
373
376
  } /* switch */
374
-
375
377
  return "Unknown";
376
378
  } /* fmt_to_str */
377
379
  #endif
@@ -396,7 +398,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs,
396
398
  internal->funcs = funcs;
397
399
  if (!funcs->open(sample, ext))
398
400
  {
399
- SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */
401
+ SDL_RWseek(internal->rw, pos, RW_SEEK_SET); /* set for next try... */
400
402
  return 0;
401
403
  } /* if */
402
404
 
@@ -423,7 +425,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs,
423
425
  {
424
426
  __Sound_SetError(SDL_GetError());
425
427
  funcs->close(sample);
426
- SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */
428
+ SDL_RWseek(internal->rw, pos, RW_SEEK_SET); /* set for next try... */
427
429
  return 0;
428
430
  } /* if */
429
431
 
@@ -433,7 +435,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs,
433
435
  if (rc == NULL)
434
436
  {
435
437
  funcs->close(sample);
436
- SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */
438
+ SDL_RWseek(internal->rw, pos, RW_SEEK_SET); /* set for next try... */
437
439
  return 0;
438
440
  } /* if */
439
441
 
@@ -517,7 +519,7 @@ Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext,
517
519
  /* skip if we would have tried decoder above... */
518
520
  while (*decoderExt)
519
521
  {
520
- if (SDL_strcasecmp(*decoderExt, ext) == 0)
522
+ if (ext && SDL_strcasecmp(*decoderExt, ext) == 0)
521
523
  {
522
524
  should_try = 0;
523
525
  break;
@@ -791,5 +793,79 @@ Sint32 Sound_GetDuration(Sound_Sample *sample)
791
793
  return internal->total_time;
792
794
  } /* Sound_GetDuration */
793
795
 
796
+
797
+ /* Utility functions ... */
798
+
799
+ /* The following uses the implementation suggested by
800
+ * the standard document, assumes RAND_MAX == 32767 */
801
+ static unsigned long __Sound_seed = 1;
802
+ int __Sound_rand(void)
803
+ {
804
+ __Sound_seed = __Sound_seed * 1103515245 + 12345;
805
+ return (__Sound_seed / 65536) % 32768;
806
+ }
807
+ void __Sound_srand(unsigned int seed)
808
+ {
809
+ __Sound_seed = seed;
810
+ }
811
+
812
+ #if !defined(HAVE_SDL_STRTOKR)
813
+ /* Adapted from _PDCLIB_strtok() of PDClib library at
814
+ * https://github.com/DevSolar/pdclib.git
815
+ *
816
+ * The code was under CC0 license:
817
+ * https://creativecommons.org/publicdomain/zero/1.0/legalcode
818
+ */
819
+ char *__Sound_strtokr(char *s1, const char *s2, char **ptr)
820
+ {
821
+ const char *p = s2;
822
+
823
+ if (!s2 || !ptr || (!s1 && !*ptr)) return NULL;
824
+
825
+ if (s1 != NULL) { /* new string */
826
+ *ptr = s1;
827
+ } else { /* old string continued */
828
+ if (*ptr == NULL) {
829
+ /* No old string, no new string, nothing to do */
830
+ return NULL;
831
+ }
832
+ s1 = *ptr;
833
+ }
834
+
835
+ /* skip leading s2 characters */
836
+ while (*p && *s1) {
837
+ if (*s1 == *p) {
838
+ /* found separator; skip and start over */
839
+ ++s1;
840
+ p = s2;
841
+ continue;
842
+ }
843
+ ++p;
844
+ }
845
+
846
+ if (! *s1) { /* no more to parse */
847
+ *ptr = s1;
848
+ return NULL;
849
+ }
850
+
851
+ /* skipping non-s2 characters */
852
+ *ptr = s1;
853
+ while (**ptr) {
854
+ p = s2;
855
+ while (*p) {
856
+ if (**ptr == *p++) {
857
+ /* found separator; overwrite with '\0', position *ptr, return */
858
+ *((*ptr)++) = '\0';
859
+ return s1;
860
+ }
861
+ }
862
+ ++(*ptr);
863
+ }
864
+
865
+ /* parsed to end of string */
866
+ return s1;
867
+ }
868
+ #endif
869
+
794
870
  /* end of SDL_sound.c ... */
795
871
 
@@ -62,16 +62,16 @@ extern "C" {
62
62
 
63
63
  #ifndef DOXYGEN_SHOULD_IGNORE_THIS
64
64
 
65
- #ifdef SDL_SOUND_DLL_EXPORTS
65
+ #if defined(SDL_SOUND_DLL_EXPORTS) && (defined(_WIN32) || defined(__OS2__))
66
66
  # define SNDDECLSPEC __declspec(dllexport)
67
- #elif (__GNUC__ >= 3)
67
+ #elif ((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)) && !(defined(_WIN32) || defined(__OS2__))
68
68
  # define SNDDECLSPEC __attribute__((visibility("default")))
69
69
  #else
70
70
  # define SNDDECLSPEC
71
71
  #endif
72
72
 
73
- #define SOUND_VER_MAJOR 1
74
- #define SOUND_VER_MINOR 9
73
+ #define SOUND_VER_MAJOR 2
74
+ #define SOUND_VER_MINOR 0
75
75
  #define SOUND_VER_PATCH 0
76
76
  #endif
77
77
 
@@ -245,7 +245,7 @@ static int read_ssnd_chunk(SDL_RWops *rw, ssnd_t *ssnd)
245
245
  ssnd->blockSize = SDL_SwapBE32(ssnd->blockSize);
246
246
 
247
247
  /* Leave the SDL_RWops position indicator at the start of the samples */
248
- if (SDL_RWseek(rw, (int) ssnd->offset, SEEK_CUR) == -1)
248
+ if (SDL_RWseek(rw, (int) ssnd->offset, RW_SEEK_CUR) == -1)
249
249
  return 0;
250
250
 
251
251
  return 1;
@@ -279,7 +279,7 @@ static Uint32 read_sample_fmt_normal(Sound_Sample *sample)
279
279
  if ((retval == 0) || (a->bytesLeft == 0))
280
280
  sample->flags |= SOUND_SAMPLEFLAG_EOF;
281
281
 
282
- else if (retval == -1)
282
+ else if (retval == -1) /** FIXME: this error check is broken **/
283
283
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
284
284
 
285
285
  /* (next call this EAGAIN may turn into an EOF or error.) */
@@ -304,7 +304,7 @@ static int seek_sample_fmt_normal(Sound_Sample *sample, Uint32 ms)
304
304
  fmt_t *fmt = &a->fmt;
305
305
  int offset = __Sound_convertMsToBytePos(&sample->actual, ms);
306
306
  int pos = (int) (fmt->data_starting_offset + offset);
307
- int rc = SDL_RWseek(internal->rw, pos, SEEK_SET);
307
+ int rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
308
308
  BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
309
309
  a->bytesLeft = fmt->total_bytes - offset;
310
310
  return 1; /* success. */
@@ -360,7 +360,7 @@ static int find_chunk(SDL_RWops *rw, Uint32 id)
360
360
  BAIL_IF_MACRO(SDL_RWread(rw, &siz, sizeof (siz), 1) != 1, NULL, 0);
361
361
  siz = SDL_SwapBE32(siz);
362
362
  SDL_assert(siz > 0);
363
- BAIL_IF_MACRO(SDL_RWseek(rw, siz, SEEK_CUR) == -1, NULL, 0);
363
+ BAIL_IF_MACRO(SDL_RWseek(rw, siz, RW_SEEK_CUR) == -1, NULL, 0);
364
364
  } /* while */
365
365
 
366
366
  return 0; /* shouldn't hit this, but just in case... */
@@ -380,14 +380,11 @@ static int read_fmt(SDL_RWops *rw, comm_t *c, fmt_t *fmt)
380
380
 
381
381
  /* add other types here. */
382
382
 
383
- default:
384
- SNDDBG(("AIFF: Format %lu is unknown.\n",
385
- (unsigned int) fmt->type));
386
- BAIL_MACRO("AIFF: Unsupported format", 0);
387
383
  } /* switch */
388
384
 
389
- SDL_assert(0); /* shouldn't hit this point. */
390
- return 0;
385
+ SNDDBG(("AIFF: Format %u is unknown.\n",
386
+ (unsigned int) fmt->type));
387
+ BAIL_MACRO("AIFF: Unsupported format", 0);
391
388
  } /* read_fmt */
392
389
 
393
390
 
@@ -450,7 +447,7 @@ static int AIFF_open(Sound_Sample *sample, const char *ext)
450
447
  return 0;
451
448
  } /* if */
452
449
 
453
- SDL_RWseek(rw, pos, SEEK_SET); /* if the seek fails, let it go... */
450
+ SDL_RWseek(rw, pos, RW_SEEK_SET); /* if the seek fails, let it go... */
454
451
 
455
452
  if (!find_chunk(rw, ssndID))
456
453
  {
@@ -497,7 +494,7 @@ static int AIFF_rewind(Sound_Sample *sample)
497
494
  Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
498
495
  aiff_t *a = (aiff_t *) internal->decoder_private;
499
496
  fmt_t *fmt = &a->fmt;
500
- int rc = SDL_RWseek(internal->rw, fmt->data_starting_offset, SEEK_SET);
497
+ int rc = SDL_RWseek(internal->rw, fmt->data_starting_offset, RW_SEEK_SET);
501
498
  BAIL_IF_MACRO(rc != fmt->data_starting_offset, ERR_IO_ERROR, 0);
502
499
  a->bytesLeft = fmt->total_bytes;
503
500
  return fmt->rewind_sample(sample);
@@ -109,7 +109,7 @@ static int AU_open(Sound_Sample *sample, const char *ext)
109
109
  {
110
110
  Sound_SampleInternal *internal = sample->opaque;
111
111
  SDL_RWops *rw = internal->rw;
112
- int skip, hsize, i, bytes_per_second;
112
+ int hsize, i, bytes_per_second;
113
113
  struct au_file_hdr hdr;
114
114
  struct audec *dec;
115
115
  char c;
@@ -163,7 +163,7 @@ static int AU_open(Sound_Sample *sample, const char *ext)
163
163
  } /* for */
164
164
  } /* if */
165
165
 
166
- else if (SDL_strcasecmp(ext, "au") == 0)
166
+ else if (ext && SDL_strcasecmp(ext, "au") == 0)
167
167
  {
168
168
  /*
169
169
  * A number of files in the wild have the .au extension but no valid
@@ -173,9 +173,9 @@ static int AU_open(Sound_Sample *sample, const char *ext)
173
173
 
174
174
  SNDDBG(("AU: Invalid header, assuming raw 8kHz µ-law.\n"));
175
175
  /* if seeking fails, we lose 24 samples. big deal */
176
- SDL_RWseek(rw, -HDR_SIZE, SEEK_CUR);
176
+ SDL_RWseek(rw, -HDR_SIZE, RW_SEEK_CUR);
177
177
  dec->encoding = AU_ENC_ULAW_8;
178
- dec->remaining = (Uint32)-1; /* no limit */
178
+ dec->remaining = (Uint32)-1; /* no limit */
179
179
  sample->actual.format = AUDIO_S16SYS;
180
180
  sample->actual.rate = 8000;
181
181
  sample->actual.channels = 1;
@@ -271,7 +271,7 @@ static Uint32 AU_read(Sound_Sample *sample)
271
271
  ret = SDL_RWread(internal->rw, buf, 1, maxlen);
272
272
  if (ret == 0)
273
273
  sample->flags |= SOUND_SAMPLEFLAG_EOF;
274
- else if (ret == -1)
274
+ else if (ret == -1) /** FIXME: this error check is broken **/
275
275
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
276
276
  else
277
277
  {
@@ -297,7 +297,7 @@ static int AU_rewind(Sound_Sample *sample)
297
297
  {
298
298
  Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
299
299
  struct audec *dec = (struct audec *) internal->decoder_private;
300
- int rc = SDL_RWseek(internal->rw, dec->start_offset, SEEK_SET);
300
+ int rc = SDL_RWseek(internal->rw, dec->start_offset, RW_SEEK_SET);
301
301
  BAIL_IF_MACRO(rc != dec->start_offset, ERR_IO_ERROR, 0);
302
302
  dec->remaining = dec->total;
303
303
  return 1;
@@ -316,7 +316,7 @@ static int AU_seek(Sound_Sample *sample, Uint32 ms)
316
316
  offset >>= 1; /* halve the byte offset for compression. */
317
317
 
318
318
  pos = (int) (dec->start_offset + offset);
319
- rc = SDL_RWseek(internal->rw, pos, SEEK_SET);
319
+ rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
320
320
  BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
321
321
  dec->remaining = dec->total - offset;
322
322
  return 1;