gosu 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +1 -1
  3. data/dependencies/SDL/include/SDL.h +108 -14
  4. data/dependencies/SDL/include/SDL_assert.h +81 -50
  5. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  6. data/dependencies/SDL/include/SDL_audio.h +960 -355
  7. data/dependencies/SDL/include/SDL_bits.h +11 -6
  8. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  9. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  10. data/dependencies/SDL/include/SDL_config.h +277 -27
  11. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  12. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  13. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  14. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  15. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  16. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  17. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  18. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  19. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  20. data/dependencies/SDL/include/SDL_copying.h +1 -1
  21. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  22. data/dependencies/SDL/include/SDL_egl.h +906 -280
  23. data/dependencies/SDL/include/SDL_endian.h +101 -47
  24. data/dependencies/SDL/include/SDL_error.h +70 -19
  25. data/dependencies/SDL/include/SDL_events.h +387 -79
  26. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  27. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  28. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  29. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  30. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  31. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  32. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  33. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  34. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  35. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  36. data/dependencies/SDL/include/SDL_locale.h +34 -32
  37. data/dependencies/SDL/include/SDL_log.h +212 -19
  38. data/dependencies/SDL/include/SDL_main.h +72 -17
  39. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  40. data/dependencies/SDL/include/SDL_metal.h +27 -32
  41. data/dependencies/SDL/include/SDL_misc.h +19 -15
  42. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  43. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  44. data/dependencies/SDL/include/SDL_name.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  47. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  48. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  49. data/dependencies/SDL/include/SDL_platform.h +39 -2
  50. data/dependencies/SDL/include/SDL_power.h +23 -10
  51. data/dependencies/SDL/include/SDL_quit.h +1 -1
  52. data/dependencies/SDL/include/SDL_rect.h +78 -28
  53. data/dependencies/SDL/include/SDL_render.h +1204 -472
  54. data/dependencies/SDL/include/SDL_revision.h +2 -2
  55. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  56. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  57. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  58. data/dependencies/SDL/include/SDL_shape.h +38 -27
  59. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  60. data/dependencies/SDL/include/SDL_surface.h +571 -139
  61. data/dependencies/SDL/include/SDL_system.h +339 -101
  62. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  63. data/dependencies/SDL/include/SDL_test.h +1 -1
  64. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  65. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  66. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  68. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  69. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  70. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  71. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  75. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  76. data/dependencies/SDL/include/SDL_thread.h +226 -128
  77. data/dependencies/SDL/include/SDL_timer.h +129 -22
  78. data/dependencies/SDL/include/SDL_touch.h +48 -8
  79. data/dependencies/SDL/include/SDL_types.h +1 -1
  80. data/dependencies/SDL/include/SDL_version.h +72 -46
  81. data/dependencies/SDL/include/SDL_video.h +1266 -460
  82. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  83. data/dependencies/SDL/include/begin_code.h +22 -1
  84. data/dependencies/SDL/include/close_code.h +1 -1
  85. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  88. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  90. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  101. data/dependencies/SDL_sound/dr_flac.h +618 -220
  102. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  105. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  106. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  107. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  108. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  109. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  110. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  111. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  112. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  113. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  114. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  115. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  116. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  117. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  118. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  119. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  120. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  121. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  122. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  123. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  124. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  125. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  126. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  127. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  128. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  129. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  130. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  131. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  132. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  133. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  134. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  135. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  136. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  137. data/dependencies/mojoAL/mojoal.c +4594 -0
  138. data/ext/gosu/extconf.rb +33 -30
  139. data/include/Gosu/Audio.hpp +70 -85
  140. data/include/Gosu/Color.hpp +63 -107
  141. data/include/Gosu/Font.hpp +44 -50
  142. data/include/Gosu/Fwd.hpp +1 -1
  143. data/include/Gosu/Graphics.hpp +64 -75
  144. data/include/Gosu/GraphicsBase.hpp +32 -39
  145. data/include/Gosu/Image.hpp +56 -62
  146. data/include/Gosu/ImageData.hpp +23 -27
  147. data/include/Gosu/Inspection.hpp +1 -4
  148. data/include/Gosu/Math.hpp +4 -16
  149. data/include/Gosu/Platform.hpp +1 -51
  150. data/include/Gosu/Text.hpp +37 -40
  151. data/include/Gosu/TextInput.hpp +34 -40
  152. data/include/Gosu/Utility.hpp +10 -8
  153. data/include/Gosu/Version.hpp +1 -1
  154. data/include/Gosu/Window.hpp +73 -70
  155. data/lib/SDL2.dll +0 -0
  156. data/lib/gosu/compat.rb +28 -37
  157. data/lib/gosu/swig_patches.rb +31 -3
  158. data/lib/gosu.rb +2 -2
  159. data/lib64/SDL2.dll +0 -0
  160. data/rdoc/gosu.rb +9 -1
  161. data/src/Audio.cpp +86 -86
  162. data/src/AudioFile.hpp +6 -6
  163. data/src/AudioFileAudioToolbox.cpp +1 -1
  164. data/src/AudioFileSDLSound.cpp +1 -1
  165. data/src/AudioImpl.hpp +5 -5
  166. data/src/Bitmap.cpp +13 -13
  167. data/src/BitmapIO.cpp +0 -20
  168. data/src/BlockAllocator.cpp +2 -1
  169. data/src/Channel.cpp +22 -20
  170. data/src/Color.cpp +62 -55
  171. data/src/EmptyImageData.hpp +16 -18
  172. data/src/FileUnix.cpp +1 -1
  173. data/src/FileWin.cpp +1 -1
  174. data/src/Font.cpp +52 -57
  175. data/src/GosuViewController.cpp +2 -0
  176. data/src/Graphics.cpp +135 -143
  177. data/src/Image.cpp +42 -42
  178. data/src/Input.cpp +1 -1
  179. data/src/InputUIKit.cpp +1 -1
  180. data/src/LargeImageData.cpp +120 -113
  181. data/src/LargeImageData.hpp +18 -16
  182. data/src/Log.hpp +6 -6
  183. data/src/Macro.cpp +124 -169
  184. data/src/Macro.hpp +11 -11
  185. data/src/Math.cpp +8 -1
  186. data/src/RenderState.hpp +5 -5
  187. data/src/Resolution.cpp +114 -61
  188. data/src/RubyGosu.cxx +470 -501
  189. data/src/RubyGosu.h +3 -2
  190. data/src/TexChunk.cpp +50 -41
  191. data/src/TexChunk.hpp +22 -22
  192. data/src/Text.cpp +58 -59
  193. data/src/TextBuilder.cpp +60 -57
  194. data/src/TextBuilder.hpp +20 -20
  195. data/src/TextInput.cpp +127 -135
  196. data/src/TrueTypeFont.cpp +108 -108
  197. data/src/TrueTypeFont.hpp +39 -38
  198. data/src/TrueTypeFontApple.cpp +27 -23
  199. data/src/TrueTypeFontUnix.cpp +21 -26
  200. data/src/TrueTypeFontWin.cpp +30 -30
  201. data/src/Utility.cpp +82 -23
  202. data/src/WinUtility.hpp +2 -1
  203. data/src/Window.cpp +103 -86
  204. data/src/WindowUIKit.cpp +48 -51
  205. metadata +8 -20
  206. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  207. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  208. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  209. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  210. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  211. data/dependencies/al_soft/AL/alext.h +0 -585
  212. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  213. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  214. data/dependencies/al_soft/AL/efx.h +0 -762
  215. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  216. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  217. data/lib/OpenAL32.dll +0 -0
  218. data/lib64/OpenAL32.dll +0 -0
  219. data/src/UtilityApple.cpp +0 -16
  220. data/src/UtilityWin.cpp +0 -17
