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
@@ -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
@@ -59,38 +59,105 @@ struct SDL_mutex;
59
59
  typedef struct SDL_mutex SDL_mutex;
60
60
 
61
61
  /**
62
- * Create a mutex, initialized unlocked.
62
+ * Create a new mutex.
63
+ *
64
+ * All newly-created mutexes begin in the _unlocked_ state.
65
+ *
66
+ * Calls to SDL_LockMutex() will not return while the mutex is locked by
67
+ * another thread. See SDL_TryLockMutex() to attempt to lock without blocking.
68
+ *
69
+ * SDL mutexes are reentrant.
70
+ *
71
+ * \returns the initialized and unlocked mutex or NULL on failure; call
72
+ * SDL_GetError() for more information.
73
+ *
74
+ * \since This function is available since SDL 2.0.0.
75
+ *
76
+ * \sa SDL_DestroyMutex
77
+ * \sa SDL_LockMutex
78
+ * \sa SDL_TryLockMutex
79
+ * \sa SDL_UnlockMutex
63
80
  */
64
81
  extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
65
82
 
66
83
  /**
67
- * Lock the mutex.
84
+ * Lock the mutex.
85
+ *
86
+ * This will block until the mutex is available, which is to say it is in the
87
+ * unlocked state and the OS has chosen the caller as the next thread to lock
88
+ * it. Of all threads waiting to lock the mutex, only one may do so at a time.
89
+ *
90
+ * It is legal for the owning thread to lock an already-locked mutex. It must
91
+ * unlock it the same number of times before it is actually made available for
92
+ * other threads in the system (this is known as a "recursive mutex").
68
93
  *
69
- * \return 0, or -1 on error.
94
+ * \param mutex the mutex to lock
95
+ * \return 0, or -1 on error.
96
+ *
97
+ * \since This function is available since SDL 2.0.0.
70
98
  */
71
- #define SDL_mutexP(m) SDL_LockMutex(m)
72
99
  extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
100
+ #define SDL_mutexP(m) SDL_LockMutex(m)
73
101
 
74
102
  /**
75
- * Try to lock the mutex
103
+ * Try to lock a mutex without blocking.
104
+ *
105
+ * This works just like SDL_LockMutex(), but if the mutex is not available,
106
+ * this function returns `SDL_MUTEX_TIMEOUT` immediately.
76
107
  *
77
- * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error
108
+ * This technique is useful if you need exclusive access to a resource but
109
+ * don't want to wait for it, and will return to it to try again later.
110
+ *
111
+ * \param mutex the mutex to try to lock
112
+ * \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
113
+ * more information.
114
+ *
115
+ * \since This function is available since SDL 2.0.0.
116
+ *
117
+ * \sa SDL_CreateMutex
118
+ * \sa SDL_DestroyMutex
119
+ * \sa SDL_LockMutex
120
+ * \sa SDL_UnlockMutex
78
121
  */
79
122
  extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
80
123
 
81
124
  /**
82
- * Unlock the mutex.
125
+ * Unlock the mutex.
126
+ *
127
+ * It is legal for the owning thread to lock an already-locked mutex. It must
128
+ * unlock it the same number of times before it is actually made available for
129
+ * other threads in the system (this is known as a "recursive mutex").
83
130
  *
84
- * \return 0, or -1 on error.
131
+ * It is an error to unlock a mutex that has not been locked by the current
132
+ * thread, and doing so results in undefined behavior.
85
133
  *
86
- * \warning It is an error to unlock a mutex that has not been locked by
87
- * the current thread, and doing so results in undefined behavior.
134
+ * It is also an error to unlock a mutex that isn't locked at all.
135
+ *
136
+ * \param mutex the mutex to unlock.
137
+ * \returns 0, or -1 on error.
138
+ *
139
+ * \since This function is available since SDL 2.0.0.
88
140
  */
89
- #define SDL_mutexV(m) SDL_UnlockMutex(m)
90
141
  extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
142
+ #define SDL_mutexV(m) SDL_UnlockMutex(m)
91
143
 
92
144
  /**
93
- * Destroy a mutex.
145
+ * Destroy a mutex created with SDL_CreateMutex().
146
+ *
147
+ * This function must be called on any mutex that is no longer needed. Failure
148
+ * to destroy a mutex will result in a system memory or resource leak. While
149
+ * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt
150
+ * to destroy a locked mutex, and may result in undefined behavior depending
151
+ * on the platform.
152
+ *
153
+ * \param mutex the mutex to destroy
154
+ *
155
+ * \since This function is available since SDL 2.0.0.
156
+ *
157
+ * \sa SDL_CreateMutex
158
+ * \sa SDL_LockMutex
159
+ * \sa SDL_TryLockMutex
160
+ * \sa SDL_UnlockMutex
94
161
  */
