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
@@ -45,6 +45,9 @@ extern "C" {
45
45
  #define SDL_RWOPS_JNIFILE 3U /**< Android asset */
46
46
  #define SDL_RWOPS_MEMORY 4U /**< Memory stream */
47
47
  #define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */
48
+ #if defined(__VITA__)
49
+ #define SDL_RWOPS_VITAFILE 6U /**< Vita file */
50
+ #endif
48
51
 
49
52
  /**
50
53
  * This is the read/write operation structure -- very basic.
@@ -110,6 +113,17 @@ typedef struct SDL_RWops
110
113
  size_t left;
111
114
  } buffer;
112
115
  } windowsio;
116
+ #elif defined(__VITA__)
117
+ struct
118
+ {
119
+ int h;
120
+ struct
121
+ {
122
+ void *data;
123
+ size_t size;
124
+ size_t left;
125
+ } buffer;
126
+ } vitaio;
113
127
  #endif
114
128
 
115
129
  #ifdef HAVE_STDIO_H
@@ -142,25 +156,228 @@ typedef struct SDL_RWops
142
156
  */
143
157
  /* @{ */
144
158
 
159
+ /**
160
+ * Use this function to create a new SDL_RWops structure for reading from
161
+ * and/or writing to a named file.
162
+ *
163
+ * The `mode` string is treated roughly the same as in a call to the C
164
+ * library's fopen(), even if SDL doesn't happen to use fopen() behind the
165
+ * scenes.
166
+ *
167
+ * Available `mode` strings:
168
+ *
169
+ * - "r": Open a file for reading. The file must exist.
170
+ * - "w": Create an empty file for writing. If a file with the same name
171
+ * already exists its content is erased and the file is treated as a new
172
+ * empty file.
173
+ * - "a": Append to a file. Writing operations append data at the end of the
174
+ * file. The file is created if it does not exist.
175
+ * - "r+": Open a file for update both reading and writing. The file must
176
+ * exist.
177
+ * - "w+": Create an empty file for both reading and writing. If a file with
178
+ * the same name already exists its content is erased and the file is
179
+ * treated as a new empty file.
180
+ * - "a+": Open a file for reading and appending. All writing operations are
181
+ * performed at the end of the file, protecting the previous content to be
182
+ * overwritten. You can reposition (fseek, rewind) the internal pointer to
183
+ * anywhere in the file for reading, but writing operations will move it
184
+ * back to the end of file. The file is created if it does not exist.
185
+ *
186
+ * **NOTE**: In order to open a file as a binary file, a "b" character has to
187
+ * be included in the `mode` string. This additional "b" character can either
188
+ * be appended at the end of the string (thus making the following compound
189
+ * modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the
190
+ * letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+").
191
+ * Additional characters may follow the sequence, although they should have no
192
+ * effect. For example, "t" is sometimes appended to make explicit the file is
193
+ * a text file.
194
+ *
195
+ * This function supports Unicode filenames, but they must be encoded in UTF-8
196
+ * format, regardless of the underlying operating system.
197
+ *
198
+ * As a fallback, SDL_RWFromFile() will transparently open a matching filename
199
+ * in an Android app's `assets`.
200
+ *
201
+ * Closing the SDL_RWops will close the file handle SDL is holding internally.
202
+ *
203
+ * \param file a UTF-8 string representing the filename to open
204
+ * \param mode an ASCII string representing the mode to be used for opening
205
+ * the file.
206
+ * \returns a pointer to the SDL_RWops structure that is created, or NULL on
207
+ * failure; call SDL_GetError() for more information.
208
+ *
209
+ * \since This function is available since SDL 2.0.0.
210
+ *
211
+ * \sa SDL_RWclose
212
+ * \sa SDL_RWFromConstMem
213
+ * \sa SDL_RWFromFP
214
+ * \sa SDL_RWFromMem
215
+ * \sa SDL_RWread
216
+ * \sa SDL_RWseek
217
+ * \sa SDL_RWtell
218
+ * \sa SDL_RWwrite
219
+ */
145
220
  extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
146
221
  const char *mode);
147
222
 
148
223
  #ifdef HAVE_STDIO_H
149
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp,
150
- SDL_bool autoclose);
224
+
225
+ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, SDL_bool autoclose);
226
+
151
227
  #else