@@ -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
@@ -112,31 +112,108 @@ typedef enum
112
112
  } SDL_YUV_CONVERSION_MODE;
113
113
 
114
114
  /**
115
- * Allocate and free an RGB surface.
115
+ * Allocate a new RGB surface.
116
116
  *
117
- * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
118
- * If the depth is greater than 8 bits, the pixel format is set using the
119
- * flags '[RGB]mask'.
117
+ * If `depth` is 4 or 8 bits, an empty palette is allocated for the surface.
118
+ * If `depth` is greater than 8 bits, the pixel format is set using the
119
+ * [RGBA]mask parameters.
120
120
  *
121
- * If the function runs out of memory, it will return NULL.
121
+ * The [RGBA]mask parameters are the bitmasks used to extract that color from
122
+ * a pixel. For instance, `Rmask` being 0xFF000000 means the red data is
123
+ * stored in the most significant byte. Using zeros for the RGB masks sets a
124
+ * default value, based on the depth. For example:
122
125
  *
123
- * \param flags The \c flags are obsolete and should be set to 0.
124
- * \param width The width in pixels of the surface to create.
125
- * \param height The height in pixels of the surface to create.
126
- * \param depth The depth in bits of the surface to create.
127
- * \param Rmask The red mask of the surface to create.
128
- * \param Gmask The green mask of the surface to create.
129
- * \param Bmask The blue mask of the surface to create.
130
- * \param Amask The alpha mask of the surface to create.
126
+ * ```c++
127
+ * SDL_CreateRGBSurface(0,w,h,32,0,0,0,0);
128
+ * ```
129
+ *
130
+ * However, using zero for the Amask results in an Amask of 0.
131
+ *
132
+ * By default surfaces with an alpha mask are set up for blending as with:
133
+ *
134
+ * ```c++
135
+ * SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND)
136
+ * ```
137
+ *
138
+ * You can change this by calling SDL_SetSurfaceBlendMode() and selecting a
139
+ * different `blendMode`.
140
+ *
141
+ * \param flags the flags are unused and should be set to 0
142
+ * \param width the width of the surface
143
+ * \param height the height of the surface
144
+ * \param depth the depth of the surface in bits
145
+ * \param Rmask the red mask for the pixels
146
+ * \param Gmask the green mask for the pixels
147
+ * \param Bmask the blue mask for the pixels
148
+ * \param Amask the alpha mask for the pixels
149
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
150
+ * call SDL_GetError() for more information.
151
+ *
152
+ * \since This function is available since SDL 2.0.0.
153
+ *
154
+ * \sa SDL_CreateRGBSurfaceFrom
155
+ * \sa SDL_CreateRGBSurfaceWithFormat
156
+ * \sa SDL_FreeSurface
131
157
  */
132
158
  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
133
159
  (Uint32 flags, int width, int height, int depth,
134
160
  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
135
161
 
162
+
136
163
  /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
164
+
165
+ /**
166
+ * Allocate a new RGB surface with a specific pixel format.
167
+ *
168
+ * This function operates mostly like SDL_CreateRGBSurface(), except instead
169
+ * of providing pixel color masks, you provide it with a predefined format
170
+ * from SDL_PixelFormatEnum.
171
+ *
172
+ * \param flags the flags are unused and should be set to 0
173
+ * \param width the width of the surface
174
+ * \param height the height of the surface
175
+ * \param depth the depth of the surface in bits
176
+ * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
177
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
178
+ * call SDL_GetError() for more information.
179
+ *
180
+ * \since This function is available since SDL 2.0.5.
181
+ *
182
+ * \sa SDL_CreateRGBSurface
183
+ * \sa SDL_CreateRGBSurfaceFrom
184
+ * \sa SDL_FreeSurface
185
+ */
137
186
  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
138
187
  (Uint32 flags, int width, int height, int depth, Uint32 format);
139
188
 
189
+ /**
190
+ * Allocate a new RGB surface with existing pixel data.
191
+ *
192
+ * This function operates mostly like SDL_CreateRGBSurface(), except it does
193
+ * not allocate memory for the pixel data, instead the caller provides an
194
+ * existing buffer of data for the surface to use.
195
+ *
196
+ * No copy is made of the pixel data. Pixel data is not managed automatically;
197
+ * you must free the surface before you free the pixel data.
198
+ *
199
+ * \param pixels a pointer to existing pixel data
200
+ * \param width the width of the surface
201
+ * \param height the height of the surface
202
+ * \param depth the depth of the surface in bits
203
+ * \param pitch the pitch of the surface in bytes
204
+ * \param Rmask the red mask for the pixels
205
+ * \param Gmask the green mask for the pixels
206
+ * \param Bmask the blue mask for the pixels
207
+ * \param Amask the alpha mask for the pixels
208
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
209
+ * call SDL_GetError() for more information.
210
+ *
211
+ * \since This function is available since SDL 2.0.0.
212
+ *
213
+ * \sa SDL_CreateRGBSurface
214
+ * \sa SDL_CreateRGBSurfaceWithFormat
215
+ * \sa SDL_FreeSurface
216
+ */
140
217
  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
141
218
  int width,
142
219
  int height,
@@ -146,74 +223,154 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
146
223
  Uint32 Gmask,
147
224
  Uint32 Bmask,
148
225
  Uint32 Amask);