95
162
  extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
96
163
 
@@ -107,50 +174,151 @@ struct SDL_semaphore;
107
174
  typedef struct SDL_semaphore SDL_sem;
108
175
 
109
176
  /**
110
- * Create a semaphore, initialized with value, returns NULL on failure.
177
+ * Create a semaphore.
178
+ *
179
+ * This function creates a new semaphore and initializes it with the value
180
+ * `initial_value`. Each wait operation on the semaphore will atomically
181
+ * decrement the semaphore value and potentially block if the semaphore value
182
+ * is 0. Each post operation will atomically increment the semaphore value and
183
+ * wake waiting threads and allow them to retry the wait operation.
184
+ *
185
+ * \param initial_value the starting value of the semaphore
186
+ * \returns a new semaphore or NULL on failure; call SDL_GetError() for more
187
+ * information.
188
+ *
189
+ * \since This function is available since SDL 2.0.0.
190
+ *
191
+ * \sa SDL_DestroySemaphore
192
+ * \sa SDL_SemPost
193
+ * \sa SDL_SemTryWait
194
+ * \sa SDL_SemValue
195
+ * \sa SDL_SemWait
196
+ * \sa SDL_SemWaitTimeout
111
197
  */
112
198
  extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
113
199
 
114
200
  /**
115
- * Destroy a semaphore.
201
+ * Destroy a semaphore.
202
+ *
203
+ * It is not safe to destroy a semaphore if there are threads currently
204
+ * waiting on it.
205
+ *
206
+ * \param sem the semaphore to destroy
207
+ *
208
+ * \since This function is available since SDL 2.0.0.
209
+ *
210
+ * \sa SDL_CreateSemaphore
211
+ * \sa SDL_SemPost
212
+ * \sa SDL_SemTryWait
213
+ * \sa SDL_SemValue
214
+ * \sa SDL_SemWait
215
+ * \sa SDL_SemWaitTimeout
116
216
  */
117
217
  extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
118
218
 
119
219
  /**
120
- * This function suspends the calling thread until the semaphore pointed
121
- * to by \c sem has a positive count. It then atomically decreases the
122
- * semaphore count.
220
+ * Wait until a semaphore has a positive value and then decrements it.
221
+ *
222
+ * This function suspends the calling thread until either the semaphore
223
+ * pointed to by `sem` has a positive value or the call is interrupted by a
224
+ * signal or error. If the call is successful it will atomically decrement the
225
+ * semaphore value.
226
+ *
227
+ * This function is the equivalent of calling SDL_SemWaitTimeout() with a time
228
+ * length of `SDL_MUTEX_MAXWAIT`.
229
+ *
230
+ * \param sem the semaphore wait on
231
+ * \returns 0 on success or a negative error code on failure; call
232
+ * SDL_GetError() for more information.
233
+ *
234
+ * \since This function is available since SDL 2.0.0.
235
+ *
236
+ * \sa SDL_CreateSemaphore
237
+ * \sa SDL_DestroySemaphore
238
+ * \sa SDL_SemPost
239
+ * \sa SDL_SemTryWait
240
+ * \sa SDL_SemValue
241
+ * \sa SDL_SemWait
242
+ * \sa SDL_SemWaitTimeout
123
243
  */
124
244
  extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
125
245
 
126
246
  /**
127
- * Non-blocking variant of SDL_SemWait().
247
+ * See if a semaphore has a positive value and decrement it if it does.
248
+ *
249
+ * This function checks to see if the semaphore pointed to by `sem` has a
250
+ * positive value and atomically decrements the semaphore value if it does. If
251
+ * the semaphore doesn't have a positive value, the function immediately
252
+ * returns SDL_MUTEX_TIMEDOUT.
253
+ *
254
+ * \param sem the semaphore to wait on
255
+ * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
256
+ * block, or a negative error code on failure; call SDL_GetError()
257
+ * for more information.
258
+ *
259
+ * \since This function is available since SDL 2.0.0.
128
260
  *
129
- * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would
130
- * block, and -1 on error.
261
+ * \sa SDL_CreateSemaphore
262
+ * \sa SDL_DestroySemaphore
263
+ * \sa SDL_SemPost
264
+ * \sa SDL_SemValue
265
+ * \sa SDL_SemWait
266
+ * \sa SDL_SemWaitTimeout
131
267
  */
132
268
  extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
133
269
 