228
+
229
+ /**
230
+ * Use this function to create an SDL_RWops structure from a standard I/O file
231
+ * pointer (stdio.h's `FILE*`).
232
+ *
233
+ * This function is not available on Windows, since files opened in an
234
+ * application on that platform cannot be used by a dynamically linked
235
+ * library.
236
+ *
237
+ * On some platforms, the first parameter is a `void*`, on others, it's a
238
+ * `FILE*`, depending on what system headers are available to SDL. It is
239
+ * always intended to be the `FILE*` type from the C runtime's stdio.h.
240
+ *
241
+ * \param fp the `FILE*` that feeds the SDL_RWops stream
242
+ * \param autoclose SDL_TRUE to close the `FILE*` when closing the SDL_RWops,
243
+ * SDL_FALSE to leave the `FILE*` open when the RWops is
244
+ * closed
245
+ * \returns a pointer to the SDL_RWops structure that is created, or NULL on
246
+ * failure; call SDL_GetError() for more information.
247
+ *
248
+ * \since This function is available since SDL 2.0.0.
249
+ *
250
+ * \sa SDL_RWclose
251
+ * \sa SDL_RWFromConstMem
252
+ * \sa SDL_RWFromFile
253
+ * \sa SDL_RWFromMem
254
+ * \sa SDL_RWread
255
+ * \sa SDL_RWseek
256
+ * \sa SDL_RWtell
257
+ * \sa SDL_RWwrite
258
+ */
152
259
  extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp,
153
260
  SDL_bool autoclose);
154
261
  #endif
155
262
 
263
+ /**
264
+ * Use this function to prepare a read-write memory buffer for use with
265
+ * SDL_RWops.
266
+ *
267
+ * This function sets up an SDL_RWops struct based on a memory area of a
268
+ * certain size, for both read and write access.
269
+ *
270
+ * This memory buffer is not copied by the RWops; the pointer you provide must
271
+ * remain valid until you close the stream. Closing the stream will not free
272
+ * the original buffer.
273
+ *
274
+ * If you need to make sure the RWops never writes to the memory buffer, you
275
+ * should use SDL_RWFromConstMem() with a read-only buffer of memory instead.
276
+ *
277
+ * \param mem a pointer to a buffer to feed an SDL_RWops stream
278
+ * \param size the buffer size, in bytes
279
+ * \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
280
+ * SDL_GetError() for more information.
281
+ *
282
+ * \since This function is available since SDL 2.0.0.
283
+ *
284
+ * \sa SDL_RWclose
285
+ * \sa SDL_RWFromConstMem
286
+ * \sa SDL_RWFromFile
287
+ * \sa SDL_RWFromFP
288
+ * \sa SDL_RWFromMem
289
+ * \sa SDL_RWread
290
+ * \sa SDL_RWseek
291
+ * \sa SDL_RWtell
292
+ * \sa SDL_RWwrite
293
+ */
156
294
  extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
295
+
296
+ /**
297
+ * Use this function to prepare a read-only memory buffer for use with RWops.
298
+ *
299
+ * This function sets up an SDL_RWops struct based on a memory area of a
300
+ * certain size. It assumes the memory area is not writable.
301
+ *
302
+ * Attempting to write to this RWops stream will report an error without
303
+ * writing to the memory buffer.
304
+ *
305
+ * This memory buffer is not copied by the RWops; the pointer you provide must
306
+ * remain valid until you close the stream. Closing the stream will not free
307
+ * the original buffer.
308
+ *
309
+ * If you need to write to a memory buffer, you should use SDL_RWFromMem()
310
+ * with a writable buffer of memory instead.
311
+ *
312
+ * \param mem a pointer to a read-only buffer to feed an SDL_RWops stream
313
+ * \param size the buffer size, in bytes
314
+ * \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
315
+ * SDL_GetError() for more information.
316
+ *
317
+ * \since This function is available since SDL 2.0.0.
318
+ *
319
+ * \sa SDL_RWclose
320
+ * \sa SDL_RWFromConstMem
321
+ * \sa SDL_RWFromFile
322
+ * \sa SDL_RWFromFP
323
+ * \sa SDL_RWFromMem
324
+ * \sa SDL_RWread
325
+ * \sa SDL_RWseek
326
+ * \sa SDL_RWtell
327
+ */
157
328
  extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
158
329
  int size);
159
330
 