226
+
227
+ /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
228
+
229
+ /**
230
+ * Allocate a new RGB surface with with a specific pixel format and existing
231
+ * pixel data.
232
+ *
233
+ * This function operates mostly like SDL_CreateRGBSurfaceFrom(), except
234
+ * instead of providing pixel color masks, you provide it with a predefined
235
+ * format from SDL_PixelFormatEnum.
236
+ *
237
+ * No copy is made of the pixel data. Pixel data is not managed automatically;
238
+ * you must free the surface before you free the pixel data.
239
+ *
240
+ * \param pixels a pointer to existing pixel data
241
+ * \param width the width of the surface
242
+ * \param height the height of the surface
243
+ * \param depth the depth of the surface in bits
244
+ * \param pitch the pitch of the surface in bytes
245
+ * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
246
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
247
+ * call SDL_GetError() for more information.
248
+ *
249
+ * \since This function is available since SDL 2.0.5.
250
+ *
251
+ * \sa SDL_CreateRGBSurfaceFrom
252
+ * \sa SDL_CreateRGBSurfaceWithFormat
253
+ * \sa SDL_FreeSurface
254
+ */
149
255
  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
150
256
  (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
257
+
258
+ /**
259
+ * Free an RGB surface.
260
+ *
261
+ * It is safe to pass NULL to this function.
262
+ *
263
+ * \param surface the SDL_Surface to free.
264
+ *
265
+ * \since This function is available since SDL 2.0.0.
266
+ *
267
+ * \sa SDL_CreateRGBSurface
268
+ * \sa SDL_CreateRGBSurfaceFrom
269
+ * \sa SDL_LoadBMP
270
+ * \sa SDL_LoadBMP_RW
271
+ */
151
272
  extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
152
273
 
153
274
  /**
154
- * \brief Set the palette used by a surface.
275
+ * Set the palette used by a surface.
276
+ *
277
+ * A single palette can be shared with many surfaces.
155
278
  *
156
- * \return 0, or -1 if the surface format doesn't use a palette.
279
+ * \param surface the SDL_Surface structure to update
280
+ * \param palette the SDL_Palette structure to use
281
+ * \returns 0 on success or a negative error code on failure; call
282
+ * SDL_GetError() for more information.
157
283
  *
158
- * \note A single palette can be shared with many surfaces.
284
+ * \since This function is available since SDL 2.0.0.
159
285
  */
160
286
  extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
161
287
  SDL_Palette * palette);
162
288
 
163
289
  /**
164
- * \brief Sets up a surface for directly accessing the pixels.
290
+ * Set up a surface for directly accessing the pixels.
165
291
  *
166
- * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
167
- * to and read from \c surface->pixels, using the pixel format stored in
168
- * \c surface->format. Once you are done accessing the surface, you should
169
- * use SDL_UnlockSurface() to release it.
292
+ * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to
293
+ * and read from `surface->pixels`, using the pixel format stored in
294
+ * `surface->format`. Once you are done accessing the surface, you should use
295
+ * SDL_UnlockSurface() to release it.
170
296
  *
171
- * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
172
- * to 0, then you can read and write to the surface at any time, and the
173
- * pixel format of the surface will not change.
297
+ * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to
298
+ * 0, then you can read and write to the surface at any time, and the pixel
299
+ * format of the surface will not change.
174
300
  *
175
- * No operating system or library calls should be made between lock/unlock
176
- * pairs, as critical system locks may be held during this time.
301
+ * \param surface the SDL_Surface structure to be locked
302
+ * \returns 0 on success or a negative error code on failure; call
303
+ * SDL_GetError() for more information.
177
304
  *
178
- * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
305
+ * \since This function is available since SDL 2.0.0.
179
306
  *
180
- * \sa SDL_UnlockSurface()
307
+ * \sa SDL_MUSTLOCK
308
+ * \sa SDL_UnlockSurface
181
309
  */
182
310
  extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
183
- /** \sa SDL_LockSurface() */
311
+
312
+ /**
313
+ * Release a surface after directly accessing the pixels.
314
+ *
315
+ * \param surface the SDL_Surface structure to be unlocked
316
+ *
317
+ * \since This function is available since SDL 2.0.0.
318
+ *
319
+ * \sa SDL_LockSurface
320
+ */
184
321
  extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
185
322
 