134
270
  /**
135
- * Variant of SDL_SemWait() with a timeout in milliseconds.
271
+ * Wait until a semaphore has a positive value and then decrements it.
136
272
  *
137
- * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not
138
- * succeed in the allotted time, and -1 on error.
273
+ * This function suspends the calling thread until either the semaphore
274
+ * pointed to by `sem` has a positive value, the call is interrupted by a
275
+ * signal or error, or the specified time has elapsed. If the call is
276
+ * successful it will atomically decrement the semaphore value.
139
277
  *
140
- * \warning On some platforms this function is implemented by looping with a
141
- * delay of 1 ms, and so should be avoided if possible.
278
+ * \param sem the semaphore to wait on
279
+ * \param ms the length of the timeout, in milliseconds
280
+ * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
281
+ * succeed in the allotted time, or a negative error code on failure;
282
+ * call SDL_GetError() for more information.
283
+ *
284
+ * \since This function is available since SDL 2.0.0.
285
+ *
286
+ * \sa SDL_CreateSemaphore
287
+ * \sa SDL_DestroySemaphore
288
+ * \sa SDL_SemPost
289
+ * \sa SDL_SemTryWait
290
+ * \sa SDL_SemValue
291
+ * \sa SDL_SemWait
142
292
  */
143
293
  extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
144
294
 
145
295
  /**
146
- * Atomically increases the semaphore's count (not blocking).
296
+ * Atomically increment a semaphore's value and wake waiting threads.
297
+ *
298
+ * \param sem the semaphore to increment
299
+ * \returns 0 on success or a negative error code on failure; call
300
+ * SDL_GetError() for more information.
301
+ *
302
+ * \since This function is available since SDL 2.0.0.
147
303
  *
148
- * \return 0, or -1 on error.
304
+ * \sa SDL_CreateSemaphore
305
+ * \sa SDL_DestroySemaphore
306
+ * \sa SDL_SemTryWait
307
+ * \sa SDL_SemValue
308
+ * \sa SDL_SemWait
309
+ * \sa SDL_SemWaitTimeout
149
310
  */
150
311
  extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
151
312
 
152
313
  /**
153
- * Returns the current count of the semaphore.
314
+ * Get the current value of a semaphore.
315
+ *
316
+ * \param sem the semaphore to query
317
+ * \returns the current value of the semaphore.
318
+ *
319
+ * \since This function is available since SDL 2.0.0.
320
+ *
321
+ * \sa SDL_CreateSemaphore
154
322
  */
155
323
  extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
156
324
 
@@ -167,72 +335,124 @@ struct SDL_cond;
167
335
  typedef struct SDL_cond SDL_cond;
168
336
 
169
337
  /**
170
- * Create a condition variable.
171
- *
172
- * Typical use of condition variables:
338
+ * Create a condition variable.
173
339
  *
174
- * Thread A:
175
- * SDL_LockMutex(lock);
176
- * while ( ! condition ) {
177
- * SDL_CondWait(cond, lock);
178
- * }
179
- * SDL_UnlockMutex(lock);
340
+ * \returns a new condition variable or NULL on failure; call SDL_GetError()
341
+ * for more information.
180
342
  *
181
- * Thread B:
182
- * SDL_LockMutex(lock);
183
- * ...
184
- * condition = true;
185
- * ...
186
- * SDL_CondSignal(cond);
187
- * SDL_UnlockMutex(lock);
343
+ * \since This function is available since SDL 2.0.0.
188
344
  *
189
- * There is some discussion whether to signal the condition variable
190
- * with the mutex locked or not. There is some potential performance
191
- * benefit to unlocking first on some platforms, but there are some
192
- * potential race conditions depending on how your code is structured.
193
- *
194
- * In general it's safer to signal the condition variable while the
195
- * mutex is locked.
345
+ * \sa SDL_CondBroadcast
346
+ * \sa SDL_CondSignal
347
+ * \sa SDL_CondWait
348
+ * \sa SDL_CondWaitTimeout
349
+ * \sa SDL_DestroyCond
196
350
  */
197
351
  extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
198
352
 
199
353
  /**
200
- * Destroy a condition variable.
354
+ * Destroy a condition variable.
355
+ *
356
+ * \param cond the condition variable to destroy
357
+ *
358
+ * \since This function is available since SDL 2.0.0.
359
+ *
360
+ * \sa SDL_CondBroadcast
361
+ * \sa SDL_CondSignal
362
+ * \sa SDL_CondWait
363
+ * \sa SDL_CondWaitTimeout
364
+ * \sa SDL_CreateCond
201
365
  */
202
366
  extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
203
367
 