160
331
  /* @} *//* RWFrom functions */
161
332
 
162
333
 
334
+ /**
335
+ * Use this function to allocate an empty, unpopulated SDL_RWops structure.
336
+ *
337
+ * Applications do not need to use this function unless they are providing
338
+ * their own SDL_RWops implementation. If you just need a SDL_RWops to
339
+ * read/write a common data source, you should use the built-in
340
+ * implementations in SDL, like SDL_RWFromFile() or SDL_RWFromMem(), etc.
341
+ *
342
+ * You must free the returned pointer with SDL_FreeRW(). Depending on your
343
+ * operating system and compiler, there may be a difference between the
344
+ * malloc() and free() your program uses and the versions SDL calls
345
+ * internally. Trying to mix the two can cause crashing such as segmentation
346
+ * faults. Since all SDL_RWops must free themselves when their **close**
347
+ * method is called, all SDL_RWops must be allocated through this function, so
348
+ * they can all be freed correctly with SDL_FreeRW().
349
+ *
350
+ * \returns a pointer to the allocated memory on success, or NULL on failure;
351
+ * call SDL_GetError() for more information.
352
+ *
353
+ * \since This function is available since SDL 2.0.0.
354
+ *
355
+ * \sa SDL_FreeRW
356
+ */
163
357
  extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
358
+
359
+ /**
360
+ * Use this function to free an SDL_RWops structure allocated by
361
+ * SDL_AllocRW().
362
+ *
363
+ * Applications do not need to use this function unless they are providing
364
+ * their own SDL_RWops implementation. If you just need a SDL_RWops to
365
+ * read/write a common data source, you should use the built-in
366
+ * implementations in SDL, like SDL_RWFromFile() or SDL_RWFromMem(), etc, and
367
+ * call the **close** method on those SDL_RWops pointers when you are done
368
+ * with them.
369
+ *
370
+ * Only use SDL_FreeRW() on pointers returned by SDL_AllocRW(). The pointer is
371
+ * invalid as soon as this function returns. Any extra memory allocated during
372
+ * creation of the SDL_RWops is not freed by SDL_FreeRW(); the programmer must
373
+ * be responsible for managing that memory in their **close** method.
374
+ *
375
+ * \param area the SDL_RWops structure to be freed
376
+ *
377
+ * \since This function is available since SDL 2.0.0.
378
+ *
379
+ * \sa SDL_AllocRW
380
+ */
164
381
  extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
165
382
 
166
383
  #define RW_SEEK_SET 0 /**< Seek from the beginning of data */
@@ -168,77 +385,218 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
168
385
  #define RW_SEEK_END 2 /**< Seek relative to the end of data */
169
386
 
170
387
  /**
171
- * Return the size of the file in this rwops, or -1 if unknown
388
+ * Use this function to get the size of the data stream in an SDL_RWops.
389
+ *
390
+ * Prior to SDL 2.0.10, this function was a macro.
391
+ *
392
+ * \param context the SDL_RWops to get the size of the data stream from
393
+ * \returns the size of the data stream in the SDL_RWops on success, -1 if
394
+ * unknown or a negative error code on failure; call SDL_GetError()
395
+ * for more information.
396
+ *
397
+ * \since This function is available since SDL 2.0.10.
172
398
  */
173
399
  extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
174
400
 
175
401
  /**
176
- * Seek to \c offset relative to \c whence, one of stdio's whence values:
177
- * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
402
+ * Seek within an SDL_RWops data stream.
403
+ *
404
+ * This function seeks to byte `offset`, relative to `whence`.
405
+ *
406
+ * `whence` may be any of the following values:
407
+ *
408
+ * - `RW_SEEK_SET`: seek from the beginning of data
409
+ * - `RW_SEEK_CUR`: seek relative to current read point
410
+ * - `RW_SEEK_END`: seek relative to the end of data
411
+ *
412
+ * If this stream can not seek, it will return -1.
413
+ *
414
+ * SDL_RWseek() is actually a wrapper function that calls the SDL_RWops's
415
+ * `seek` method appropriately, to simplify application development.
178
416
  *
179
- * \return the final offset in the data stream, or -1 on error.
417
+ * Prior to SDL 2.0.10, this function was a macro.
418
+ *
419
+ * \param context a pointer to an SDL_RWops structure
420
+ * \param offset an offset in bytes, relative to **whence** location; can be
421
+ * negative
422
+ * \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END`
423
+ * \returns the final offset in the data stream after the seek or -1 on error.
424
+ *
425
+ * \since This function is available since SDL 2.0.10.
426
+ *
427
+ * \sa SDL_RWclose
428
+ * \sa SDL_RWFromConstMem
429
+ * \sa SDL_RWFromFile
430
+ * \sa SDL_RWFromFP
431
+ * \sa SDL_RWFromMem
432
+ * \sa SDL_RWread
433
+ * \sa SDL_RWtell
434
+ * \sa SDL_RWwrite
180
435
  */