186
323
  /**
187
- * Load a surface from a seekable SDL data stream (memory or file).
324
+ * Load a BMP image from a seekable SDL data stream.
188
325
  *
189
- * If \c freesrc is non-zero, the stream will be closed after being read.
326
+ * The new surface should be freed with SDL_FreeSurface(). Not doing so will
327
+ * result in a memory leak.
190
328
  *
191
- * The new surface should be freed with SDL_FreeSurface().
329
+ * src is an open SDL_RWops buffer, typically loaded with SDL_RWFromFile.
330
+ * Alternitavely, you might also use the macro SDL_LoadBMP to load a bitmap
331
+ * from a file, convert it to an SDL_Surface and then close the file.
192
332
  *
193
- * \return the new surface, or NULL if there was an error.
333
+ * \param src the data stream for the surface
334
+ * \param freesrc non-zero to close the stream after being read
335
+ * \returns a pointer to a new SDL_Surface structure or NULL if there was an
336
+ * error; call SDL_GetError() for more information.
337
+ *
338
+ * \since This function is available since SDL 2.0.0.
339
+ *
340
+ * \sa SDL_FreeSurface
341
+ * \sa SDL_RWFromFile
342
+ * \sa SDL_LoadBMP
343
+ * \sa SDL_SaveBMP_RW
194
344
  */
195
345
  extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
196
346
  int freesrc);
197
347
 
198
348
  /**
199
- * Load a surface from a file.
349
+ * Load a surface from a file.
200
350
  *
201
- * Convenience macro.
351
+ * Convenience macro.
202
352
  */
203
353
  #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
204
354
 
205
355
  /**
206
- * Save a surface to a seekable SDL data stream (memory or file).
356
+ * Save a surface to a seekable SDL data stream in BMP format.
357
+ *
358
+ * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
359
+ * BMP directly. Other RGB formats with 8-bit or higher get converted to a
360
+ * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
361
+ * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
362
+ * not supported.
207
363
  *
208
- * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
209
- * BMP directly. Other RGB formats with 8-bit or higher get converted to a
210
- * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
211
- * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
212
- * not supported.
364
+ * \param surface the SDL_Surface structure containing the image to be saved
365
+ * \param dst a data stream to save to
366
+ * \param freedst non-zero to close the stream after being written
367
+ * \returns 0 on success or a negative error code on failure; call
368
+ * SDL_GetError() for more information.
213
369
  *
214
- * If \c freedst is non-zero, the stream will be closed after being written.
370
+ * \since This function is available since SDL 2.0.0.
215
371
  *
216
- * \return 0 if successful or -1 if there was an error.
372
+ * \sa SDL_LoadBMP_RW
373
+ * \sa SDL_SaveBMP
217
374
  */
218
375
  extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
219
376
  (SDL_Surface * surface, SDL_RWops * dst, int freedst);
@@ -227,190 +384,335 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
227
384
  SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
228
385
 
229
386
  /**
230
- * \brief Sets the RLE acceleration hint for a surface.
387
+ * Set the RLE acceleration hint for a surface.
231
388
  *
232
- * \return 0 on success, or -1 if the surface is not valid
389
+ * If RLE is enabled, color key and alpha blending blits are much faster, but
390
+ * the surface must be locked before directly accessing the pixels.
233
391
  *
234
- * \note If RLE is enabled, colorkey and alpha blending blits are much faster,
235
- * but the surface must be locked before directly accessing the pixels.
392
+ * \param surface the SDL_Surface structure to optimize
393
+ * \param flag 0 to disable, non-zero to enable RLE acceleration
394
+ * \returns 0 on success or a negative error code on failure; call
395
+ * SDL_GetError() for more information.
396
+ *
397
+ * \since This function is available since SDL 2.0.0.
398
+ *
399
+ * \sa SDL_BlitSurface
400
+ * \sa SDL_LockSurface
401
+ * \sa SDL_UnlockSurface
236
402
  */
237
403
  extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
238
404
  int flag);
239
405
 
240
406
  /**
241
- * \brief Returns whether the surface is RLE enabled
407
+ * Returns whether the surface is RLE enabled
408
+ *
409
+ * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
410
+ *
411
+ * \param surface the SDL_Surface structure to query
412
+ * \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise.
242
413
  *
243
- * \return SDL_TRUE if the surface is RLE enabled, or SDL_FALSE if the surface is NULL or not RLE enabled
414
+ * \since This function is available since SDL 2.0.14.
415
+ *
416
+ * \sa SDL_SetSurfaceRLE
244
417
  */
245
418
  extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
246
419
 
247
420
  /**
248
- * \brief Sets the color key (transparent pixel) in a blittable surface.
421
+ * Set the color key (transparent pixel) in a surface.
422
+ *
423
+ * The color key defines a pixel value that will be treated as transparent in
424
+ * a blit. For example, one can use this to specify that cyan pixels should be
425
+ * considered transparent, and therefore not rendered.
426
+ *
427
+ * It is a pixel of the format used by the surface, as generated by
428
+ * SDL_MapRGB().
429
+ *
430
+ * RLE acceleration can substantially speed up blitting of images with large
431
+ * horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details.
249
432
  *
250
- * \param surface The surface to update
251
- * \param flag Non-zero to enable colorkey and 0 to disable colorkey
252
- * \param key The transparent pixel in the native surface format
433
+ * \param surface the SDL_Surface structure to update
434
+ * \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key
435
+ * \param key the transparent pixel
436
+ * \returns 0 on success or a negative error code on failure; call
437
+ * SDL_GetError() for more information.
253
438
  *
254
- * \return 0 on success, or -1 if the surface is not valid
439
+ * \since This function is available since SDL 2.0.0.
255
440
  *
256
- * You can pass SDL_RLEACCEL to enable RLE accelerated blits.
441
+ * \sa SDL_BlitSurface
442
+ * \sa SDL_GetColorKey
257
443
  */
258
444
  extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
259
445
  int flag, Uint32 key);
260
446
 
261
447
  /**
262
- * \brief Returns whether the surface has a color key
448
+ * Returns whether the surface has a color key
263
449
  *
264
- * \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key
450
+ * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
451
+ *
452
+ * \param surface the SDL_Surface structure to query
453
+ * \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
454
+ *
455
+ * \since This function is available since SDL 2.0.9.
456
+ *
457
+ * \sa SDL_SetColorKey
458
+ * \sa SDL_GetColorKey
265
459
  */