204
368
  /**
205
- * Restart one of the threads that are waiting on the condition variable.
369
+ * Restart one of the threads that are waiting on the condition variable.
206
370
  *
207
- * \return 0 or -1 on error.
371
+ * \param cond the condition variable to signal
372
+ * \returns 0 on success or a negative error code on failure; call
373
+ * SDL_GetError() for more information.
374
+ *
375
+ * \since This function is available since SDL 2.0.0.
376
+ *
377
+ * \sa SDL_CondBroadcast
378
+ * \sa SDL_CondWait
379
+ * \sa SDL_CondWaitTimeout
380
+ * \sa SDL_CreateCond
381
+ * \sa SDL_DestroyCond
208
382
  */
209
383
  extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
210
384
 
211
385
  /**
212
- * Restart all threads that are waiting on the condition variable.
386
+ * Restart all threads that are waiting on the condition variable.
387
+ *
388
+ * \param cond the condition variable to signal
389
+ * \returns 0 on success or a negative error code on failure; call
390
+ * SDL_GetError() for more information.
391
+ *
392
+ * \since This function is available since SDL 2.0.0.
213
393
  *
214
- * \return 0 or -1 on error.
394
+ * \sa SDL_CondSignal
395
+ * \sa SDL_CondWait
396
+ * \sa SDL_CondWaitTimeout
397
+ * \sa SDL_CreateCond
398
+ * \sa SDL_DestroyCond
215
399
  */
216
400
  extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
217
401
 
218
402
  /**
219
- * Wait on the condition variable, unlocking the provided mutex.
403
+ * Wait until a condition variable is signaled.
220
404
  *
221
- * \warning The mutex must be locked before entering this function!
405
+ * This function unlocks the specified `mutex` and waits for another thread to
406
+ * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
407
+ * `cond`. Once the condition variable is signaled, the mutex is re-locked and
408
+ * the function returns.
222
409
  *
223
- * The mutex is re-locked once the condition variable is signaled.
410
+ * The mutex must be locked before calling this function.
224
411
  *
225
- * \return 0 when it is signaled, or -1 on error.
412
+ * This function is the equivalent of calling SDL_CondWaitTimeout() with a
413
+ * time length of `SDL_MUTEX_MAXWAIT`.
414
+ *
415
+ * \param cond the condition variable to wait on
416
+ * \param mutex the mutex used to coordinate thread access
417
+ * \returns 0 when it is signaled or a negative error code on failure; call
418
+ * SDL_GetError() for more information.
419
+ *
420
+ * \since This function is available since SDL 2.0.0.
421
+ *
422
+ * \sa SDL_CondBroadcast
423
+ * \sa SDL_CondSignal
424
+ * \sa SDL_CondWaitTimeout
425
+ * \sa SDL_CreateCond
426
+ * \sa SDL_DestroyCond
226
427
  */
227
428
  extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
228
429
 
229
430
  /**
230
- * Waits for at most \c ms milliseconds, and returns 0 if the condition
231
- * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not
232
- * signaled in the allotted time, and -1 on error.
431
+ * Wait until a condition variable is signaled or a certain time has passed.
432
+ *
433
+ * This function unlocks the specified `mutex` and waits for another thread to
434
+ * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
435
+ * `cond`, or for the specified time to elapse. Once the condition variable is
436
+ * signaled or the time elapsed, the mutex is re-locked and the function
437
+ * returns.
438
+ *
439
+ * The mutex must be locked before calling this function.
440
+ *
441
+ * \param cond the condition variable to wait on
442
+ * \param mutex the mutex used to coordinate thread access
443
+ * \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT`
444
+ * to wait indefinitely
445
+ * \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
446
+ * the condition is not signaled in the allotted time, or a negative
447
+ * error code on failure; call SDL_GetError() for more information.
448
+ *
449
+ * \since This function is available since SDL 2.0.0.
233
450
  *
234
- * \warning On some platforms this function is implemented by looping with a
235
- * delay of 1 ms, and so should be avoided if possible.
451
+ * \sa SDL_CondBroadcast
452
+ * \sa SDL_CondSignal
453
+ * \sa SDL_CondWait
454
+ * \sa SDL_CreateCond
455
+ * \sa SDL_DestroyCond
236
456
  */
237
457
  extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
238
458
  SDL_mutex * mutex, Uint32 ms);
@@ -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
@@ -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
@@ -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
@@ -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
@@ -26,7 +26,7 @@
26
26
  */
27
27
  #include "SDL_config.h"
28
28
 
29
- #ifndef _MSC_VER
29
+ #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)
30
30
 
31
31
  #ifdef __IPHONEOS__
32
32
  #include <OpenGLES/ES2/gl.h>