181
436
  extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context,
182
437
  Sint64 offset, int whence);
183
438
 
184
439
  /**
185
- * Return the current offset in the data stream, or -1 on error.
440
+ * Determine the current read/write offset in an SDL_RWops data stream.
441
+ *
442
+ * SDL_RWtell is actually a wrapper function that calls the SDL_RWops's `seek`
443
+ * method, with an offset of 0 bytes from `RW_SEEK_CUR`, to simplify
444
+ * application development.
445
+ *
446
+ * Prior to SDL 2.0.10, this function was a macro.
447
+ *
448
+ * \param context a SDL_RWops data stream object from which to get the current
449
+ * offset
450
+ * \returns the current offset in the stream, or -1 if the information can not
451
+ * be determined.
452
+ *
453
+ * \since This function is available since SDL 2.0.10.
454
+ *
455
+ * \sa SDL_RWclose
456
+ * \sa SDL_RWFromConstMem
457
+ * \sa SDL_RWFromFile
458
+ * \sa SDL_RWFromFP
459
+ * \sa SDL_RWFromMem
460
+ * \sa SDL_RWread
461
+ * \sa SDL_RWseek
462
+ * \sa SDL_RWwrite
186
463
  */
187
464
  extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
188
465
 
189
466
  /**
190
- * Read up to \c maxnum objects each of size \c size from the data
191
- * stream to the area pointed at by \c ptr.
467
+ * Read from a data source.
468
+ *
469
+ * This function reads up to `maxnum` objects each of size `size` from the
470
+ * data source to the area pointed at by `ptr`. This function may read less
471
+ * objects than requested. It will return zero when there has been an error or
472
+ * the data stream is completely read.
473
+ *
474
+ * SDL_RWread() is actually a function wrapper that calls the SDL_RWops's
475
+ * `read` method appropriately, to simplify application development.
476
+ *
477
+ * Prior to SDL 2.0.10, this function was a macro.
478
+ *
479
+ * \param context a pointer to an SDL_RWops structure
480
+ * \param ptr a pointer to a buffer to read data into
481
+ * \param size the size of each object to read, in bytes
482
+ * \param maxnum the maximum number of objects to be read
483
+ * \returns the number of objects read, or 0 at error or end of file; call
484
+ * SDL_GetError() for more information.
192
485
  *
193
- * \return the number of objects read, or 0 at error or end of file.
486
+ * \since This function is available since SDL 2.0.10.
487
+ *
488
+ * \sa SDL_RWclose
489
+ * \sa SDL_RWFromConstMem
490
+ * \sa SDL_RWFromFile
491
+ * \sa SDL_RWFromFP
492
+ * \sa SDL_RWFromMem
493
+ * \sa SDL_RWseek
494
+ * \sa SDL_RWwrite
194
495
  */
195
496
  extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context,
196
- void *ptr, size_t size, size_t maxnum);
497
+ void *ptr, size_t size,
498
+ size_t maxnum);
197
499
 
198
500
  /**
199
- * Write exactly \c num objects each of size \c size from the area
200
- * pointed at by \c ptr to data stream.
501
+ * Write to an SDL_RWops data stream.
502
+ *
503
+ * This function writes exactly `num` objects each of size `size` from the
504
+ * area pointed at by `ptr` to the stream. If this fails for any reason, it'll
505
+ * return less than `num` to demonstrate how far the write progressed. On
506
+ * success, it returns `num`.
507
+ *
508
+ * SDL_RWwrite is actually a function wrapper that calls the SDL_RWops's
509
+ * `write` method appropriately, to simplify application development.
510
+ *
511
+ * Prior to SDL 2.0.10, this function was a macro.
512
+ *
513
+ * \param context a pointer to an SDL_RWops structure
514
+ * \param ptr a pointer to a buffer containing data to write
515
+ * \param size the size of an object to write, in bytes
516
+ * \param num the number of objects to write
517
+ * \returns the number of objects written, which will be less than **num** on
518
+ * error; call SDL_GetError() for more information.
519
+ *
520
+ * \since This function is available since SDL 2.0.10.
201
521
  *
202
- * \return the number of objects written, or 0 at error or end of file.
522
+ * \sa SDL_RWclose
523
+ * \sa SDL_RWFromConstMem
524
+ * \sa SDL_RWFromFile
525
+ * \sa SDL_RWFromFP
526
+ * \sa SDL_RWFromMem
527
+ * \sa SDL_RWread
528
+ * \sa SDL_RWseek
203
529
  */