266
460
  extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
267
461
 
268
462
  /**
269
- * \brief Gets the color key (transparent pixel) in a blittable surface.
463
+ * Get the color key (transparent pixel) for a surface.
464
+ *
465
+ * The color key is a pixel of the format used by the surface, as generated by
466
+ * SDL_MapRGB().
270
467
  *
271
- * \param surface The surface to update
272
- * \param key A pointer filled in with the transparent pixel in the native
273
- * surface format
468
+ * If the surface doesn't have color key enabled this function returns -1.
274
469
  *
275
- * \return 0 on success, or -1 if the surface is not valid or colorkey is not
276
- * enabled.
470
+ * \param surface the SDL_Surface structure to query
471
+ * \param key a pointer filled in with the transparent pixel
472
+ * \returns 0 on success or a negative error code on failure; call
473
+ * SDL_GetError() for more information.
474
+ *
475
+ * \since This function is available since SDL 2.0.0.
476
+ *
477
+ * \sa SDL_BlitSurface
478
+ * \sa SDL_SetColorKey
277
479
  */
278
480
  extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
279
481
  Uint32 * key);
280
482
 
281
483
  /**
282
- * \brief Set an additional color value used in blit operations.
484
+ * Set an additional color value multiplied into blit operations.
485
+ *
486
+ * When this surface is blitted, during the blit operation each source color
487
+ * channel is modulated by the appropriate color value according to the
488
+ * following formula:
489
+ *
490
+ * `srcC = srcC * (color / 255)`
283
491
  *
284
- * \param surface The surface to update.
285
- * \param r The red color value multiplied into blit operations.
286
- * \param g The green color value multiplied into blit operations.
287
- * \param b The blue color value multiplied into blit operations.
492
+ * \param surface the SDL_Surface structure to update
493
+ * \param r the red color value multiplied into blit operations
494
+ * \param g the green color value multiplied into blit operations
495
+ * \param b the blue color value multiplied into blit operations
496
+ * \returns 0 on success or a negative error code on failure; call
497
+ * SDL_GetError() for more information.
288
498
  *
289
- * \return 0 on success, or -1 if the surface is not valid.
499
+ * \since This function is available since SDL 2.0.0.
290
500
  *
291
- * \sa SDL_GetSurfaceColorMod()
501
+ * \sa SDL_GetSurfaceColorMod
502
+ * \sa SDL_SetSurfaceAlphaMod
292
503
  */
293
504
  extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
294
505
  Uint8 r, Uint8 g, Uint8 b);
295
506
 
296
507
 
297
508
  /**
298
- * \brief Get the additional color value used in blit operations.
509
+ * Get the additional color value multiplied into blit operations.
299
510
  *
300
- * \param surface The surface to query.
301
- * \param r A pointer filled in with the current red color value.
302
- * \param g A pointer filled in with the current green color value.
303
- * \param b A pointer filled in with the current blue color value.
511
+ * \param surface the SDL_Surface structure to query
512
+ * \param r a pointer filled in with the current red color value
513
+ * \param g a pointer filled in with the current green color value
514
+ * \param b a pointer filled in with the current blue color value
515
+ * \returns 0 on success or a negative error code on failure; call
516
+ * SDL_GetError() for more information.
304
517
  *
305
- * \return 0 on success, or -1 if the surface is not valid.
518
+ * \since This function is available since SDL 2.0.0.
306
519
  *
307
- * \sa SDL_SetSurfaceColorMod()
520
+ * \sa SDL_GetSurfaceAlphaMod
521
+ * \sa SDL_SetSurfaceColorMod
308
522
  */
309
523
  extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
310
524
  Uint8 * r, Uint8 * g,
311
525
  Uint8 * b);
312
526
 
313
527
  /**
314
- * \brief Set an additional alpha value used in blit operations.
528
+ * Set an additional alpha value used in blit operations.
315
529
  *
316
- * \param surface The surface to update.
317
- * \param alpha The alpha value multiplied into blit operations.
530
+ * When this surface is blitted, during the blit operation the source alpha
531
+ * value is modulated by this alpha value according to the following formula:
318
532
  *
319
- * \return 0 on success, or -1 if the surface is not valid.
533
+ * `srcA = srcA * (alpha / 255)`
320
534
  *
321
- * \sa SDL_GetSurfaceAlphaMod()
535
+ * \param surface the SDL_Surface structure to update
536
+ * \param alpha the alpha value multiplied into blit operations
537
+ * \returns 0 on success or a negative error code on failure; call
538
+ * SDL_GetError() for more information.
539
+ *
540
+ * \since This function is available since SDL 2.0.0.
541
+ *
542
+ * \sa SDL_GetSurfaceAlphaMod
543
+ * \sa SDL_SetSurfaceColorMod
322
544
  */
323
545
  extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
324
546
  Uint8 alpha);
325
547
 
326
548
  /**
327
- * \brief Get the additional alpha value used in blit operations.
549
+ * Get the additional alpha value used in blit operations.
328
550
  *
329
- * \param surface The surface to query.
330
- * \param alpha A pointer filled in with the current alpha value.
551
+ * \param surface the SDL_Surface structure to query
552
+ * \param alpha a pointer filled in with the current alpha value
553
+ * \returns 0 on success or a negative error code on failure; call
554
+ * SDL_GetError() for more information.
331
555
  *
332
- * \return 0 on success, or -1 if the surface is not valid.
556
+ * \since This function is available since SDL 2.0.0.
333
557
  *
334
- * \sa SDL_SetSurfaceAlphaMod()
558
+ * \sa SDL_GetSurfaceColorMod
559
+ * \sa SDL_SetSurfaceAlphaMod
335
560
  */
336
561
  extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
337
562
  Uint8 * alpha);
338
563
 
339
564
  /**
340
- * \brief Set the blend mode used for blit operations.
565
+ * Set the blend mode used for blit operations.
566
+ *
567
+ * To copy a surface to another surface (or texture) without blending with the
568
+ * existing data, the blendmode of the SOURCE surface should be set to
569
+ * `SDL_BLENDMODE_NONE`.
341
570
  *
342
- * \param surface The surface to update.
343
- * \param blendMode ::SDL_BlendMode to use for blit blending.
571
+ * \param surface the SDL_Surface structure to update
572
+ * \param blendMode the SDL_BlendMode to use for blit blending
573
+ * \returns 0 on success or a negative error code on failure; call
574
+ * SDL_GetError() for more information.
344
575
  *
345
- * \return 0 on success, or -1 if the parameters are not valid.
576
+ * \since This function is available since SDL 2.0.0.
346
577
  *
347
- * \sa SDL_GetSurfaceBlendMode()
578
+ * \sa SDL_GetSurfaceBlendMode
348
579
  */
349
580
  extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
350
581
  SDL_BlendMode blendMode);
351
582
 
352
583
  /**
353
- * \brief Get the blend mode used for blit operations.
584
+ * Get the blend mode used for blit operations.
354
585
  *
355
- * \param surface The surface to query.
356
- * \param blendMode A pointer filled in with the current blend mode.
586
+ * \param surface the SDL_Surface structure to query
587
+ * \param blendMode a pointer filled in with the current SDL_BlendMode
588
+ * \returns 0 on success or a negative error code on failure; call
589
+ * SDL_GetError() for more information.
357
590
  *
358
- * \return 0 on success, or -1 if the surface is not valid.
591
+ * \since This function is available since SDL 2.0.0.
359
592
  *
360
- * \sa SDL_SetSurfaceBlendMode()
593
+ * \sa SDL_SetSurfaceBlendMode
361
594
  */
362
595
  extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
363
596
  SDL_BlendMode *blendMode);
364
597
 
365
598
  /**
366
- * Sets the clipping rectangle for the destination surface in a blit.
599
+ * Set the clipping rectangle for a surface.
600
+ *
601
+ * When `surface` is the destination of a blit, only the area within the clip
602
+ * rectangle is drawn into.
603
+ *
604
+ * Note that blits are automatically clipped to the edges of the source and
605
+ * destination surfaces.
367
606
  *
368
- * If the clip rectangle is NULL, clipping will be disabled.
607
+ * \param surface the SDL_Surface structure to be clipped
608
+ * \param rect the SDL_Rect structure representing the clipping rectangle, or
609
+ * NULL to disable clipping
610
+ * \returns SDL_TRUE if the rectangle intersects the surface, otherwise
611
+ * SDL_FALSE and blits will be completely clipped.
369
612
  *
370
- * If the clip rectangle doesn't intersect the surface, the function will
371
- * return SDL_FALSE and blits will be completely clipped. Otherwise the
372
- * function returns SDL_TRUE and blits to the surface will be clipped to
373
- * the intersection of the surface area and the clipping rectangle.
613
+ * \since This function is available since SDL 2.0.0.
374
614
  *
375
- * Note that blits are automatically clipped to the edges of the source
376
- * and destination surfaces.
615
+ * \sa SDL_BlitSurface
616
+ * \sa SDL_GetClipRect
377
617
  */
378
618
  extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
379
619
  const SDL_Rect * rect);
380
620
 
381
621
  /**
382
- * Gets the clipping rectangle for the destination surface in a blit.
622
+ * Get the clipping rectangle for a surface.
383
623
  *
384
- * \c rect must be a pointer to a valid rectangle which will be filled
385
- * with the correct values.
624
+ * When `surface` is the destination of a blit, only the area within the clip
625
+ * rectangle is drawn into.
626
+ *
627
+ * \param surface the SDL_Surface structure representing the surface to be
628
+ * clipped
629
+ * \param rect an SDL_Rect structure filled in with the clipping rectangle for
630
+ * the surface
631
+ *
632
+ * \since This function is available since SDL 2.0.0.
633
+ *
634
+ * \sa SDL_BlitSurface
635
+ * \sa SDL_SetClipRect
386
636
  */
387
637
  extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
388
638
  SDL_Rect * rect);
389
639
 
390
640
  /*
391
- * Creates a new surface identical to the existing surface
641
+ * Creates a new surface identical to the existing surface.
642
+ *
643
+ * The returned surface should be freed with SDL_FreeSurface().
644
+ *
645
+ * \param surface the surface to duplicate.
646
+ * \returns a copy of the surface, or NULL on failure; call SDL_GetError() for
647
+ * more information.
392
648
  */
393
649
  extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface);
394
650
 
395
651
  /**
396
- * Creates a new surface of the specified format, and then copies and maps
397
- * the given surface to it so the blit of the converted surface will be as
398
- * fast as possible. If this function fails, it returns NULL.
652
+ * Copy an existing surface to a new surface of the specified format.
653
+ *
654
+ * This function is used to optimize images for faster *repeat* blitting. This
655
+ * is accomplished by converting the original and storing the result as a new
656
+ * surface. The new, optimized surface can then be used as the source for
657
+ * future blits, making them faster.
658
+ *
659
+ * \param src the existing SDL_Surface structure to convert
660
+ * \param fmt the SDL_PixelFormat structure that the new surface is optimized
661
+ * for
662
+ * \param flags the flags are unused and should be set to 0; this is a
663
+ * leftover from SDL 1.2's API
664
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
665
+ * call SDL_GetError() for more information.
666
+ *
667
+ * \since This function is available since SDL 2.0.0.
399
668
  *
400
- * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those
401
- * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and
402
- * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
403
- * surface.
669
+ * \sa SDL_AllocFormat
670
+ * \sa SDL_ConvertSurfaceFormat
671
+ * \sa SDL_CreateRGBSurface
404
672
  */
405
673
  extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