204
530
  extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context,
205
- const void *ptr, size_t size, size_t num);
531
+ const void *ptr, size_t size,
532
+ size_t num);
206
533
 
207
534
  /**
208
- * Close and free an allocated SDL_RWops structure.
535
+ * Close and free an allocated SDL_RWops structure.
209
536
  *
210
- * \return 0 if successful or -1 on write error when flushing data.
537
+ * SDL_RWclose() closes and cleans up the SDL_RWops stream. It releases any
538
+ * resources used by the stream and frees the SDL_RWops itself with
539
+ * SDL_FreeRW(). This returns 0 on success, or -1 if the stream failed to
540
+ * flush to its output (e.g. to disk).
541
+ *
542
+ * Note that if this fails to flush the stream to disk, this function reports
543
+ * an error, but the SDL_RWops is still invalid once this function returns.
544
+ *
545
+ * Prior to SDL 2.0.10, this function was a macro.
546
+ *
547
+ * \param context SDL_RWops structure to close
548
+ * \returns 0 on success or a negative error code on failure; call
549
+ * SDL_GetError() for more information.
550
+ *
551
+ * \since This function is available since SDL 2.0.10.
552
+ *
553
+ * \sa SDL_RWFromConstMem
554
+ * \sa SDL_RWFromFile
555
+ * \sa SDL_RWFromFP
556
+ * \sa SDL_RWFromMem
557
+ * \sa SDL_RWread
558
+ * \sa SDL_RWseek
559
+ * \sa SDL_RWwrite
211
560
  */
212
561
  extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context);
213
562
 
214
563
  /**
215
- * Load all the data from an SDL data stream.
216
- *
217
- * The data is allocated with a zero byte at the end (null terminated)
564
+ * Load all the data from an SDL data stream.
218
565
  *
219
- * If \c datasize is not NULL, it is filled with the size of the data read.
566
+ * The data is allocated with a zero byte at the end (null terminated) for
567
+ * convenience. This extra byte is not included in the value reported via
568
+ * `datasize`.
220
569
  *
221
- * If \c freesrc is non-zero, the stream will be closed after being read.
570
+ * The data should be freed with SDL_free().
222
571
  *
223
- * The data should be freed with SDL_free().
572
+ * \param src the SDL_RWops to read all available data from
573
+ * \param datasize if not NULL, will store the number of bytes read
574
+ * \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning
575
+ * \returns the data, or NULL if there was an error.
224
576
  *
225
- * \return the data, or NULL if there was an error.
577
+ * \since This function is available since SDL 2.0.6.
226
578
  */
227
- extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize,
228
- int freesrc);
579
+ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src,
580
+ size_t *datasize,
581
+ int freesrc);
229
582
 
230
583
  /**
231
- * Load an entire file.
584
+ * Load all the data from a file path.
232
585
  *
233
- * The data is allocated with a zero byte at the end (null terminated)
586
+ * The data is allocated with a zero byte at the end (null terminated) for
587
+ * convenience. This extra byte is not included in the value reported via
588
+ * `datasize`.
234
589
  *
235
- * If \c datasize is not NULL, it is filled with the size of the data read.
590
+ * The data should be freed with SDL_free().
236
591
  *
237
- * If \c freesrc is non-zero, the stream will be closed after being read.
592
+ * Prior to SDL 2.0.10, this function was a macro wrapping around
593
+ * SDL_LoadFile_RW.
238
594
  *
239
- * The data should be freed with SDL_free().
595
+ * \param file the path to read all available data from
596
+ * \param datasize if not NULL, will store the number of bytes read
597
+ * \returns the data, or NULL if there was an error.
240
598
  *
241
- * \return the data, or NULL if there was an error.
599
+ * \since This function is available since SDL 2.0.10.
242
600
  */
243
601
  extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
244
602
 
@@ -248,12 +606,114 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
248
606
  * Read an item of the specified endianness and return in native format.
249
607
  */
250
608
  /* @{ */
609
+
610
+ /**
611
+ * Use this function to read a byte from an SDL_RWops.
612
+ *
613
+ * \param src the SDL_RWops to read from
614
+ * \returns the read byte on success or 0 on failure; call SDL_GetError() for
615
+ * more information.
616
+ *
617
+ * \since This function is available since SDL 2.0.0.
618
+ *
619
+ * \sa SDL_WriteU8
620
+ */
251
621
  extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
622
+
623
+ /**
624
+ * Use this function to read 16 bits of little-endian data from an SDL_RWops
625
+ * and return in native format.
626
+ *
627
+ * SDL byteswaps the data only if necessary, so the data returned will be in
628
+ * the native byte order.
629
+ *
630
+ * \param src the stream from which to read data
631
+ * \returns 16 bits of data in the native byte order of the platform.
632
+ *
633
+ * \since This function is available since SDL 2.0.0.
634
+ *
635
+ * \sa SDL_ReadBE16
636
+ */
252
637
  extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
638
+
639
+ /**
640
+ * Use this function to read 16 bits of big-endian data from an SDL_RWops and
641
+ * return in native format.
642
+ *
643
+ * SDL byteswaps the data only if necessary, so the data returned will be in
644
+ * the native byte order.
645
+ *
646
+ * \param src the stream from which to read data
647
+ * \returns 16 bits of data in the native byte order of the platform.
648
+ *
649
+ * \since This function is available since SDL 2.0.0.
650
+ *
651
+ * \sa SDL_ReadLE16
652
+ */
253
653
  extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
654
+
655
+ /**
656
+ * Use this function to read 32 bits of little-endian data from an SDL_RWops
657
+ * and return in native format.
658
+ *
659
+ * SDL byteswaps the data only if necessary, so the data returned will be in
660
+ * the native byte order.
661
+ *
662
+ * \param src the stream from which to read data
663
+ * \returns 32 bits of data in the native byte order of the platform.
664
+ *
665
+ * \since This function is available since SDL 2.0.0.
666
+ *
667
+ * \sa SDL_ReadBE32
668
+ */
254
669
  extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
670
+
671
+ /**
672
+ * Use this function to read 32 bits of big-endian data from an SDL_RWops and
673
+ * return in native format.
674
+ *
675
+ * SDL byteswaps the data only if necessary, so the data returned will be in
676
+ * the native byte order.
677
+ *
678
+ * \param src the stream from which to read data
679
+ * \returns 32 bits of data in the native byte order of the platform.
680
+ *
681
+ * \since This function is available since SDL 2.0.0.
682
+ *
683
+ * \sa SDL_ReadLE32
684
+ */
255
685
  extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
686
+
687
+ /**
688
+ * Use this function to read 64 bits of little-endian data from an SDL_RWops
689
+ * and return in native format.
690
+ *
691
+ * SDL byteswaps the data only if necessary, so the data returned will be in
692
+ * the native byte order.
693
+ *
694
+ * \param src the stream from which to read data
695
+ * \returns 64 bits of data in the native byte order of the platform.
696
+ *
697
+ * \since This function is available since SDL 2.0.0.
698
+ *
699
+ * \sa SDL_ReadBE64
700
+ */
256
701
  extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
702
+
703
+ /**
704
+ * Use this function to read 64 bits of big-endian data from an SDL_RWops and
705
+ * return in native format.
706
+ *
707
+ * SDL byteswaps the data only if necessary, so the data returned will be in
708
+ * the native byte order.
709
+ *
710
+ * \param src the stream from which to read data
711
+ * \returns 64 bits of data in the native byte order of the platform.
712
+ *
713
+ * \since This function is available since SDL 2.0.0.
714
+ *
715
+ * \sa SDL_ReadLE64
716
+ */
257
717
  extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
258
718
  /* @} *//* Read endian functions */
259
719
 
@@ -263,12 +723,124 @@ extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
263
723
  * Write an item of native format to the specified endianness.