406
674
  (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
675
+
676
+ /**
677
+ * Copy an existing surface to a new surface of the specified format enum.
678
+ *
679
+ * This function operates just like SDL_ConvertSurface(), but accepts an
680
+ * SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As such,
681
+ * it might be easier to call but it doesn't have access to palette
682
+ * information for the destination surface, in case that would be important.
683
+ *
684
+ * \param src the existing SDL_Surface structure to convert
685
+ * \param pixel_format the SDL_PixelFormatEnum that the new surface is
686
+ * optimized for
687
+ * \param flags the flags are unused and should be set to 0; this is a
688
+ * leftover from SDL 1.2's API
689
+ * \returns the new SDL_Surface structure that is created or NULL if it fails;
690
+ * call SDL_GetError() for more information.
691
+ *
692
+ * \since This function is available since SDL 2.0.0.
693
+ *
694
+ * \sa SDL_AllocFormat
695
+ * \sa SDL_ConvertSurface
696
+ * \sa SDL_CreateRGBSurface
697
+ */
407
698
  extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
408
699
  (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
409
700
 
410
701
  /**
411
- * \brief Copy a block of pixels of one format to another format
702
+ * Copy a block of pixels of one format to another format.
703
+ *
704
+ * \param width the width of the block to copy, in pixels
705
+ * \param height the height of the block to copy, in pixels
706
+ * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format
707
+ * \param src a pointer to the source pixels
708
+ * \param src_pitch the pitch of the source pixels, in bytes
709
+ * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format
710
+ * \param dst a pointer to be filled in with new pixel data
711
+ * \param dst_pitch the pitch of the destination pixels, in bytes
712
+ * \returns 0 on success or a negative error code on failure; call
713
+ * SDL_GetError() for more information.
412
714
  *
413
- * \return 0 on success, or -1 if there was an error
715
+ * \since This function is available since SDL 2.0.0.
414
716
  */
415
717
  extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
416
718
  Uint32 src_format,
@@ -419,20 +721,84 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
419
721
  void * dst, int dst_pitch);
420
722
 
421
723
  /**
422
- * Performs a fast fill of the given rectangle with \c color.
724
+ * Premultiply the alpha on a block of pixels.
725
+ *
726
+ * This is safe to use with src == dst, but not for other overlapping areas.
727
+ *
728
+ * This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888.
729
+ *
730
+ * \param width the width of the block to convert, in pixels
731
+ * \param height the height of the block to convert, in pixels
732
+ * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format
733
+ * \param src a pointer to the source pixels
734
+ * \param src_pitch the pitch of the source pixels, in bytes
735
+ * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format
736
+ * \param dst a pointer to be filled in with premultiplied pixel data
737
+ * \param dst_pitch the pitch of the destination pixels, in bytes
738
+ * \returns 0 on success or a negative error code on failure; call
739
+ * SDL_GetError() for more information.
740
+ *
741
+ * \since This function is available since SDL 2.0.18.
742
+ */
743
+ extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
744
+ Uint32 src_format,
745
+ const void * src, int src_pitch,
746
+ Uint32 dst_format,
747
+ void * dst, int dst_pitch);
748
+
749
+ /**
750
+ * Perform a fast fill of a rectangle with a specific color.
751
+ *
752
+ * `color` should be a pixel of the format used by the surface, and can be
753
+ * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
754
+ * alpha component then the destination is simply filled with that alpha
755
+ * information, no blending takes place.
423
756
  *
424
- * If \c rect is NULL, the whole surface will be filled with \c color.
757
+ * If there is a clip rectangle set on the destination (set via
758
+ * SDL_SetClipRect()), then this function will fill based on the intersection
759
+ * of the clip rectangle and `rect`.
425
760
  *
426
- * The color should be a pixel of the format used by the surface, and
427
- * can be generated by the SDL_MapRGB() function.
761
+ * \param dst the SDL_Surface structure that is the drawing target
762
+ * \param rect the SDL_Rect structure representing the rectangle to fill, or
763
+ * NULL to fill the entire surface
764
+ * \param color the color to fill with
765
+ * \returns 0 on success or a negative error code on failure; call
766
+ * SDL_GetError() for more information.
428
767
  *
429
- * \return 0 on success, or -1 on error.
768
+ * \since This function is available since SDL 2.0.0.
769
+ *
770
+ * \sa SDL_FillRects
430
771
  */
431
772
  extern DECLSPEC int SDLCALL SDL_FillRect
432
773
  (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
774
+
775
+ /**
776
+ * Perform a fast fill of a set of rectangles with a specific color.
777
+ *
778
+ * `color` should be a pixel of the format used by the surface, and can be
779
+ * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
780
+ * alpha component then the destination is simply filled with that alpha
781
+ * information, no blending takes place.
782
+ *
783
+ * If there is a clip rectangle set on the destination (set via
784
+ * SDL_SetClipRect()), then this function will fill based on the intersection
785
+ * of the clip rectangle and `rect`.
786
+ *
787
+ * \param dst the SDL_Surface structure that is the drawing target
788
+ * \param rects an array of SDL_Rects representing the rectangles to fill.
789
+ * \param count the number of rectangles in the array
790
+ * \param color the color to fill with
791
+ * \returns 0 on success or a negative error code on failure; call
792
+ * SDL_GetError() for more information.
793
+ *
794
+ * \since This function is available since SDL 2.0.0.
795
+ *
796
+ * \sa SDL_FillRect
797
+ */
433
798
  extern DECLSPEC int SDLCALL SDL_FillRects
434
799
  (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
435
800
 
801
+ /* !!! FIXME: merge this documentation with the wiki */
436
802
  /**
437
803
  * Performs a fast blit from the source surface to the destination surface.
438
804
  *
@@ -441,7 +807,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects
441
807
  * surface (\c src or \c dst) is copied. The final blit rectangles are saved
442
808
  * in \c srcrect and \c dstrect after all clipping is performed.
443
809
  *
444
- * \return If the blit is successful, it returns 0, otherwise it returns -1.
810
+ * \returns 0 if the blit is successful, otherwise it returns -1.
445
811
  *
446
812
  * The blit function should not be called on a locked surface.
447
813
  *
@@ -493,62 +859,128 @@ extern DECLSPEC int SDLCALL SDL_FillRects
493
859
  #define SDL_BlitSurface SDL_UpperBlit
494
860
 
495
861
  /**
496
- * This is the public blit function, SDL_BlitSurface(), and it performs
497
- * rectangle validation and clipping before passing it to SDL_LowerBlit()
862
+ * Perform a fast blit from the source surface to the destination surface.
863
+ *
864
+ * SDL_UpperBlit() has been replaced by SDL_BlitSurface(), which is merely a
865
+ * macro for this function with a less confusing name.
866
+ *
867
+ * \since This function is available since SDL 2.0.0.
868
+ *
869
+ * \sa SDL_BlitSurface
498
870
  */
499
871
  extern DECLSPEC int SDLCALL SDL_UpperBlit
500
872
  (SDL_Surface * src, const SDL_Rect * srcrect,
501
873
  SDL_Surface * dst, SDL_Rect * dstrect);
502
874
 
503
875
  /**
504
- * This is a semi-private blit function and it performs low-level surface
505
- * blitting only.
876
+ * Perform low-level surface blitting only.
877
+ *
878
+ * This is a semi-private blit function and it performs low-level surface
879
+ * blitting, assuming the input rectangles have already been clipped.
880
+ *
881
+ * Unless you know what you're doing, you should be using SDL_BlitSurface()
882
+ * instead.
883
+ *
884
+ * \param src the SDL_Surface structure to be copied from
885
+ * \param srcrect the SDL_Rect structure representing the rectangle to be
886
+ * copied, or NULL to copy the entire surface
887
+ * \param dst the SDL_Surface structure that is the blit target
888
+ * \param dstrect the SDL_Rect structure representing the rectangle that is
889
+ * copied into
890
+ * \returns 0 on success or a negative error code on failure; call
891
+ * SDL_GetError() for more information.
892
+ *
893
+ * \since This function is available since SDL 2.0.0.
894
+ *
895
+ * \sa SDL_BlitSurface
506
896
  */
507
897
  extern DECLSPEC int SDLCALL SDL_LowerBlit
508
898
  (SDL_Surface * src, SDL_Rect * srcrect,
509
899
  SDL_Surface * dst, SDL_Rect * dstrect);
510
900
 
901
+
511
902
  /**
512
- * \brief Perform a fast, low quality, stretch blit between two surfaces of the
513
- * same pixel format.
903
+ * Perform a fast, low quality, stretch blit between two surfaces of the same
904
+ * format.
905
+ *
906
+ * Please use SDL_BlitScaled() instead.
514
907
  *
515
- * \note This function uses a static buffer, and is not thread-safe.
908
+ * \since This function is available since SDL 2.0.0.
516
909
  */
517
910
  extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
518
911
  const SDL_Rect * srcrect,
519
912
  SDL_Surface * dst,
520
913
  const SDL_Rect * dstrect);
521
914
 
915
+ /**
916
+ * Perform bilinear scaling between two surfaces of the same format, 32BPP.
917
+ *
918
+ * \since This function is available since SDL 2.0.16.
919
+ */
920
+ extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
921
+ const SDL_Rect * srcrect,
922
+ SDL_Surface * dst,
923
+ const SDL_Rect * dstrect);
924
+
925
+
522
926
  #define SDL_BlitScaled SDL_UpperBlitScaled
523
927
 
524
928
  /**
525
- * This is the public scaled blit function, SDL_BlitScaled(), and it performs
526
- * rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
929
+ * Perform a scaled surface copy to a destination surface.
930
+ *
931
+ * SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is
932
+ * merely a macro for this function with a less confusing name.
933
+ *
934
+ * \since This function is available since SDL 2.0.0.
935
+ *
936
+ * \sa SDL_BlitScaled
527
937
  */
528
938
  extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
529
939
  (SDL_Surface * src, const SDL_Rect * srcrect,
530
940
  SDL_Surface * dst, SDL_Rect * dstrect);
531
941
 
532
942
  /**
533
- * This is a semi-private blit function and it performs low-level surface
534
- * scaled blitting only.
943
+ * Perform low-level surface scaled blitting only.
944
+ *
945
+ * This is a semi-private function and it performs low-level surface blitting,
946
+ * assuming the input rectangles have already been clipped.
947
+ *
948
+ * \param src the SDL_Surface structure to be copied from
949
+ * \param srcrect the SDL_Rect structure representing the rectangle to be
950
+ * copied
951
+ * \param dst the SDL_Surface structure that is the blit target
952
+ * \param dstrect the SDL_Rect structure representing the rectangle that is
953
+ * copied into
954
+ * \returns 0 on success or a negative error code on failure; call
955
+ * SDL_GetError() for more information.
956
+ *
957
+ * \since This function is available since SDL 2.0.0.
958
+ *
959
+ * \sa SDL_BlitScaled
535
960
  */
536
961
  extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
537
962
  (SDL_Surface * src, SDL_Rect * srcrect,
538
963
  SDL_Surface * dst, SDL_Rect * dstrect);
539
964
 
540
965
  /**
541
- * \brief Set the YUV conversion mode
966
+ * Set the YUV conversion mode
967
+ *
968
+ * \since This function is available since SDL 2.0.8.
542
969
  */
543
970
  extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
544
971
 
545
972
  /**
546
- * \brief Get the YUV conversion mode
973
+ * Get the YUV conversion mode
974
+ *
975
+ * \since This function is available since SDL 2.0.8.
547
976
  */
548
977
  extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
549
978
 
550
979
  /**
551
- * \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
980
+ * Get the YUV conversion mode, returning the correct mode for the resolution
981
+ * when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
982
+ *
983
+ * \since This function is available since SDL 2.0.8.
552
984
  */
553
985
  extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
554
986