264
724
  */
265
725
  /* @{ */
726
+
727
+ /**
728
+ * Use this function to write a byte to an SDL_RWops.
729
+ *
730
+ * \param dst the SDL_RWops to write to
731
+ * \param value the byte value to write
732
+ * \returns 1 on success or 0 on failure; call SDL_GetError() for more
733
+ * information.
734
+ *
735
+ * \since This function is available since SDL 2.0.0.
736
+ *
737
+ * \sa SDL_ReadU8
738
+ */
266
739
  extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
740
+
741
+ /**
742
+ * Use this function to write 16 bits in native format to a SDL_RWops as
743
+ * little-endian data.
744
+ *
745
+ * SDL byteswaps the data only if necessary, so the application always
746
+ * specifies native format, and the data written will be in little-endian
747
+ * format.
748
+ *
749
+ * \param dst the stream to which data will be written
750
+ * \param value the data to be written, in native format
751
+ * \returns 1 on successful write, 0 on error.
752
+ *
753
+ * \since This function is available since SDL 2.0.0.
754
+ *
755
+ * \sa SDL_WriteBE16
756
+ */
267
757
  extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
758
+
759
+ /**
760
+ * Use this function to write 16 bits in native format to a SDL_RWops as
761
+ * big-endian data.
762
+ *
763
+ * SDL byteswaps the data only if necessary, so the application always
764
+ * specifies native format, and the data written will be in big-endian format.
765
+ *
766
+ * \param dst the stream to which data will be written
767
+ * \param value the data to be written, in native format
768
+ * \returns 1 on successful write, 0 on error.
769
+ *
770
+ * \since This function is available since SDL 2.0.0.
771
+ *
772
+ * \sa SDL_WriteLE16
773
+ */
268
774
  extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
775
+
776
+ /**
777
+ * Use this function to write 32 bits in native format to a SDL_RWops as
778
+ * little-endian data.
779
+ *
780
+ * SDL byteswaps the data only if necessary, so the application always
781
+ * specifies native format, and the data written will be in little-endian
782
+ * format.
783
+ *
784
+ * \param dst the stream to which data will be written
785
+ * \param value the data to be written, in native format
786
+ * \returns 1 on successful write, 0 on error.
787
+ *
788
+ * \since This function is available since SDL 2.0.0.
789
+ *
790
+ * \sa SDL_WriteBE32
791
+ */
269
792
  extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
793
+
794
+ /**
795
+ * Use this function to write 32 bits in native format to a SDL_RWops as
796
+ * big-endian data.
797
+ *
798
+ * SDL byteswaps the data only if necessary, so the application always
799
+ * specifies native format, and the data written will be in big-endian format.
800
+ *
801
+ * \param dst the stream to which data will be written
802
+ * \param value the data to be written, in native format
803
+ * \returns 1 on successful write, 0 on error.
804
+ *
805
+ * \since This function is available since SDL 2.0.0.
806
+ *
807
+ * \sa SDL_WriteLE32
808
+ */
270
809
  extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
810
+
811
+ /**
812
+ * Use this function to write 64 bits in native format to a SDL_RWops as
813
+ * little-endian data.
814
+ *
815
+ * SDL byteswaps the data only if necessary, so the application always
816
+ * specifies native format, and the data written will be in little-endian
817
+ * format.
818
+ *
819
+ * \param dst the stream to which data will be written
820
+ * \param value the data to be written, in native format
821
+ * \returns 1 on successful write, 0 on error.
822
+ *
823
+ * \since This function is available since SDL 2.0.0.
824
+ *
825
+ * \sa SDL_WriteBE64
826
+ */
271
827
  extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
828
+
829
+ /**
830
+ * Use this function to write 64 bits in native format to a SDL_RWops as
831
+ * big-endian data.
832
+ *
833
+ * SDL byteswaps the data only if necessary, so the application always
834
+ * specifies native format, and the data written will be in big-endian format.
835
+ *
836
+ * \param dst the stream to which data will be written
837
+ * \param value the data to be written, in native format
838
+ * \returns 1 on successful write, 0 on error.
839
+ *
840
+ * \since This function is available since SDL 2.0.0.
841
+ *
842
+ * \sa SDL_WriteLE64
843
+ */
272
844
  extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value);
273
845
  /* @} *//* Write endian functions */
274
846