Simple Directmedia Layer
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

include: Filled in all remaining missing documentation!

+1870 -138
+98 -17
include/SDL3/SDL_assert.h
··· 156 156 #define SDL_TriggerBreakpoint() 157 157 #endif 158 158 159 - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ 159 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 160 + /** 161 + * A macro that reports the current function being compiled. 162 + * 163 + * If SDL can't figure how the compiler reports this, it will use "???". 164 + * 165 + * \since This macro is available since SDL 3.1.3. 166 + */ 167 + #define SDL_FUNCTION __FUNCTION__ 168 + 169 + #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ 160 170 # define SDL_FUNCTION __func__ 161 171 #elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__)) 162 172 # define SDL_FUNCTION __FUNCTION__ 163 173 #else 164 174 # define SDL_FUNCTION "???" 165 175 #endif 176 + 177 + /** 178 + * A macro that reports the current file being compiled. 179 + * 180 + * \since This macro is available since SDL 3.1.3. 181 + */ 166 182 #define SDL_FILE __FILE__ 183 + 184 + /** 185 + * A macro that reports the current line number of the file being compiled. 186 + * 187 + * \since This macro is available since SDL 3.1.3. 188 + */ 167 189 #define SDL_LINE __LINE__ 168 190 169 191 /* ··· 181 203 disable assertions. 182 204 */ 183 205 206 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 207 + /** 208 + * A macro for wrapping code in `do {} while (0);` without compiler warnings. 209 + * 210 + * Visual Studio with really aggressive warnings enabled needs this to avoid 211 + * compiler complaints. 212 + * 213 + * the `do {} while (0);` trick is useful for wrapping code in a macro that 214 + * may or may not be a single statement, to avoid various C language accidents. 215 + * 216 + * To use: 217 + * 218 + * ```c 219 + * do { SomethingOnce(); } while (SDL_NULL_WHILE_LOOP_CONDITION (0)); 220 + * ``` 221 + * 222 + * \since This macro is available since SDL 3.1.3. 223 + */ 224 + #define SDL_NULL_WHILE_LOOP_CONDITION (0) 225 + 226 + #elif defined _MSC_VER /* Avoid /W4 warnings. */ 184 227 /* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking 185 228 this condition isn't constant. And looks like an owl's face! */ 186 - #ifdef _MSC_VER /* stupid /W4 warnings. */ 187 229 #define SDL_NULL_WHILE_LOOP_CONDITION (0,0) 188 230 #else 189 231 #define SDL_NULL_WHILE_LOOP_CONDITION (0) 190 232 #endif 191 233 234 + /** 235 + * The macro used when an assertion is disabled. 236 + * 237 + * This isn't for direct use by apps, but this is the code that is inserted 238 + * when an SDL_assert is disabled (perhaps in a release build). 239 + * 240 + * The code does nothing, but wraps `condition` in a sizeof operator, which 241 + * generates no code and has no side effects, but avoid compiler warnings 242 + * about unused variables. 243 + * 244 + * \param condition the condition to assert (but not actually run here). 245 + * 246 + * \since This macro is available since SDL 3.1.3. 247 + */ 192 248 #define SDL_disabled_assert(condition) \ 193 249 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) 194 250 ··· 237 293 /** 238 294 * Never call this directly. 239 295 * 240 - * Use the SDL_assert* macros instead. 296 + * Use the SDL_assert macros instead. 241 297 * 242 298 * \param data assert data structure. 243 299 * \param func function name. ··· 253 309 const char *func, 254 310 const char *file, int line) SDL_ANALYZER_NORETURN; 255 311 256 - /* Define the trigger breakpoint call used in asserts */ 257 - #ifndef SDL_AssertBreakpoint 258 - #if defined(ANDROID) && defined(assert) 259 - /* Define this as empty in case assert() is defined as SDL_assert */ 260 - #define SDL_AssertBreakpoint() 261 - #else 312 + 313 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 314 + /** 315 + * The macro used when an assertion triggers a breakpoint. 316 + * 317 + * This isn't for direct use by apps; use SDL_assert or SDL_TriggerBreakpoint 318 + * instead. 319 + * 320 + * \since This macro is available since SDL 3.1.3. 321 + */ 262 322 #define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() 263 - #endif 323 + 324 + #elif !defined(SDL_AssertBreakpoint) 325 + # if defined(ANDROID) && defined(assert) 326 + /* Define this as empty in case assert() is defined as SDL_assert */ 327 + # define SDL_AssertBreakpoint() 328 + # else 329 + # define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() 330 + # endif 264 331 #endif /* !SDL_AssertBreakpoint */ 265 332 266 - /* the do {} while(0) avoids dangling else problems: 267 - if (x) SDL_assert(y); else blah(); 268 - ... without the do/while, the "else" could attach to this macro's "if". 269 - We try to handle just the minimum we need here in a macro...the loop, 270 - the static vars, and break points. The heavy lifting is handled in 271 - SDL_ReportAssertion(), in SDL_assert.c. 272 - */ 333 + /** 334 + * The macro used when an assertion is enabled. 335 + * 336 + * This isn't for direct use by apps, but this is the code that is inserted 337 + * when an SDL_assert is enabled. 338 + * 339 + * The `do {} while(0)` avoids dangling else problems: 340 + * 341 + * ```c 342 + * if (x) SDL_assert(y); else blah(); 343 + * ``` 344 + * 345 + * ... without the do/while, the "else" could attach to this macro's "if". 346 + * We try to handle just the minimum we need here in a macro...the loop, 347 + * the static vars, and break points. The heavy lifting is handled in 348 + * SDL_ReportAssertion(). 349 + * 350 + * \param condition the condition to assert. 351 + * 352 + * \since This macro is available since SDL 3.1.3. 353 + */ 273 354 #define SDL_enabled_assert(condition) \ 274 355 do { \ 275 356 while ( !(condition) ) { \
+71 -11
include/SDL3/SDL_atomic.h
··· 155 155 * \since This macro is available since SDL 3.1.3. 156 156 */ 157 157 #define SDL_CompilerBarrier() DoCompilerSpecificReadWriteBarrier() 158 + 158 159 #elif defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) 159 160 void _ReadWriteBarrier(void); 160 161 #pragma intrinsic(_ReadWriteBarrier) ··· 171 172 #endif 172 173 173 174 /** 174 - * Insert a memory release barrier. 175 + * Insert a memory release barrier (function version). 176 + * 177 + * Please refer to SDL_MemoryBarrierRelease for details. This is a function 178 + * version, which might be useful if you need to use this functionality from 179 + * a scripting language, etc. Also, some of the macro versions call this 180 + * function behind the scenes, where more heavy lifting can happen inside 181 + * of SDL. Generally, though, an app written in C/C++/etc should use the macro 182 + * version, as it will be more efficient. 183 + * 184 + * \threadsafety Obviously this function is safe to use from any thread at any 185 + * time, but if you find yourself needing this, you are probably 186 + * dealing with some very sensitive code; be careful! 187 + * 188 + * \since This function is available since SDL 3.1.3. 189 + * 190 + * \sa SDL_MemoryBarrierRelease 191 + */ 192 + extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); 193 + 194 + /** 195 + * Insert a memory acquire barrier (function version). 196 + * 197 + * Please refer to SDL_MemoryBarrierRelease for details. This is a function 198 + * version, which might be useful if you need to use this functionality from 199 + * a scripting language, etc. Also, some of the macro versions call this 200 + * function behind the scenes, where more heavy lifting can happen inside 201 + * of SDL. Generally, though, an app written in C/C++/etc should use the macro 202 + * version, as it will be more efficient. 203 + * 204 + * \threadsafety Obviously this function is safe to use from any thread at any 205 + * time, but if you find yourself needing this, you are probably 206 + * dealing with some very sensitive code; be careful! 207 + * 208 + * \since This function is available since SDL 3.1.3. 209 + * 210 + * \sa SDL_MemoryBarrierAcquire 211 + */ 212 + extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); 213 + 214 + 215 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 216 + /** 217 + * Insert a memory release barrier (macro version). 175 218 * 176 219 * Memory barriers are designed to prevent reads and writes from being 177 220 * reordered by the compiler and being seen out of order on multi-core CPUs. ··· 190 233 * 191 234 * For more information on these semantics, take a look at the blog post: 192 235 * http://preshing.com/20120913/acquire-and-release-semantics 236 + * 237 + * This is the macro version of this functionality; if possible, SDL will 238 + * use compiler intrinsics or inline assembly, but some platforms might 239 + * need to call the function version of this, SDL_MemoryBarrierReleaseFunction 240 + * to do the heavy lifting. Apps that can use the macro should favor it over 241 + * the function. 193 242 * 194 243 * \threadsafety Obviously this macro is safe to use from any thread at any 195 244 * time, but if you find yourself needing this, you are probably 196 245 * dealing with some very sensitive code; be careful! 197 246 * 198 - * \since This function is available since SDL 3.1.3. 247 + * \since This macro is available since SDL 3.1.3. 248 + * 249 + * \sa SDL_MemoryBarrierAcquire 250 + * \sa SDL_MemoryBarrierReleaseFunction 199 251 */ 200 - extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); 252 + #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() 201 253 202 254 /** 203 - * Insert a memory acquire barrier. 255 + * Insert a memory acquire barrier (macro version). 204 256 * 205 - * Please refer to SDL_MemoryBarrierReleaseFunction for the details! 257 + * Please see SDL_MemoryBarrierRelease for the details on what memory barriers 258 + * are and when to use them. 206 259 * 207 - * \threadsafety Obviously this function is safe to use from any thread at any 260 + * This is the macro version of this functionality; if possible, SDL will 261 + * use compiler intrinsics or inline assembly, but some platforms might 262 + * need to call the function version of this, 263 + * SDL_MemoryBarrierAcquireFunction, to do the heavy lifting. Apps that can 264 + * use the macro should favor it over the function. 265 + * 266 + * \threadsafety Obviously this macro is safe to use from any thread at any 208 267 * time, but if you find yourself needing this, you are probably 209 268 * dealing with some very sensitive code; be careful! 210 269 * 211 - * \since This function is available since SDL 3.1.3. 270 + * \since This macro is available since SDL 3.1.3. 212 271 * 213 - * \sa SDL_MemoryBarrierReleaseFunction 272 + * \sa SDL_MemoryBarrierRelease 273 + * \sa SDL_MemoryBarrierAcquireFunction 214 274 */ 215 - extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); 275 + #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() 216 276 217 - /* !!! FIXME: this should have documentation! */ 218 - #if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 277 + #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 219 278 #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") 220 279 #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") 221 280 #elif defined(__GNUC__) && defined(__aarch64__) ··· 284 343 * \since This macro is available since SDL 3.1.3. 285 344 */ 286 345 #define SDL_CPUPauseInstruction() DoACPUPauseInACompilerAndArchitectureSpecificWay 346 + 287 347 #elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) 288 348 #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */ 289 349 #elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)
+57 -12
include/SDL3/SDL_audio.h
··· 141 141 extern "C" { 142 142 #endif 143 143 144 - /* masks for different parts of SDL_AudioFormat. */ 144 + /** 145 + * Mask of bits in an SDL_AudioFormat that contains the format bit size. 146 + * 147 + * Generally one should use SDL_AUDIO_BITSIZE instead of this macro directly. 148 + * 149 + * \since This macro is available since SDL 3.1.3. 150 + */ 145 151 #define SDL_AUDIO_MASK_BITSIZE (0xFFu) 152 + 153 + /** 154 + * Mask of bits in an SDL_AudioFormat that contain the floating point flag. 155 + * 156 + * Generally one should use SDL_AUDIO_ISFLOAT instead of this macro directly. 157 + * 158 + * \since This macro is available since SDL 3.1.3. 159 + */ 146 160 #define SDL_AUDIO_MASK_FLOAT (1u<<8) 161 + 162 + /** 163 + * Mask of bits in an SDL_AudioFormat that contain the bigendian flag. 164 + * 165 + * Generally one should use SDL_AUDIO_ISBIGENDIAN or SDL_AUDIO_ISLITTLEENDIAN 166 + * instead of this macro directly. 167 + * 168 + * \since This macro is available since SDL 3.1.3. 169 + */ 147 170 #define SDL_AUDIO_MASK_BIG_ENDIAN (1u<<12) 171 + 172 + /** 173 + * Mask of bits in an SDL_AudioFormat that contain the signed data flag. 174 + * 175 + * Generally one should use SDL_AUDIO_ISSIGNED instead of this macro directly. 176 + * 177 + * \since This macro is available since SDL 3.1.3. 178 + */ 148 179 #define SDL_AUDIO_MASK_SIGNED (1u<<15) 149 180 150 - #define SDL_DEFINE_AUDIO_FORMAT(signed, bigendian, float, size) \ 151 - (((Uint16)(signed) << 15) | ((Uint16)(bigendian) << 12) | ((Uint16)(float) << 8) | ((size) & SDL_AUDIO_MASK_BITSIZE)) 181 + /** 182 + * Define an SDL_AudioFormat value. 183 + * 184 + * SDL does not support custom audio formats, so this macro is not of much 185 + * use externally, but it can be illustrative as to what the various bits of 186 + * an SDL_AudioFormat mean. 187 + * 188 + * For example, SDL_AUDIO_S32LE looks like this: 189 + * 190 + * ```c 191 + * SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32) 192 + * ``` 193 + * 194 + * \param signed 1 for signed data, 0 for unsigned data. 195 + * \param bigendian 1 for bigendian data, 0 for littleendian data. 196 + * \param flt 1 for floating point data, 0 for integer data. 197 + * \param size number of bits per sample. 198 + * \returns a format value in the style of SDL_AudioFormat. 199 + * 200 + * \threadsafety It is safe to call this macro from any thread. 201 + * 202 + * \since This macro is available since SDL 3.1.3. 203 + */ 204 + #define SDL_DEFINE_AUDIO_FORMAT(signed, bigendian, flt, size) \ 205 + (((Uint16)(signed) << 15) | ((Uint16)(bigendian) << 12) | ((Uint16)(flt) << 8) | ((size) & SDL_AUDIO_MASK_BITSIZE)) 152 206 153 207 /** 154 208 * Audio format. ··· 400 454 /* Function prototypes */ 401 455 402 456 /** 403 - * \name Driver discovery functions 404 - * 405 - * These functions return the list of built in audio drivers, in the 406 - * order that they are normally initialized by default. 407 - */ 408 - /* @{ */ 409 - 410 - /** 411 457 * Use this function to get the number of built-in audio drivers. 412 458 * 413 459 * This function returns a hardcoded number. This never returns a negative ··· 453 499 * \sa SDL_GetNumAudioDrivers 454 500 */ 455 501 extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index); 456 - /* @} */ 457 502 458 503 /** 459 504 * Get the name of the current audio driver.
+6 -3
include/SDL3/SDL_begin_code.h
··· 22 22 /* WIKI CATEGORY: BeginCode */ 23 23 24 24 /** 25 - * SDL_begin_code.h sets things up for C dynamic library function definitions, 26 - * static inlined functions, and structures aligned at 4-byte alignment. 27 - * If you don't like ugly C preprocessor code, don't look at this file. :) 25 + * # CategoryBeginCode 26 + * 27 + * `SDL_begin_code.h` sets things up for C dynamic library function 28 + * definitions, static inlined functions, and structures aligned at 4-byte 29 + * alignment. If you don't like ugly C preprocessor code, don't look at this 30 + * file. :) 28 31 * 29 32 * SDL's headers use this; applications generally should not include this 30 33 * header directly.
+33 -7
include/SDL3/SDL_gpu.h
··· 1504 1504 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ 1505 1505 } SDL_GPUTextureCreateInfo; 1506 1506 1507 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r" 1508 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g" 1509 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b" 1510 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a" 1511 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth" 1512 - #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil" 1513 - 1514 1507 /** 1515 1508 * A structure specifying the parameters of a buffer. 1516 1509 * ··· 2239 2232 * implementation will automatically fall back to the highest available sample 2240 2233 * count. 2241 2234 * 2235 + * There are optional properties that can be provided through 2236 + * SDL_GPUTextureCreateInfo's `props`. These are the supported properties: 2237 + * 2238 + * - `SDL_PROP_PROCESS_CREATE_ARGS_POINTER`: an array of strings containing 2239 + * the program to run, any arguments, and a NULL pointer, e.g. const char 2240 + * *args[] = { "myprogram", "argument", NULL }. This is a required property. 2241 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT`: (Direct3D 12 only) 2242 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the 2243 + * texture to a color with this red intensity. Defaults to zero. 2244 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT`: (Direct3D 12 only) 2245 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the 2246 + * texture to a color with this green intensity. Defaults to zero. 2247 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT`: (Direct3D 12 only) 2248 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the 2249 + * texture to a color with this blue intensity. Defaults to zero. 2250 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT`: (Direct3D 12 only) 2251 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the 2252 + * texture to a color with this alpha intensity. Defaults to zero. 2253 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT`: (Direct3D 12 only) 2254 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear 2255 + * the texture to a depth of this value. Defaults to zero. 2256 + * - `SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8`: (Direct3D 12 only) 2257 + * if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear 2258 + * the texture to a stencil of this value. Defaults to zero. 2259 + * 2242 2260 * \param device a GPU Context. 2243 2261 * \param createinfo a struct describing the state of the texture to create. 2244 2262 * \returns a texture object on success, or NULL on failure; call ··· 2260 2278 extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture( 2261 2279 SDL_GPUDevice *device, 2262 2280 const SDL_GPUTextureCreateInfo *createinfo); 2281 + 2282 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r" 2283 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g" 2284 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b" 2285 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a" 2286 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth" 2287 + #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil" 2288 + 2263 2289 2264 2290 /** 2265 2291 * Creates a buffer object to be used in graphics or compute workflows.
+13 -1
include/SDL3/SDL_haptic.h
··· 299 299 #define SDL_HAPTIC_LEFTRIGHT (1u<<11) 300 300 301 301 /** 302 - * Reserved for future use 302 + * Reserved for future use. 303 303 * 304 304 * \since This macro is available since SDL 3.1.3. 305 305 */ 306 306 #define SDL_HAPTIC_RESERVED1 (1u<<12) 307 + 308 + /** 309 + * Reserved for future use. 310 + * 311 + * \since This macro is available since SDL 3.1.3. 312 + */ 307 313 #define SDL_HAPTIC_RESERVED2 (1u<<13) 314 + 315 + /** 316 + * Reserved for future use. 317 + * 318 + * \since This macro is available since SDL 3.1.3. 319 + */ 308 320 #define SDL_HAPTIC_RESERVED3 (1u<<14) 309 321 310 322 /**
+9
include/SDL3/SDL_hints.h
··· 4021 4021 * \since This hint is available since SDL 3.1.3. 4022 4022 */ 4023 4023 #define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" 4024 + 4025 + /** 4026 + * A variable to specify custom icon resource id from RC file on Windows 4027 + * platform. 4028 + * 4029 + * This hint should be set before SDL is initialized. 4030 + * 4031 + * \since This hint is available since SDL 3.1.3. 4032 + */ 4024 4033 #define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" 4025 4034 4026 4035 /**
+60
include/SDL3/SDL_init.h
··· 113 113 SDL_APP_FAILURE /**< Value that requests termination with error from the main callbacks. */ 114 114 } SDL_AppResult; 115 115 116 + /** 117 + * Function pointer typedef for SDL_AppInit. 118 + * 119 + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind 120 + * the scenes for apps using the optional main callbacks. Apps that want to use 121 + * this should just implement SDL_AppInit directly. 122 + * 123 + * \param appstate a place where the app can optionally store a pointer for 124 + * future use. 125 + * \param argc the standard ANSI C main's argc; number of elements in `argv`. 126 + * \param argv the standard ANSI C main's argv; array of command line 127 + * arguments. 128 + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to 129 + * terminate with success, SDL_APP_CONTINUE to continue. 130 + * 131 + * \since This datatype is available since SDL 3.1.3. 132 + */ 116 133 typedef SDL_AppResult (SDLCALL *SDL_AppInit_func)(void **appstate, int argc, char *argv[]); 134 + 135 + /** 136 + * Function pointer typedef for SDL_AppIterate. 137 + * 138 + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind 139 + * the scenes for apps using the optional main callbacks. Apps that want to use 140 + * this should just implement SDL_AppIterate directly. 141 + * 142 + * \param appstate an optional pointer, provided by the app in SDL_AppInit. 143 + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to 144 + * terminate with success, SDL_APP_CONTINUE to continue. 145 + * 146 + * \since This datatype is available since SDL 3.1.3. 147 + */ 117 148 typedef SDL_AppResult (SDLCALL *SDL_AppIterate_func)(void *appstate); 149 + 150 + /** 151 + * Function pointer typedef for SDL_AppEvent. 152 + * 153 + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind 154 + * the scenes for apps using the optional main callbacks. Apps that want to use 155 + * this should just implement SDL_AppEvent directly. 156 + * 157 + * \param appstate an optional pointer, provided by the app in SDL_AppInit. 158 + * \param event the new event for the app to examine. 159 + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to 160 + * terminate with success, SDL_APP_CONTINUE to continue. 161 + * 162 + * \since This datatype is available since SDL 3.1.3. 163 + */ 118 164 typedef SDL_AppResult (SDLCALL *SDL_AppEvent_func)(void *appstate, SDL_Event *event); 165 + 166 + /** 167 + * Function pointer typedef for SDL_AppQuit. 168 + * 169 + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind 170 + * the scenes for apps using the optional main callbacks. Apps that want to use 171 + * this should just implement SDL_AppEvent directly. 172 + * 173 + * \param appstate an optional pointer, provided by the app in SDL_AppInit. 174 + * \param result the result code that terminated the app (success or failure). 175 + * 176 + * \since This datatype is available since SDL 3.1.3. 177 + */ 119 178 typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate, SDL_AppResult result); 179 + 120 180 121 181 /** 122 182 * Initialize the SDL library.
+64 -2
include/SDL3/SDL_intrin.h
··· 267 267 #endif 268 268 #endif /* compiler version */ 269 269 270 - #if defined(__clang__) && defined(__has_attribute) 270 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 271 + /** 272 + * A macro to decide if the compiler supports `__attribute__((target))`. 273 + * 274 + * Even though this is defined in SDL's public headers, it is generally not 275 + * used directly by apps. Apps should probably just use SDL_TARGETING 276 + * directly, instead. 277 + * 278 + * \since This macro is available since SDL 3.1.3. 279 + * 280 + * \sa SDL_TARGETING 281 + */ 282 + #define SDL_HAS_TARGET_ATTRIBS 283 + 284 + #elif defined(__clang__) && defined(__has_attribute) 271 285 # if __has_attribute(target) 272 286 # define SDL_HAS_TARGET_ATTRIBS 273 287 # endif ··· 277 291 # define SDL_HAS_TARGET_ATTRIBS 278 292 #endif 279 293 280 - #ifdef SDL_HAS_TARGET_ATTRIBS 294 + 295 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 296 + 297 + /** 298 + * A macro to tag a function as targeting a specific CPU architecture. 299 + * 300 + * This is a hint to the compiler that a function should be built with support 301 + * for a CPU instruction set that might be different than the rest of the 302 + * program. 303 + * 304 + * The particulars of this are explained in the GCC documentation: 305 + * 306 + * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target-function-attribute 307 + * 308 + * An example of using this feature is to turn on SSE2 support for a specific 309 + * function, even if the rest of the source code is not compiled to use SSE2 310 + * code: 311 + * 312 + * ```c 313 + * #ifdef SDL_SSE2_INTRINSICS 314 + * static void SDL_TARGETING("sse2") DoSomethingWithSSE2(char *x) { 315 + * ...use SSE2 intrinsic functions, etc... 316 + * } 317 + * #endif 318 + * 319 + * // later... 320 + * #ifdef SDL_SSE2_INTRINSICS 321 + * if (SDL_HasSSE2()) { 322 + * DoSomethingWithSSE2(str); 323 + * } 324 + * #endif 325 + * ``` 326 + * 327 + * The application is, on a whole, built without SSE2 instructions, so it 328 + * will run on Intel machines that don't support SSE2. But then at runtime, 329 + * it checks if the system supports the instructions, and then calls into a 330 + * function that uses SSE2 opcodes. The ifdefs make sure that this code isn't 331 + * used on platforms that don't have SSE2 at all. 332 + * 333 + * On compilers without target support, this is defined to nothing. 334 + * 335 + * This symbol is used by SDL internally, but apps and other libraries are 336 + * welcome to use it for their own interfaces as well. 337 + * 338 + * \since This macro is available since SDL 3.1.3. 339 + */ 340 + #define SDL_TARGETING(x) __attribute__((target(x))) 341 + 342 + #elif defined(SDL_HAS_TARGET_ATTRIBS) 281 343 # define SDL_TARGETING(x) __attribute__((target(x))) 282 344 #else 283 345 # define SDL_TARGETING(x)
+99 -27
include/SDL3/SDL_main.h
··· 28 28 * should look like this: 29 29 * 30 30 * ```c 31 - * int main(int argc, char *argv[]) 32 - * { 33 - * } 31 + * int main(int argc, char *argv[]) 32 + * { 33 + * } 34 34 * ``` 35 35 * 36 36 * SDL will take care of platform specific details on how it gets called. ··· 55 55 #include <SDL3/SDL_error.h> 56 56 #include <SDL3/SDL_events.h> 57 57 58 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 59 + 60 + /** 61 + * Inform SDL that the app is providing an entry point instead of SDL. 62 + * 63 + * SDL does not define this macro, but will check if it is defined when 64 + * including `SDL_main.h`. If defined, SDL will expect the app to provide the 65 + * proper entry point for the platform, and all the other magic details 66 + * needed, like manually calling SDL_SetMainReady. 67 + * 68 + * Please see [README/main-functions](README/main-functions), (or 69 + * docs/README-main-functions.md in the source tree) for a more detailed 70 + * explanation. 71 + * 72 + * \since This macro is used by the headers since SDL 3.1.3. 73 + */ 74 + #define SDL_MAIN_HANDLED 1 75 + 76 + /** 77 + * Inform SDL to use the main callbacks instead of main. 78 + * 79 + * SDL does not define this macro, but will check if it is defined when 80 + * including `SDL_main.h`. If defined, SDL will expect the app to provide 81 + * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and 82 + * SDL_AppQuit. The app should not provide a `main` function in this case, and 83 + * doing so will likely cause the build to fail. 84 + * 85 + * Please see [README/main-functions](README/main-functions), (or 86 + * docs/README-main-functions.md in the source tree) for a more detailed 87 + * explanation. 88 + * 89 + * \since This macro is used by the headers since SDL 3.1.3. 90 + * 91 + * \sa SDL_AppInit 92 + * \sa SDL_AppEvent 93 + * \sa SDL_AppIterate 94 + * \sa SDL_AppQuit 95 + */ 96 + #define SDL_MAIN_USE_CALLBACKS 1 97 + 98 + /** 99 + * Defined if the target platform offers a special mainline through SDL. 100 + * 101 + * This won't be defined otherwise. If defined, SDL's headers will redefine 102 + * `main` to `SDL_main`. 103 + * 104 + * This macro is defined by `SDL_main.h`, which is not automatically included 105 + * by `SDL.h`. 106 + * 107 + * Even if available, an app can define SDL_MAIN_HANDLED and provide their 108 + * own, if they know what they're doing. 109 + * 110 + * This macro is used internally by SDL, and apps probably shouldn't rely on it. 111 + * 112 + * \since This macro is available since SDL 3.1.3. 113 + */ 114 + #define SDL_MAIN_AVAILABLE 115 + 116 + /** 117 + * Defined if the target platform _requires_ a special mainline through SDL. 118 + * 119 + * This won't be defined otherwise. If defined, SDL's headers will redefine 120 + * `main` to `SDL_main`. 121 + * 122 + * This macro is defined by `SDL_main.h`, which is not automatically included 123 + * by `SDL.h`. 124 + * 125 + * Even if required, an app can define SDL_MAIN_HANDLED and provide their 126 + * own, if they know what they're doing. 127 + * 128 + * This macro is used internally by SDL, and apps probably shouldn't rely on it. 129 + * 130 + * \since This macro is available since SDL 3.1.3. 131 + */ 132 + #define SDL_MAIN_NEEDED 133 + 134 + #endif 135 + 58 136 #ifndef SDL_MAIN_HANDLED 59 137 #if defined(SDL_PLATFORM_PRIVATE_MAIN) 60 138 /* Private platforms may have their own ideas about entry points. */ ··· 144 222 #endif 145 223 #endif /* SDL_MAIN_HANDLED */ 146 224 147 - #ifdef SDL_MAIN_EXPORTED 148 - /* We need to export SDL_main so it can be launched from external code, 149 - like SDLActivity.java on Android */ 150 - #define SDLMAIN_DECLSPEC SDL_DECLSPEC 151 - #else 152 - /* usually this is empty */ 153 - #define SDLMAIN_DECLSPEC 154 - #endif /* SDL_MAIN_EXPORTED */ 155 225 156 226 #ifdef SDL_WIKI_DOCUMENTATION_SECTION 157 227 158 228 /** 159 - * Inform SDL to use the main callbacks instead of main. 229 + * A macro to tag a main entry point function as exported. 160 230 * 161 - * SDL does not define this macro, but will check if it is defined when 162 - * including `SDL_main.h`. If defined, SDL will expect the app to provide 163 - * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and 164 - * SDL_AppQuit. The app should not provide a `main` function in this case, and 165 - * doing so will likely cause the build to fail. 231 + * Most platforms don't need this, and the macro will be defined to nothing. 232 + * Some, like Android, keep the entry points in a shared library and need to 233 + * explicitly export the symbols. 166 234 * 167 - * Please see [README/main-functions](README/main-functions), (or 168 - * docs/README-main-functions.md in the source tree) for a more detailed 169 - * explanation. 235 + * External code rarely needs this, and if it needs something, it's almost 236 + * always SDL_DECLSPEC instead. 170 237 * 171 - * \since This macro is used by the headers since SDL 3.1.3. 238 + * \since This macro is available since SDL 3.1.3. 172 239 * 173 - * \sa SDL_AppInit 174 - * \sa SDL_AppEvent 175 - * \sa SDL_AppIterate 176 - * \sa SDL_AppQuit 240 + * \sa SDL_DECLSPEC 177 241 */ 178 - #define SDL_MAIN_USE_CALLBACKS 1 179 - #endif 242 + #define SDLMAIN_DECLSPEC 243 + 244 + #elif defined(SDL_MAIN_EXPORTED) 245 + /* We need to export SDL_main so it can be launched from external code, 246 + like SDLActivity.java on Android */ 247 + #define SDLMAIN_DECLSPEC SDL_DECLSPEC 248 + #else 249 + /* usually this is empty */ 250 + #define SDLMAIN_DECLSPEC 251 + #endif /* SDL_MAIN_EXPORTED */ 180 252 181 253 #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS) 182 254 #define main SDL_main
+152 -6
include/SDL3/SDL_mutex.h
··· 33 33 #include <SDL3/SDL_error.h> 34 34 #include <SDL3/SDL_thread.h> 35 35 36 - /******************************************************************************/ 37 - /* Enable thread safety attributes only with clang. 36 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 37 + /** 38 + * Enable thread safety attributes, only with clang. 39 + * 38 40 * The attributes can be safely erased when compiling with other compilers. 39 41 * 40 42 * To enable analysis, set these environment variables before running cmake: 41 - * export CC=clang 42 - * export CFLAGS="-DSDL_THREAD_SAFETY_ANALYSIS -Wthread-safety" 43 + * 44 + * ```bash 45 + * export CC=clang 46 + * export CFLAGS="-DSDL_THREAD_SAFETY_ANALYSIS -Wthread-safety" 47 + * ``` 43 48 */ 44 - #if defined(SDL_THREAD_SAFETY_ANALYSIS) && \ 45 - defined(__clang__) && (!defined(SWIG)) 49 + #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) 50 + 51 + #elif defined(SDL_THREAD_SAFETY_ANALYSIS) && defined(__clang__) && (!defined(SWIG)) 46 52 #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) 47 53 #else 48 54 #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */ 49 55 #endif 50 56 57 + /** 58 + * Wrapper around Clang thread safety analysis annotations. 59 + * 60 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 61 + * 62 + * \since This macro is available since SDL 3.1.3. 63 + */ 51 64 #define SDL_CAPABILITY(x) \ 52 65 SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) 53 66 67 + /** 68 + * Wrapper around Clang thread safety analysis annotations. 69 + * 70 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 71 + * 72 + * \since This macro is available since SDL 3.1.3. 73 + */ 54 74 #define SDL_SCOPED_CAPABILITY \ 55 75 SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) 56 76 77 + /** 78 + * Wrapper around Clang thread safety analysis annotations. 79 + * 80 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 81 + * 82 + * \since This macro is available since SDL 3.1.3. 83 + */ 57 84 #define SDL_GUARDED_BY(x) \ 58 85 SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) 59 86 87 + /** 88 + * Wrapper around Clang thread safety analysis annotations. 89 + * 90 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 91 + * 92 + * \since This macro is available since SDL 3.1.3. 93 + */ 60 94 #define SDL_PT_GUARDED_BY(x) \ 61 95 SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) 62 96 97 + /** 98 + * Wrapper around Clang thread safety analysis annotations. 99 + * 100 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 101 + * 102 + * \since This macro is available since SDL 3.1.3. 103 + */ 63 104 #define SDL_ACQUIRED_BEFORE(x) \ 64 105 SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) 65 106 107 + /** 108 + * Wrapper around Clang thread safety analysis annotations. 109 + * 110 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 111 + * 112 + * \since This macro is available since SDL 3.1.3. 113 + */ 66 114 #define SDL_ACQUIRED_AFTER(x) \ 67 115 SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) 68 116 117 + /** 118 + * Wrapper around Clang thread safety analysis annotations. 119 + * 120 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 121 + * 122 + * \since This macro is available since SDL 3.1.3. 123 + */ 69 124 #define SDL_REQUIRES(x) \ 70 125 SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x)) 71 126 127 + /** 128 + * Wrapper around Clang thread safety analysis annotations. 129 + * 130 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 131 + * 132 + * \since This macro is available since SDL 3.1.3. 133 + */ 72 134 #define SDL_REQUIRES_SHARED(x) \ 73 135 SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x)) 74 136 137 + /** 138 + * Wrapper around Clang thread safety analysis annotations. 139 + * 140 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 141 + * 142 + * \since This macro is available since SDL 3.1.3. 143 + */ 75 144 #define SDL_ACQUIRE(x) \ 76 145 SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x)) 77 146 147 + /** 148 + * Wrapper around Clang thread safety analysis annotations. 149 + * 150 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 151 + * 152 + * \since This macro is available since SDL 3.1.3. 153 + */ 78 154 #define SDL_ACQUIRE_SHARED(x) \ 79 155 SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x)) 80 156 157 + /** 158 + * Wrapper around Clang thread safety analysis annotations. 159 + * 160 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 161 + * 162 + * \since This macro is available since SDL 3.1.3. 163 + */ 81 164 #define SDL_RELEASE(x) \ 82 165 SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x)) 83 166 167 + /** 168 + * Wrapper around Clang thread safety analysis annotations. 169 + * 170 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 171 + * 172 + * \since This macro is available since SDL 3.1.3. 173 + */ 84 174 #define SDL_RELEASE_SHARED(x) \ 85 175 SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x)) 86 176 177 + /** 178 + * Wrapper around Clang thread safety analysis annotations. 179 + * 180 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 181 + * 182 + * \since This macro is available since SDL 3.1.3. 183 + */ 87 184 #define SDL_RELEASE_GENERIC(x) \ 88 185 SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x)) 89 186 187 + /** 188 + * Wrapper around Clang thread safety analysis annotations. 189 + * 190 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 191 + * 192 + * \since This macro is available since SDL 3.1.3. 193 + */ 90 194 #define SDL_TRY_ACQUIRE(x, y) \ 91 195 SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y)) 92 196 197 + /** 198 + * Wrapper around Clang thread safety analysis annotations. 199 + * 200 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 201 + * 202 + * \since This macro is available since SDL 3.1.3. 203 + */ 93 204 #define SDL_TRY_ACQUIRE_SHARED(x, y) \ 94 205 SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y)) 95 206 207 + /** 208 + * Wrapper around Clang thread safety analysis annotations. 209 + * 210 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 211 + * 212 + * \since This macro is available since SDL 3.1.3. 213 + */ 96 214 #define SDL_EXCLUDES(x) \ 97 215 SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) 98 216 217 + /** 218 + * Wrapper around Clang thread safety analysis annotations. 219 + * 220 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 221 + * 222 + * \since This macro is available since SDL 3.1.3. 223 + */ 99 224 #define SDL_ASSERT_CAPABILITY(x) \ 100 225 SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) 101 226 227 + /** 228 + * Wrapper around Clang thread safety analysis annotations. 229 + * 230 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 231 + * 232 + * \since This macro is available since SDL 3.1.3. 233 + */ 102 234 #define SDL_ASSERT_SHARED_CAPABILITY(x) \ 103 235 SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) 104 236 237 + /** 238 + * Wrapper around Clang thread safety analysis annotations. 239 + * 240 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 241 + * 242 + * \since This macro is available since SDL 3.1.3. 243 + */ 105 244 #define SDL_RETURN_CAPABILITY(x) \ 106 245 SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) 107 246 247 + /** 248 + * Wrapper around Clang thread safety analysis annotations. 249 + * 250 + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h 251 + * 252 + * \since This macro is available since SDL 3.1.3. 253 + */ 108 254 #define SDL_NO_THREAD_SAFETY_ANALYSIS \ 109 255 SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) 110 256
+399 -25
include/SDL3/SDL_pixels.h
··· 213 213 SDL_PACKEDLAYOUT_1010102 214 214 } SDL_PackedLayout; 215 215 216 + /** 217 + * A macro for defining custom FourCC pixel formats. 218 + * 219 + * For example, defining SDL_PIXELFORMAT_YV12 looks like this: 220 + * 221 + * ```c 222 + * SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2') 223 + * ``` 224 + * 225 + * \param A the first character of the FourCC code. 226 + * \param B the second character of the FourCC code. 227 + * \param C the third character of the FourCC code. 228 + * \param D the fourth character of the FourCC code. 229 + * \returns a format value in the style of SDL_PixelFormat. 230 + * 231 + * \threadsafety It is safe to call this macro from any thread. 232 + * 233 + * \since This macro is available since SDL 3.1.3. 234 + */ 216 235 #define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) 217 236 237 + /** 238 + * A macro for defining custom non-FourCC pixel formats. 239 + * 240 + * For example, defining SDL_PIXELFORMAT_RGBA8888 looks like this: 241 + * 242 + * ```c 243 + * SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4) 244 + * ``` 245 + * 246 + * \param type the type of the new format, probably a SDL_PixelType value. 247 + * \param order the order of the new format, probably a SDL_BitmapOrder, SDL_PackedOrder, or SDL_ArrayOrder value. 248 + * \param layout the layout of the new format, probably an SDL_PackedLayout value or zero. 249 + * \param bits the number of bits per pixel of the new format. 250 + * \param bytes the number of bytes per pixel of the new format. 251 + * \returns a format value in the style of SDL_PixelFormat. 252 + * 253 + * \threadsafety It is safe to call this macro from any thread. 254 + * 255 + * \since This macro is available since SDL 3.1.3. 256 + */ 218 257 #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ 219 258 ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ 220 259 ((bits) << 8) | ((bytes) << 0)) 221 260 222 - #define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) 223 - #define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) 224 - #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) 225 - #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) 226 - #define SDL_BITSPERPIXEL(X) \ 227 - (SDL_ISPIXELFORMAT_FOURCC(X) ? 0 : (((X) >> 8) & 0xFF)) 228 - #define SDL_BYTESPERPIXEL(X) \ 229 - (SDL_ISPIXELFORMAT_FOURCC(X) ? \ 230 - ((((X) == SDL_PIXELFORMAT_YUY2) || \ 231 - ((X) == SDL_PIXELFORMAT_UYVY) || \ 232 - ((X) == SDL_PIXELFORMAT_YVYU) || \ 233 - ((X) == SDL_PIXELFORMAT_P010)) ? 2 : 1) : (((X) >> 0) & 0xFF)) 261 + /** 262 + * A macro to retrieve the flags of an SDL_PixelFormat. 263 + * 264 + * This macro is generally not needed directly by an app, which should use 265 + * specific tests, like SDL_ISPIXELFORMAT_FOURCC, instead. 266 + * 267 + * \param format an SDL_PixelFormat to check. 268 + * \returns the flags of `format`. 269 + * 270 + * \threadsafety It is safe to call this macro from any thread. 271 + * 272 + * \since This macro is available since SDL 3.1.3. 273 + */ 274 + #define SDL_PIXELFLAG(format) (((format) >> 28) & 0x0F) 234 275 276 + /** 277 + * A macro to retrieve the type of an SDL_PixelFormat. 278 + * 279 + * This is usually a value from the SDL_PixelType enumeration. 280 + * 281 + * \param format an SDL_PixelFormat to check. 282 + * \returns the type of `format`. 283 + * 284 + * \threadsafety It is safe to call this macro from any thread. 285 + * 286 + * \since This macro is available since SDL 3.1.3. 287 + */ 288 + #define SDL_PIXELTYPE(format) (((format) >> 24) & 0x0F) 289 + 290 + /** 291 + * A macro to retrieve the order of an SDL_PixelFormat. 292 + * 293 + * This is usually a value from the SDL_BitmapOrder, SDL_PackedOrder, or 294 + * SDL_ArrayOrder enumerations, depending on the format type. 295 + * 296 + * \param format an SDL_PixelFormat to check. 297 + * \returns the order of `format`. 298 + * 299 + * \threadsafety It is safe to call this macro from any thread. 300 + * 301 + * \since This macro is available since SDL 3.1.3. 302 + */ 303 + #define SDL_PIXELORDER(format) (((format) >> 20) & 0x0F) 304 + 305 + /** 306 + * A macro to retrieve the layout of an SDL_PixelFormat. 307 + * 308 + * This is usually a value from the SDL_PackedLayout enumeration, or zero if 309 + * a layout doesn't make sense for the format type. 310 + * 311 + * \param format an SDL_PixelFormat to check. 312 + * \returns the layout of `format`. 313 + * 314 + * \threadsafety It is safe to call this macro from any thread. 315 + * 316 + * \since This macro is available since SDL 3.1.3. 317 + */ 318 + #define SDL_PIXELLAYOUT(format) (((format) >> 16) & 0x0F) 319 + 320 + /** 321 + * A macro to determine an SDL_PixelFormat's bits per pixel. 322 + * 323 + * Note that this macro double-evaluates its parameter, so do not use 324 + * expressions with side-effects here. 325 + * 326 + * FourCC formats will report zero here, as it rarely makes sense to measure 327 + * them per-pixel. 328 + * 329 + * \param format an SDL_PixelFormat to check. 330 + * \returns the bits-per-pixel of `format`. 331 + * 332 + * \threadsafety It is safe to call this macro from any thread. 333 + * 334 + * \since This macro is available since SDL 3.1.3. 335 + * 336 + * \sa SDL_BYTESPERPIXEL 337 + */ 338 + #define SDL_BITSPERPIXEL(format) \ 339 + (SDL_ISPIXELFORMAT_FOURCC(format) ? 0 : (((format) >> 8) & 0xFF)) 340 + 341 + /** 342 + * A macro to determine an SDL_PixelFormat's bytes per pixel. 343 + * 344 + * Note that this macro double-evaluates its parameter, so do not use 345 + * expressions with side-effects here. 346 + * 347 + * FourCC formats do their best here, but many of them don't have a meaningful 348 + * measurement of bytes per pixel. 349 + * 350 + * \param format an SDL_PixelFormat to check. 351 + * \returns the bytes-per-pixel of `format`. 352 + * 353 + * \threadsafety It is safe to call this macro from any thread. 354 + * 355 + * \since This macro is available since SDL 3.1.3. 356 + * 357 + * \sa SDL_BITSPERPIXEL 358 + */ 359 + #define SDL_BYTESPERPIXEL(format) \ 360 + (SDL_ISPIXELFORMAT_FOURCC(format) ? \ 361 + ((((format) == SDL_PIXELFORMAT_YUY2) || \ 362 + ((format) == SDL_PIXELFORMAT_UYVY) || \ 363 + ((format) == SDL_PIXELFORMAT_YVYU) || \ 364 + ((format) == SDL_PIXELFORMAT_P010)) ? 2 : 1) : (((format) >> 0) & 0xFF)) 365 + 366 + 367 + /** 368 + * A macro to determine if an SDL_PixelFormat is an indexed format. 369 + * 370 + * Note that this macro double-evaluates its parameter, so do not use 371 + * expressions with side-effects here. 372 + * 373 + * \param format an SDL_PixelFormat to check. 374 + * \returns true if the format is indexed, false otherwise. 375 + * 376 + * \threadsafety It is safe to call this macro from any thread. 377 + * 378 + * \since This macro is available since SDL 3.1.3. 379 + */ 235 380 #define SDL_ISPIXELFORMAT_INDEXED(format) \ 236 381 (!SDL_ISPIXELFORMAT_FOURCC(format) && \ 237 382 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ ··· 239 384 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ 240 385 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) 241 386 387 + /** 388 + * A macro to determine if an SDL_PixelFormat is a packed format. 389 + * 390 + * Note that this macro double-evaluates its parameter, so do not use 391 + * expressions with side-effects here. 392 + * 393 + * \param format an SDL_PixelFormat to check. 394 + * \returns true if the format is packed, false otherwise. 395 + * 396 + * \threadsafety It is safe to call this macro from any thread. 397 + * 398 + * \since This macro is available since SDL 3.1.3. 399 + */ 242 400 #define SDL_ISPIXELFORMAT_PACKED(format) \ 243 401 (!SDL_ISPIXELFORMAT_FOURCC(format) && \ 244 402 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ 245 403 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ 246 404 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) 247 405 406 + /** 407 + * A macro to determine if an SDL_PixelFormat is an array format. 408 + * 409 + * Note that this macro double-evaluates its parameter, so do not use 410 + * expressions with side-effects here. 411 + * 412 + * \param format an SDL_PixelFormat to check. 413 + * \returns true if the format is an array, false otherwise. 414 + * 415 + * \threadsafety It is safe to call this macro from any thread. 416 + * 417 + * \since This macro is available since SDL 3.1.3. 418 + */ 248 419 #define SDL_ISPIXELFORMAT_ARRAY(format) \ 249 420 (!SDL_ISPIXELFORMAT_FOURCC(format) && \ 250 421 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ ··· 253 424 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ 254 425 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) 255 426 427 + /** 428 + * A macro to determine if an SDL_PixelFormat is a 10-bit format. 429 + * 430 + * Note that this macro double-evaluates its parameter, so do not use 431 + * expressions with side-effects here. 432 + * 433 + * \param format an SDL_PixelFormat to check. 434 + * \returns true if the format is 10-bit, false otherwise. 435 + * 436 + * \threadsafety It is safe to call this macro from any thread. 437 + * 438 + * \since This macro is available since SDL 3.1.3. 439 + */ 256 440 #define SDL_ISPIXELFORMAT_10BIT(format) \ 257 441 (!SDL_ISPIXELFORMAT_FOURCC(format) && \ 258 442 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32) && \ 259 443 (SDL_PIXELLAYOUT(format) == SDL_PACKEDLAYOUT_2101010))) 260 444 445 + /** 446 + * A macro to determine if an SDL_PixelFormat is a floating point format. 447 + * 448 + * Note that this macro double-evaluates its parameter, so do not use 449 + * expressions with side-effects here. 450 + * 451 + * \param format an SDL_PixelFormat to check. 452 + * \returns true if the format is 10-bit, false otherwise. 453 + * 454 + * \threadsafety It is safe to call this macro from any thread. 455 + * 456 + * \since This macro is available since SDL 3.1.3. 457 + */ 261 458 #define SDL_ISPIXELFORMAT_FLOAT(format) \ 262 459 (!SDL_ISPIXELFORMAT_FOURCC(format) && \ 263 460 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ 264 461 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) 265 462 463 + /** 464 + * A macro to determine if an SDL_PixelFormat has an alpha channel. 465 + * 466 + * Note that this macro double-evaluates its parameter, so do not use 467 + * expressions with side-effects here. 468 + * 469 + * \param format an SDL_PixelFormat to check. 470 + * \returns true if the format has alpha, false otherwise. 471 + * 472 + * \threadsafety It is safe to call this macro from any thread. 473 + * 474 + * \since This macro is available since SDL 3.1.3. 475 + */ 266 476 #define SDL_ISPIXELFORMAT_ALPHA(format) \ 267 477 ((SDL_ISPIXELFORMAT_PACKED(format) && \ 268 478 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ ··· 275 485 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ 276 486 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) 277 487 278 - /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ 279 - #define SDL_ISPIXELFORMAT_FOURCC(format) \ 488 + 489 + /** 490 + * A macro to determine if an SDL_PixelFormat is a "FourCC" format. 491 + * 492 + * This covers custom and other unusual formats. 493 + * 494 + * Note that this macro double-evaluates its parameter, so do not use 495 + * expressions with side-effects here. 496 + * 497 + * \param format an SDL_PixelFormat to check. 498 + * \returns true if the format has alpha, false otherwise. 499 + * 500 + * \threadsafety It is safe to call this macro from any thread. 501 + * 502 + * \since This macro is available since SDL 3.1.3. 503 + */ 504 + #define SDL_ISPIXELFORMAT_FOURCC(format) /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ \ 280 505 ((format) && (SDL_PIXELFLAG(format) != 1)) 281 506 282 507 /* Note: If you modify this enum, update SDL_GetPixelFormatName() */ ··· 591 816 592 817 593 818 /* Colorspace definition */ 819 + 820 + /** 821 + * A macro for defining custom SDL_Colorspace formats. 822 + * 823 + * For example, defining SDL_COLORSPACE_SRGB looks like this: 824 + * 825 + * ```c 826 + * SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, 827 + * SDL_COLOR_RANGE_FULL, 828 + * SDL_COLOR_PRIMARIES_BT709, 829 + * SDL_TRANSFER_CHARACTERISTICS_SRGB, 830 + * SDL_MATRIX_COEFFICIENTS_IDENTITY, 831 + * SDL_CHROMA_LOCATION_NONE) 832 + * ``` 833 + * 834 + * \param type the type of the new format, probably an SDL_ColorType value. 835 + * \param range the range of the new format, probably a SDL_ColorRange value. 836 + * \param primaries the primaries of the new format, probably an SDL_ColorPrimaries value. 837 + * \param transfer the transfer characteristics of the new format, probably an SDL_TransferCharacteristics value. 838 + * \param matrix the matrix coefficients of the new format, probably an SDL_MatrixCoefficients value. 839 + * \param chroma the chroma sample location of the new format, probably an SDL_ChromaLocation value. 840 + * \returns a format value in the style of SDL_Colorspace. 841 + * 842 + * \threadsafety It is safe to call this macro from any thread. 843 + * 844 + * \since This macro is available since SDL 3.1.3. 845 + */ 594 846 #define SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma) \ 595 847 (((Uint32)(type) << 28) | ((Uint32)(range) << 24) | ((Uint32)(chroma) << 20) | \ 596 848 ((Uint32)(primaries) << 10) | ((Uint32)(transfer) << 5) | ((Uint32)(matrix) << 0)) 597 849 598 - #define SDL_COLORSPACETYPE(X) (SDL_ColorType)(((X) >> 28) & 0x0F) 599 - #define SDL_COLORSPACERANGE(X) (SDL_ColorRange)(((X) >> 24) & 0x0F) 600 - #define SDL_COLORSPACECHROMA(X) (SDL_ChromaLocation)(((X) >> 20) & 0x0F) 601 - #define SDL_COLORSPACEPRIMARIES(X) (SDL_ColorPrimaries)(((X) >> 10) & 0x1F) 602 - #define SDL_COLORSPACETRANSFER(X) (SDL_TransferCharacteristics)(((X) >> 5) & 0x1F) 603 - #define SDL_COLORSPACEMATRIX(X) (SDL_MatrixCoefficients)((X) & 0x1F) 850 + /** 851 + * A macro to retrieve the type of an SDL_Colorspace. 852 + * 853 + * \param cspace an SDL_Colorspace to check. 854 + * \returns the SDL_ColorType for `cspace`. 855 + * 856 + * \threadsafety It is safe to call this macro from any thread. 857 + * 858 + * \since This macro is available since SDL 3.1.3. 859 + */ 860 + #define SDL_COLORSPACETYPE(cspace) (SDL_ColorType)(((cspace) >> 28) & 0x0F) 861 + 862 + /** 863 + * A macro to retrieve the range of an SDL_Colorspace. 864 + * 865 + * \param cspace an SDL_Colorspace to check. 866 + * \returns the SDL_ColorRange of `cspace`. 867 + * 868 + * \threadsafety It is safe to call this macro from any thread. 869 + * 870 + * \since This macro is available since SDL 3.1.3. 871 + */ 872 + #define SDL_COLORSPACERANGE(cspace) (SDL_ColorRange)(((cspace) >> 24) & 0x0F) 873 + 874 + /** 875 + * A macro to retrieve the chroma sample location of an SDL_Colorspace. 876 + * 877 + * \param cspace an SDL_Colorspace to check. 878 + * \returns the SDL_ChromaLocation of `cspace`. 879 + * 880 + * \threadsafety It is safe to call this macro from any thread. 881 + * 882 + * \since This macro is available since SDL 3.1.3. 883 + */ 884 + #define SDL_COLORSPACECHROMA(cspace) (SDL_ChromaLocation)(((cspace) >> 20) & 0x0F) 885 + 886 + /** 887 + * A macro to retrieve the primaries of an SDL_Colorspace. 888 + * 889 + * \param cspace an SDL_Colorspace to check. 890 + * \returns the SDL_ColorPrimaries of `cspace`. 891 + * 892 + * \threadsafety It is safe to call this macro from any thread. 893 + * 894 + * \since This macro is available since SDL 3.1.3. 895 + */ 896 + #define SDL_COLORSPACEPRIMARIES(cspace) (SDL_ColorPrimaries)(((cspace) >> 10) & 0x1F) 897 + 898 + /** 899 + * A macro to retrieve the transfer characteristics of an SDL_Colorspace. 900 + * 901 + * \param cspace an SDL_Colorspace to check. 902 + * \returns the SDL_TransferCharacteristics of `cspace`. 903 + * 904 + * \threadsafety It is safe to call this macro from any thread. 905 + * 906 + * \since This macro is available since SDL 3.1.3. 907 + */ 908 + #define SDL_COLORSPACETRANSFER(cspace) (SDL_TransferCharacteristics)(((cspace) >> 5) & 0x1F) 909 + 910 + /** 911 + * A macro to retrieve the matrix coefficients of an SDL_Colorspace. 912 + * 913 + * \param cspace an SDL_Colorspace to check. 914 + * \returns the SDL_MatrixCoefficients of `cspace`. 915 + * 916 + * \threadsafety It is safe to call this macro from any thread. 917 + * 918 + * \since This macro is available since SDL 3.1.3. 919 + */ 920 + #define SDL_COLORSPACEMATRIX(cspace) (SDL_MatrixCoefficients)((cspace) & 0x1F) 921 + 922 + /** 923 + * A macro to determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix coefficients. 924 + * 925 + * Note that this macro double-evaluates its parameter, so do not use 926 + * expressions with side-effects here. 927 + * 928 + * \param cspace an SDL_Colorspace to check. 929 + * \returns true if BT601 or BT470BG, false otherwise. 930 + * 931 + * \threadsafety It is safe to call this macro from any thread. 932 + * 933 + * \since This macro is available since SDL 3.1.3. 934 + */ 935 + #define SDL_ISCOLORSPACE_MATRIX_BT601(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT470BG) 936 + 937 + /** 938 + * A macro to determine if an SDL_Colorspace uses BT709 matrix coefficients. 939 + * 940 + * \param cspace an SDL_Colorspace to check. 941 + * \returns true if BT709, false otherwise. 942 + * 943 + * \threadsafety It is safe to call this macro from any thread. 944 + * 945 + * \since This macro is available since SDL 3.1.3. 946 + */ 947 + #define SDL_ISCOLORSPACE_MATRIX_BT709(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT709) 948 + 949 + /** 950 + * A macro to determine if an SDL_Colorspace uses BT2020_NCL matrix coefficients. 951 + * 952 + * \param cspace an SDL_Colorspace to check. 953 + * \returns true if BT709, false otherwise. 954 + * 955 + * \threadsafety It is safe to call this macro from any thread. 956 + * 957 + * \since This macro is available since SDL 3.1.3. 958 + */ 959 + #define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL) 604 960 605 - #define SDL_ISCOLORSPACE_MATRIX_BT601(X) (SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT470BG) 606 - #define SDL_ISCOLORSPACE_MATRIX_BT709(X) (SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT709) 607 - #define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(X) (SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL) 608 - #define SDL_ISCOLORSPACE_LIMITED_RANGE(X) (SDL_COLORSPACERANGE(X) != SDL_COLOR_RANGE_FULL) 609 - #define SDL_ISCOLORSPACE_FULL_RANGE(X) (SDL_COLORSPACERANGE(X) == SDL_COLOR_RANGE_FULL) 961 + /** 962 + * A macro to determine if an SDL_Colorspace has a limited range. 963 + * 964 + * \param cspace an SDL_Colorspace to check. 965 + * \returns true if limited range, false otherwise. 966 + * 967 + * \threadsafety It is safe to call this macro from any thread. 968 + * 969 + * \since This macro is available since SDL 3.1.3. 970 + */ 971 + #define SDL_ISCOLORSPACE_LIMITED_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) != SDL_COLOR_RANGE_FULL) 972 + 973 + /** 974 + * A macro to determine if an SDL_Colorspace has a full range. 975 + * 976 + * \param cspace an SDL_Colorspace to check. 977 + * \returns true if full range, false otherwise. 978 + * 979 + * \threadsafety It is safe to call this macro from any thread. 980 + * 981 + * \since This macro is available since SDL 3.1.3. 982 + */ 983 + #define SDL_ISCOLORSPACE_FULL_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) == SDL_COLOR_RANGE_FULL) 610 984 611 985 /** 612 986 * Colorspace definitions.
+9 -1
include/SDL3/SDL_platform_defines.h
··· 357 357 #define WINAPI_FAMILY_WINRT 0 358 358 #endif /* HAVE_WINAPIFAMILY_H */ 359 359 360 - #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H 360 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 361 + /** 362 + * A preprocessor macro that defined to 1 if compiling for Windows Phone. 363 + * 364 + * \since This macro is available since SDL 3.1.3. 365 + */ 366 + #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) 367 + 368 + #elif HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H 361 369 #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) 362 370 #else 363 371 #define SDL_WINAPI_FAMILY_PHONE 0
+7
include/SDL3/SDL_process.h
··· 54 54 extern "C" { 55 55 #endif 56 56 57 + /** 58 + * An opaque handle representing a system process. 59 + * 60 + * \since This datatype is available since SDL 3.1.3. 61 + * 62 + * \sa SDL_CreateProcess 63 + */ 57 64 typedef struct SDL_Process SDL_Process; 58 65 59 66 /**
+655 -19
include/SDL3/SDL_stdinc.h
··· 753 753 #endif 754 754 755 755 /* Annotations to help code analysis tools */ 756 - #ifdef SDL_DISABLE_ANALYZE_MACROS 756 + #ifdef SDL_WIKI_DOCUMENTATION_SECTION 757 + 758 + /** 759 + * Macro that annotates function params with input buffer size. 760 + * 761 + * If we were to annotate `memcpy`: 762 + * 763 + * ```c 764 + * void *memcpy(void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); 765 + * ``` 766 + * 767 + * This notes that `src` should be `len` bytes in size and is only read by the 768 + * function. The compiler or other analysis tools can warn when this doesn't 769 + * appear to be the case. 770 + * 771 + * On compilers without this annotation mechanism, this is defined to nothing. 772 + * 773 + * \since This macro is available since SDL 3.1.3. 774 + */ 775 + #define SDL_IN_BYTECAP(x) _In_bytecount_(x) 776 + 777 + /** 778 + * Macro that annotates function params with input/output string buffer size. 779 + * 780 + * If we were to annotate `strlcat`: 781 + * 782 + * ```c 783 + * size_t strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); 784 + * ``` 785 + * 786 + * This notes that `dst` is a null-terminated C string, should be `maxlen` 787 + * bytes in size, and is both read from and written to by the function. The 788 + * compiler or other analysis tools can warn when this doesn't appear to be 789 + * the case. 790 + * 791 + * On compilers without this annotation mechanism, this is defined to nothing. 792 + * 793 + * \since This macro is available since SDL 3.1.3. 794 + */ 795 + #define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) 796 + 797 + /** 798 + * Macro that annotates function params with output string buffer size. 799 + * 800 + * If we were to annotate `snprintf`: 801 + * 802 + * ```c 803 + * int snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, ...); 804 + * ``` 805 + * 806 + * This notes that `text` is a null-terminated C string, should be `maxlen` 807 + * bytes in size, and is only written to by the function. The compiler or 808 + * other analysis tools can warn when this doesn't appear to be the case. 809 + * 810 + * On compilers without this annotation mechanism, this is defined to nothing. 811 + * 812 + * \since This macro is available since SDL 3.1.3. 813 + */ 814 + #define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) 815 + 816 + /** 817 + * Macro that annotates function params with output buffer size. 818 + * 819 + * If we were to annotate `wcsncpy`: 820 + * 821 + * ```c 822 + * char *wcscpy(SDL_OUT_CAP(bufsize) wchar_t *dst, const wchar_t *src, size_t bufsize); 823 + * ``` 824 + * 825 + * This notes that `dst` should have a capacity of `bufsize` wchar_t in size, 826 + * and is only written to by the function. The compiler or other analysis 827 + * tools can warn when this doesn't appear to be the case. 828 + * 829 + * This operates on counts of objects, not bytes. Use SDL_OUT_BYTECAP for bytes. 830 + * 831 + * On compilers without this annotation mechanism, this is defined to nothing. 832 + * 833 + * \since This macro is available since SDL 3.1.3. 834 + */ 835 + #define SDL_OUT_CAP(x) _Out_cap_(x) 836 + 837 + /** 838 + * Macro that annotates function params with output buffer size. 839 + * 840 + * If we were to annotate `memcpy`: 841 + * 842 + * ```c 843 + * void *memcpy(SDL_OUT_BYTECAP(bufsize) void *dst, const void *src, size_t bufsize); 844 + * ``` 845 + * 846 + * This notes that `dst` should have a capacity of `bufsize` bytes in size, 847 + * and is only written to by the function. The compiler or other analysis 848 + * tools can warn when this doesn't appear to be the case. 849 + * 850 + * On compilers without this annotation mechanism, this is defined to nothing. 851 + * 852 + * \since This macro is available since SDL 3.1.3. 853 + */ 854 + #define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) 855 + 856 + /** 857 + * Macro that annotates function params with output buffer string size. 858 + * 859 + * If we were to annotate `strcpy`: 860 + * 861 + * ```c 862 + * char *strcpy(SDL_OUT_Z_BYTECAP(bufsize) char *dst, const char *src, size_t bufsize); 863 + * ``` 864 + * 865 + * This notes that `dst` should have a capacity of `bufsize` bytes in size, 866 + * and a zero-terminated string is written to it by the function. The compiler 867 + * or other analysis tools can warn when this doesn't appear to be the case. 868 + * 869 + * On compilers without this annotation mechanism, this is defined to nothing. 870 + * 871 + * \since This macro is available since SDL 3.1.3. 872 + */ 873 + #define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) 874 + 875 + /** 876 + * Macro that annotates function params as printf-style format strings. 877 + * 878 + * If we were to annotate `fprintf`: 879 + * 880 + * ```c 881 + * int fprintf(FILE *f, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); 882 + * ``` 883 + * 884 + * This notes that `fmt` should be a printf-style format string. The compiler 885 + * or other analysis tools can warn when this doesn't appear to be the case. 886 + * 887 + * On compilers without this annotation mechanism, this is defined to nothing. 888 + * 889 + * \since This macro is available since SDL 3.1.3. 890 + */ 891 + #define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ 892 + 893 + /** 894 + * Macro that annotates function params as scanf-style format strings. 895 + * 896 + * If we were to annotate `fscanf`: 897 + * 898 + * ```c 899 + * int fscanf(FILE *f, SDL_SCANF_FORMAT_STRING const char *fmt, ...); 900 + * ``` 901 + * 902 + * This notes that `fmt` should be a scanf-style format string. The compiler 903 + * or other analysis tools can warn when this doesn't appear to be the case. 904 + * 905 + * On compilers without this annotation mechanism, this is defined to nothing. 906 + * 907 + * \since This macro is available since SDL 3.1.3. 908 + */ 909 + #define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ 910 + 911 + /** 912 + * Macro that annotates a vararg function that operates like printf. 913 + * 914 + * If we were to annotate `fprintf`: 915 + * 916 + * ```c 917 + * int fprintf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 918 + * ``` 919 + * 920 + * This notes that the second parameter should be a printf-style format string, followed by `...`. 921 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 922 + * 923 + * On compilers without this annotation mechanism, this is defined to nothing. 924 + * 925 + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which between them 926 + * will cover at least Visual Studio, GCC, and Clang. 927 + * 928 + * \since This macro is available since SDL 3.1.3. 929 + */ 930 + #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) 931 + 932 + /** 933 + * Macro that annotates a va_list function that operates like printf. 934 + * 935 + * If we were to annotate `vfprintf`: 936 + * 937 + * ```c 938 + * int vfprintf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); 939 + * ``` 940 + * 941 + * This notes that the second parameter should be a printf-style format string, followed by a va_list. 942 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 943 + * 944 + * On compilers without this annotation mechanism, this is defined to nothing. 945 + * 946 + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which between them 947 + * will cover at least Visual Studio, GCC, and Clang. 948 + * 949 + * \since This macro is available since SDL 3.1.3. 950 + */ 951 + #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) 952 + 953 + /** 954 + * Macro that annotates a vararg function that operates like scanf. 955 + * 956 + * If we were to annotate `fscanf`: 957 + * 958 + * ```c 959 + * int fscanf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNCV(2); 960 + * ``` 961 + * 962 + * This notes that the second parameter should be a scanf-style format string, followed by `...`. 963 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 964 + * 965 + * On compilers without this annotation mechanism, this is defined to nothing. 966 + * 967 + * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which between them 968 + * will cover at least Visual Studio, GCC, and Clang. 969 + * 970 + * \since This macro is available since SDL 3.1.3. 971 + */ 972 + #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) 973 + 974 + /** 975 + * Macro that annotates a va_list function that operates like scanf. 976 + * 977 + * If we were to annotate `vfscanf`: 978 + * 979 + * ```c 980 + * int vfscanf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); 981 + * ``` 982 + * 983 + * This notes that the second parameter should be a scanf-style format string, followed by a va_list. 984 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 985 + * 986 + * On compilers without this annotation mechanism, this is defined to nothing. 987 + * 988 + * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which between them 989 + * will cover at least Visual Studio, GCC, and Clang. 990 + * 991 + * \since This macro is available since SDL 3.1.3. 992 + */ 993 + #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) 994 + 995 + /** 996 + * Macro that annotates a vararg function that operates like wprintf. 997 + * 998 + * If we were to annotate `fwprintf`: 999 + * 1000 + * ```c 1001 + * int fwprintf(FILE *f, const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(2); 1002 + * ``` 1003 + * 1004 + * This notes that the second parameter should be a wprintf-style format wide string, followed by `...`. 1005 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 1006 + * 1007 + * On compilers without this annotation mechanism, this is defined to nothing. 1008 + * 1009 + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which between them 1010 + * will cover at least Visual Studio, GCC, and Clang. 1011 + * 1012 + * \since This macro is available since SDL 3.1.3. 1013 + */ 1014 + #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */ 1015 + 1016 + /** 1017 + * Macro that annotates a va_list function that operates like wprintf. 1018 + * 1019 + * If we were to annotate `vfwprintf`: 1020 + * 1021 + * ```c 1022 + * int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNC(2); 1023 + * ``` 1024 + * 1025 + * This notes that the second parameter should be a wprintf-style format wide string, followed by a va_list. 1026 + * The compiler or other analysis tools can warn when this doesn't appear to be the case. 1027 + * 1028 + * On compilers without this annotation mechanism, this is defined to nothing. 1029 + * 1030 + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which between them 1031 + * will cover at least Visual Studio, GCC, and Clang. 1032 + * 1033 + * \since This macro is available since SDL 3.1.3. 1034 + */ 1035 + #define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, 0 ))) */ 1036 + 1037 + #elif defined(SDL_DISABLE_ANALYZE_MACROS) 757 1038 #define SDL_IN_BYTECAP(x) 758 1039 #define SDL_INOUT_Z_CAP(x) 759 1040 #define SDL_OUT_Z_CAP(x) ··· 2295 2576 #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) 2296 2577 2297 2578 2579 + /** 2580 + * Compare two buffers of memory. 2581 + * 2582 + * \param s1 the first buffer to compare. NULL is not permitted! 2583 + * \param s2 the second buffer to compare. NULL is not permitted! 2584 + * \param len the number of bytes to compare between the buffers. 2585 + * \returns less than zero if s1 is "less than" s2, greater than zero if 2586 + * s1 is "greater than" s2, and zero if the buffers match 2587 + * exactly for `len` bytes. 2588 + * 2589 + * \threadsafety It is safe to call this function from any thread. 2590 + * 2591 + * \since This function is available since SDL 3.1.3. 2592 + */ 2298 2593 extern SDL_DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); 2299 2594 2595 + /** 2596 + * This works exactly like wcslen() but doesn't require access to a C runtime. 2597 + * 2598 + * Counts the number of wchar_t values in `wstr`, excluding the null 2599 + * terminator. 2600 + * 2601 + * Like SDL_strlen only counts bytes and not codepoints in a UTF-8 string, 2602 + * this counts wchar_t values in a string, even if the string's encoding is of 2603 + * variable width, like UTF-16. 2604 + * 2605 + * Also be aware that wchar_t is different sizes on different platforms (4 2606 + * bytes on Linux, 2 on Windows, etc). 2607 + * 2608 + * \param wstr The null-terminated wide string to read. Must not be NULL. 2609 + * \returns the length (in wchar_t values, excluding the null terminator) of `wstr`. 2610 + * 2611 + * \threadsafety It is safe to call this function from any thread. 2612 + * 2613 + * \since This function is available since SDL 3.1.3. 2614 + * 2615 + * \sa SDL_wcsnlen 2616 + * \sa SDL_utf8strlen 2617 + * \sa SDL_utf8strnlen 2618 + */ 2300 2619 extern SDL_DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); 2620 + 2621 + /** 2622 + * This works exactly like wcsnlen() but doesn't require access to a C 2623 + * runtime. 2624 + * 2625 + * Counts up to a maximum of `maxlen` wchar_t values in `wstr`, excluding the 2626 + * null terminator. 2627 + * 2628 + * Like SDL_strnlen only counts bytes and not codepoints in a UTF-8 string, 2629 + * this counts wchar_t values in a string, even if the string's encoding is of 2630 + * variable width, like UTF-16. 2631 + * 2632 + * Also be aware that wchar_t is different sizes on different platforms (4 2633 + * bytes on Linux, 2 on Windows, etc). 2634 + * 2635 + * Also, `maxlen` is a count of wide characters, not bytes! 2636 + * 2637 + * \param wstr The null-terminated wide string to read. Must not be NULL. 2638 + * \param maxlen The maximum amount of wide characters to count. 2639 + * \returns the length (in wide characters, excluding the null terminator) of 2640 + * `wstr` but never more than `maxlen`. 2641 + * 2642 + * \threadsafety It is safe to call this function from any thread. 2643 + * 2644 + * \since This function is available since SDL 3.1.3. 2645 + * 2646 + * \sa SDL_wcslen 2647 + * \sa SDL_utf8strlen 2648 + * \sa SDL_utf8strnlen 2649 + */ 2301 2650 extern SDL_DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen); 2302 2651 2303 2652 /** ··· 2316 2665 * \param src The null-terminated wide string to copy. Must not be NULL, and 2317 2666 * must not overlap with `dst`. 2318 2667 * \param maxlen The length (in wide characters) of the destination buffer. 2319 - * \returns The length (in wide characters, excluding the null terminator) of 2668 + * \returns the length (in wide characters, excluding the null terminator) of 2320 2669 * `src`. 2321 2670 * 2322 2671 * \threadsafety It is safe to call this function from any thread. ··· 2345 2694 * \param src The second null-terminated wide string. Must not be NULL, and 2346 2695 * must not overlap with `dst`. 2347 2696 * \param maxlen The length (in wide characters) of the destination buffer. 2348 - * \returns The length (in wide characters, excluding the null terminator) of 2697 + * \returns the length (in wide characters, excluding the null terminator) of 2349 2698 * the string in `dst` plus the length of `src`. 2350 2699 * 2351 2700 * \threadsafety It is safe to call this function from any thread. ··· 2356 2705 */ 2357 2706 extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); 2358 2707 2708 + /** 2709 + * Allocate a copy of a wide string. 2710 + * 2711 + * This allocates enough space for a null-terminated copy of `wstr`, using 2712 + * SDL_malloc, and then makes a copy of the string into this space. 2713 + * 2714 + * The returned string is owned by the caller, and should be passed to 2715 + * SDL_free when no longer needed. 2716 + * 2717 + * \param wstr the string to copy. 2718 + * \returns a pointer to the newly-allocated wide string. 2719 + * 2720 + * \threadsafety It is safe to call this function from any thread. 2721 + * 2722 + * \since This function is available since SDL 3.1.3. 2723 + */ 2359 2724 extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsdup(const wchar_t *wstr); 2725 + 2726 + /** 2727 + * Search a wide string for the first instance of a specific substring. 2728 + * 2729 + * The search ends once it finds the requested substring, or a null 2730 + * terminator byte to end the string. 2731 + * 2732 + * Note that this looks for strings of _wide characters_, not _codepoints_, so 2733 + * it's legal to search for malformed and incomplete UTF-16 sequences. 2734 + * 2735 + * \param haystack the wide string to search. Must not be NULL. 2736 + * \param needle the wide string to search for. Must not be NULL. 2737 + * \returns a pointer to the first instance of `needle` in the string, or NULL if not found. 2738 + * 2739 + * \threadsafety It is safe to call this function from any thread. 2740 + * 2741 + * \since This function is available since SDL 3.1.3. 2742 + */ 2360 2743 extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle); 2744 + 2745 + /** 2746 + * Search a wide string, up to n wide chars, for the first instance of a specific substring. 2747 + * 2748 + * The search ends once it finds the requested substring, or a null 2749 + * terminator value to end the string, or `maxlen` wide character have been 2750 + * examined. It is possible to use this function on a wide string without a 2751 + * null terminator. 2752 + * 2753 + * Note that this looks for strings of _wide characters_, not _codepoints_, so 2754 + * it's legal to search for malformed and incomplete UTF-16 sequences. 2755 + * 2756 + * \param haystack the wide string to search. Must not be NULL. 2757 + * \param needle the wide string to search for. Must not be NULL. 2758 + * \param maxlen the maximum number of wide characters to search in `haystack`. 2759 + * \returns a pointer to the first instance of `needle` in the string, or NULL if not found. 2760 + * 2761 + * \threadsafety It is safe to call this function from any thread. 2762 + * 2763 + * \since This function is available since SDL 3.1.3. 2764 + */ 2361 2765 extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen); 2362 2766 2363 2767 /** ··· 2499 2903 * to 36 inclusive. If 0, the base will be inferred from the 2500 2904 * number's prefix (0x for hexadecimal, 0 for octal, decimal 2501 2905 * otherwise). 2502 - * \returns The parsed `long`, or 0 if no number could be parsed. 2906 + * \returns the parsed `long`, or 0 if no number could be parsed. 2503 2907 * 2504 2908 * \threadsafety It is safe to call this function from any thread. 2505 2909 * ··· 2517 2921 * If you need the length of a UTF-8 string, consider using SDL_utf8strlen(). 2518 2922 * 2519 2923 * \param str The null-terminated string to read. Must not be NULL. 2520 - * \returns The length (in bytes, excluding the null terminator) of `src`. 2924 + * \returns the length (in bytes, excluding the null terminator) of `src`. 2521 2925 * 2522 2926 * \threadsafety It is safe to call this function from any thread. 2523 2927 * ··· 2540 2944 * 2541 2945 * \param str The null-terminated string to read. Must not be NULL. 2542 2946 * \param maxlen The maximum amount of bytes to count. 2543 - * \returns The length (in bytes, excluding the null terminator) of `src` but 2947 + * \returns the length (in bytes, excluding the null terminator) of `src` but 2544 2948 * never more than `maxlen`. 2545 2949 * 2546 2950 * \threadsafety It is safe to call this function from any thread. ··· 2570 2974 * \param src The null-terminated string to copy. Must not be NULL, and must 2571 2975 * not overlap with `dst`. 2572 2976 * \param maxlen The length (in characters) of the destination buffer. 2573 - * \returns The length (in characters, excluding the null terminator) of 2977 + * \returns the length (in characters, excluding the null terminator) of 2574 2978 * `src`. 2575 2979 * 2576 2980 * \threadsafety It is safe to call this function from any thread. ··· 2600 3004 * must not overlap with `dst`. 2601 3005 * \param dst_bytes The length (in bytes) of the destination buffer. Must not 2602 3006 * be 0. 2603 - * \returns The number of bytes written, excluding the null terminator. 3007 + * \returns the number of bytes written, excluding the null terminator. 2604 3008 * 2605 3009 * \threadsafety It is safe to call this function from any thread. 2606 3010 * ··· 2627 3031 * \param src The second null-terminated string. Must not be NULL, and must 2628 3032 * not overlap with `dst`. 2629 3033 * \param maxlen The length (in characters) of the destination buffer. 2630 - * \returns The length (in characters, excluding the null terminator) of the 3034 + * \returns the length (in characters, excluding the null terminator) of the 2631 3035 * string in `dst` plus the length of `src`. 2632 3036 * 2633 3037 * \threadsafety It is safe to call this function from any thread. ··· 2638 3042 */ 2639 3043 extern SDL_DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); 2640 3044 3045 + /** 3046 + * Allocate a copy of a string. 3047 + * 3048 + * This allocates enough space for a null-terminated copy of `str`, using 3049 + * SDL_malloc, and then makes a copy of the string into this space. 3050 + * 3051 + * The returned string is owned by the caller, and should be passed to 3052 + * SDL_free when no longer needed. 3053 + * 3054 + * \param str the string to copy. 3055 + * \returns a pointer to the newly-allocated string. 3056 + * 3057 + * \threadsafety It is safe to call this function from any thread. 3058 + * 3059 + * \since This function is available since SDL 3.1.3. 3060 + */ 2641 3061 extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strdup(const char *str); 3062 + 3063 + /** 3064 + * Allocate a copy of a string, up to n characters. 3065 + * 3066 + * This allocates enough space for a null-terminated copy of `str`, up to 3067 + * `maxlen` bytes, using SDL_malloc, and then makes a copy of the string 3068 + * into this space. 3069 + * 3070 + * If the string is longer than `maxlen` bytes, the returned string will 3071 + * be `maxlen` bytes long, plus a null-terminator character that isn't 3072 + * included in the count. 3073 + * 3074 + * The returned string is owned by the caller, and should be passed to 3075 + * SDL_free when no longer needed. 3076 + * 3077 + * \param str the string to copy. 3078 + * \param maxlen the maximum length of the copied string, not counting 3079 + * the null-terminator character. 3080 + * \returns a pointer to the newly-allocated string. 3081 + * 3082 + * \threadsafety It is safe to call this function from any thread. 3083 + * 3084 + * \since This function is available since SDL 3.1.3. 3085 + */ 2642 3086 extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strndup(const char *str, size_t maxlen); 3087 + 3088 + /** 3089 + * Reverse a string's contents. 3090 + * 3091 + * This reverses a null-terminated string in-place. Only the content of the 3092 + * string is reversed; the null-terminator character remains at the end of the 3093 + * reversed string. 3094 + * 3095 + * **WARNING**: This function reverses the _bytes_ of the string, not the 3096 + * codepoints. If `str` is a UTF-8 string with Unicode codepoints > 127, this 3097 + * will ruin the string data. You should only use this function on strings 3098 + * that are completely comprised of low ASCII characters. 3099 + * 3100 + * \param str the string to reverse. 3101 + * \returns `str`. 3102 + * 3103 + * \threadsafety It is safe to call this function from any thread. 3104 + * 3105 + * \since This function is available since SDL 3.1.3. 3106 + */ 2643 3107 extern SDL_DECLSPEC char * SDLCALL SDL_strrev(char *str); 2644 3108 2645 3109 /** ··· 3059 3523 * `(int)SDL_strtol(str, NULL, 10)`. 3060 3524 * 3061 3525 * \param str The null-terminated string to read. Must not be NULL. 3062 - * \returns The parsed `int`. 3526 + * \returns the parsed `int`. 3063 3527 * 3064 3528 * \threadsafety It is safe to call this function from any thread. 3065 3529 * ··· 3082 3546 * NULL)`. 3083 3547 * 3084 3548 * \param str The null-terminated string to read. Must not be NULL. 3085 - * \returns The parsed `double`. 3549 + * \returns the parsed `double`. 3086 3550 * 3087 3551 * \threadsafety It is safe to call this function from any thread. 3088 3552 * ··· 3114 3578 * to 36 inclusive. If 0, the base will be inferred from the 3115 3579 * number's prefix (0x for hexadecimal, 0 for octal, decimal 3116 3580 * otherwise). 3117 - * \returns The parsed `long`, or 0 if no number could be parsed. 3581 + * \returns the parsed `long`, or 0 if no number could be parsed. 3118 3582 * 3119 3583 * \threadsafety It is safe to call this function from any thread. 3120 3584 * ··· 3148 3612 * to 36 inclusive. If 0, the base will be inferred from the 3149 3613 * number's prefix (0x for hexadecimal, 0 for octal, decimal 3150 3614 * otherwise). 3151 - * \returns The parsed `unsigned long`, or 0 if no number could be parsed. 3615 + * \returns the parsed `unsigned long`, or 0 if no number could be parsed. 3152 3616 * 3153 3617 * \threadsafety It is safe to call this function from any thread. 3154 3618 * ··· 3181 3645 * to 36 inclusive. If 0, the base will be inferred from the 3182 3646 * number's prefix (0x for hexadecimal, 0 for octal, decimal 3183 3647 * otherwise). 3184 - * \returns The parsed `long long`, or 0 if no number could be parsed. 3648 + * \returns the parsed `long long`, or 0 if no number could be parsed. 3185 3649 * 3186 3650 * \threadsafety It is safe to call this function from any thread. 3187 3651 * ··· 3214 3678 * to 36 inclusive. If 0, the base will be inferred from the 3215 3679 * number's prefix (0x for hexadecimal, 0 for octal, decimal 3216 3680 * otherwise). 3217 - * \returns The parsed `unsigned long long`, or 0 if no number could be 3681 + * \returns the parsed `unsigned long long`, or 0 if no number could be 3218 3682 * parsed. 3219 3683 * 3220 3684 * \threadsafety It is safe to call this function from any thread. ··· 3241 3705 * - Whether or not INF and NAN can be parsed is unspecified. 3242 3706 * - The precision of the result is unspecified. 3243 3707 * 3244 - * \param str The null-terminated string to read. Must not be NULL. 3245 - * \param endp If not NULL, the address of the first invalid character (i.e. 3708 + * \param str the null-terminated string to read. Must not be NULL. 3709 + * \param endp if not NULL, the address of the first invalid character (i.e. 3246 3710 * the next character after the parsed number) will be written to 3247 3711 * this pointer. 3248 - * \returns The parsed `double`, or 0 if no number could be parsed. 3712 + * \returns the parsed `double`, or 0 if no number could be parsed. 3249 3713 * 3250 3714 * \threadsafety It is safe to call this function from any thread. 3251 3715 * ··· 3516 3980 */ 3517 3981 extern SDL_DECLSPEC char * SDLCALL SDL_UCS4ToUTF8(Uint32 codepoint, char *dst); 3518 3982 3983 + /** 3984 + * This works exactly like sscanf() but doesn't require access to a C runtime. 3985 + * 3986 + * Scan a string, matching a format string, converting each '%' item and 3987 + * storing it to pointers provided through variable arguments. 3988 + * 3989 + * \param text the string to scan. Must not be NULL. 3990 + * \param fmt a printf-style format string. Must not be NULL. 3991 + * \param ... a list of pointers to values to be filled in with scanned items. 3992 + * \returns the number of items that matched the format string. 3993 + * 3994 + * \threadsafety It is safe to call this function from any thread. 3995 + * 3996 + * \since This function is available since SDL 3.1.3. 3997 + */ 3998 + extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); 3519 3999 3520 - extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); 4000 + /** 4001 + * This works exactly like vsscanf() but doesn't require access to a C runtime. 4002 + * 4003 + * Functions identically to SDL_sscanf(), except it takes a `va_list` 4004 + * instead of using `...` variable arguments. 4005 + * 4006 + * \param text the string to scan. Must not be NULL. 4007 + * \param fmt a printf-style format string. Must not be NULL. 4008 + * \param ap a `va_list` of pointers to values to be filled in with scanned items. 4009 + * \returns the number of items that matched the format string. 4010 + * 4011 + * \threadsafety It is safe to call this function from any thread. 4012 + * 4013 + * \since This function is available since SDL 3.1.3. 4014 + */ 3521 4015 extern SDL_DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2); 4016 + 4017 + /** 4018 + * This works exactly like snprintf() but doesn't require access to a C runtime. 4019 + * 4020 + * Format a string of up to `maxlen`-1 bytes, converting each '%' item with 4021 + * values provided through variable arguments. 4022 + * 4023 + * While some C runtimes differ on how to deal with too-large strings, 4024 + * this function null-terminates the output, by treating the null-terminator 4025 + * as part of the `maxlen` count. Note that if `maxlen` is zero, however, no 4026 + * bytes will be written at all. 4027 + * 4028 + * This function returns the number of _bytes_ (not _characters_) that should 4029 + * be written, excluding the null-terminator character. If this returns a 4030 + * number >= `maxlen`, it means the output string was truncated. A negative 4031 + * return value means an error occurred. 4032 + * 4033 + * Referencing the output string's pointer with a format item is undefined 4034 + * behavior. 4035 + * 4036 + * \param text the buffer to write the string into. Must not be NULL. 4037 + * \param maxlen the maximum bytes to write, including the null-terminator. 4038 + * \param fmt a printf-style format string. Must not be NULL. 4039 + * \param ... a list of values to be used with the format string. 4040 + * \returns the number of bytes that should be written, not counting the 4041 + * null-terminator char, or a negative value on error. 4042 + * 4043 + * \threadsafety It is safe to call this function from any thread. 4044 + * 4045 + * \since This function is available since SDL 3.1.3. 4046 + */ 3522 4047 extern SDL_DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); 4048 + 4049 + /** 4050 + * This works exactly like swprintf() but doesn't require access to a C runtime. 4051 + * 4052 + * Format a wide string of up to `maxlen`-1 wchar_t values, converting each '%' 4053 + * item with values provided through variable arguments. 4054 + * 4055 + * While some C runtimes differ on how to deal with too-large strings, 4056 + * this function null-terminates the output, by treating the null-terminator 4057 + * as part of the `maxlen` count. Note that if `maxlen` is zero, however, no 4058 + * wide characters will be written at all. 4059 + * 4060 + * This function returns the number of _wide characters_ (not _codepoints_) 4061 + * that should be written, excluding the null-terminator character. If this 4062 + * returns a number >= `maxlen`, it means the output string was truncated. A 4063 + * negative return value means an error occurred. 4064 + * 4065 + * Referencing the output string's pointer with a format item is undefined 4066 + * behavior. 4067 + * 4068 + * \param text the buffer to write the wide string into. Must not be NULL. 4069 + * \param maxlen the maximum wchar_t values to write, including the null-terminator. 4070 + * \param fmt a printf-style format string. Must not be NULL. 4071 + * \param ... a list of values to be used with the format string. 4072 + * \returns the number of wide characters that should be written, not counting 4073 + * the null-terminator char, or a negative value on error. 4074 + * 4075 + * \threadsafety It is safe to call this function from any thread. 4076 + * 4077 + * \since This function is available since SDL 3.1.3. 4078 + */ 3523 4079 extern SDL_DECLSPEC int SDLCALL SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(3); 4080 + 4081 + /** 4082 + * This works exactly like vsnprintf() but doesn't require access to a C runtime. 4083 + * 4084 + * Functions identically to SDL_snprintf(), except it takes a `va_list` 4085 + * instead of using `...` variable arguments. 4086 + * 4087 + * \param text the buffer to write the string into. Must not be NULL. 4088 + * \param maxlen the maximum bytes to write, including the null-terminator. 4089 + * \param fmt a printf-style format string. Must not be NULL. 4090 + * \param ap a `va_list` values to be used with the format string. 4091 + * \returns the number of bytes that should be written, not counting the 4092 + * null-terminator char, or a negative value on error. 4093 + * 4094 + * \threadsafety It is safe to call this function from any thread. 4095 + * 4096 + * \since This function is available since SDL 3.1.3. 4097 + */ 3524 4098 extern SDL_DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); 4099 + 4100 + /** 4101 + * This works exactly like vswprintf() but doesn't require access to a C runtime. 4102 + * 4103 + * Functions identically to SDL_swprintf(), except it takes a `va_list` 4104 + * instead of using `...` variable arguments. 4105 + * 4106 + * \param text the buffer to write the string into. Must not be NULL. 4107 + * \param maxlen the maximum wide characters to write, including the null-terminator. 4108 + * \param fmt a printf-style format wide string. Must not be NULL. 4109 + * \param ap a `va_list` values to be used with the format string. 4110 + * \returns the number of wide characters that should be written, not counting 4111 + * the null-terminator char, or a negative value on error. 4112 + * 4113 + * \threadsafety It is safe to call this function from any thread. 4114 + * 4115 + * \since This function is available since SDL 3.1.3. 4116 + */ 3525 4117 extern SDL_DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNCV(3); 4118 + 4119 + /** 4120 + * This works exactly like asprintf() but doesn't require access to a C runtime. 4121 + * 4122 + * Functions identically to SDL_snprintf(), except it allocates a buffer large 4123 + * enough to hold the output string on behalf of the caller. 4124 + * 4125 + * On success, this function returns the number of bytes (not characters) 4126 + * comprising the output string, not counting the null-terminator character, 4127 + * and sets `*strp` to the newly-allocated string. 4128 + * 4129 + * On error, this function returns a negative number, and the value of `*strp` 4130 + * is undefined. 4131 + * 4132 + * The returned string is owned by the caller, and should be passed to 4133 + * SDL_free when no longer needed. 4134 + * 4135 + * \param strp on output, is set to the new string. Must not be NULL. 4136 + * \param fmt a printf-style format string. Must not be NULL. 4137 + * \param ... a list of values to be used with the format string. 4138 + * \returns the number of bytes in the newly-allocated string, not counting 4139 + * the null-terminator char, or a negative value on error. 4140 + * 4141 + * \threadsafety It is safe to call this function from any thread. 4142 + * 4143 + * \since This function is available since SDL 3.1.3. 4144 + */ 3526 4145 extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 4146 + 4147 + /** 4148 + * This works exactly like vasprintf() but doesn't require access to a C runtime. 4149 + * 4150 + * Functions identically to SDL_asprintf(), except it takes a `va_list` 4151 + * instead of using `...` variable arguments. 4152 + * 4153 + * \param strp on output, is set to the new string. Must not be NULL. 4154 + * \param fmt a printf-style format string. Must not be NULL. 4155 + * \param ap a `va_list` values to be used with the format string. 4156 + * \returns the number of bytes in the newly-allocated string, not counting 4157 + * the null-terminator char, or a negative value on error. 4158 + * 4159 + * \threadsafety It is safe to call this function from any thread. 4160 + * 4161 + * \since This function is available since SDL 3.1.3. 4162 + */ 3527 4163 extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); 3528 4164 3529 4165 /**
+40 -1
include/SDL3/SDL_system.h
··· 129 129 * Platform specific functions for UNIX 130 130 */ 131 131 132 + /* this is defined in Xlib's headers, just need a simple declaration here. */ 132 133 typedef union _XEvent XEvent; 134 + 135 + /** 136 + * A callback to be used with SDL_SetX11EventHook. 137 + * 138 + * This callback may modify the event, and should return true if the event 139 + * should continue to be processed, or false to prevent further processing. 140 + * 141 + * As this is processing an event directly from the X11 event loop, this 142 + * callback should do the minimum required work and return quickly. 143 + * 144 + * \param userdata the app-defined pointer provided to SDL_SetX11EventHook. 145 + * \param xevent a pointer to an Xlib XEvent union to process. 146 + * \returns true to let event continue on, false to drop it. 147 + * 148 + * \threadsafety This may only be called (by SDL) from the thread handling the 149 + * X11 event loop. 150 + * 151 + * \since This datatype is available since SDL 3.1.3. 152 + * 153 + * \sa SDL_SetX11EventHook 154 + */ 133 155 typedef bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent); 134 156 135 157 /** ··· 380 402 * \since This macro is available since SDL 3.1.3. 381 403 */ 382 404 #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 405 + 406 + /** 407 + * See the official Android developer guide for more information: 408 + * http://developer.android.com/guide/topics/data/data-storage.html 409 + * 410 + * \since This macro is available since SDL 3.1.3. 411 + */ 383 412 #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 384 413 385 414 /** ··· 468 497 */ 469 498 extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void); 470 499 471 - 500 + /** 501 + * Callback that presents a response from a SDL_RequestAndroidPermission call. 502 + * 503 + * \param userdata an app-controlled pointer that is passed to the callback. 504 + * \param permission the Android-specific permission name that was requested. 505 + * \param granted true if permission is granted, false if denied. 506 + * 507 + * \since This datatype is available since SDL 3.1.3. 508 + * 509 + * \sa SDL_RequestAndroidPermission 510 + */ 472 511 typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, bool granted); 473 512 474 513 /**
+98 -6
include/SDL3/SDL_video.h
··· 112 112 SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */ 113 113 } SDL_SystemTheme; 114 114 115 - /* Internal display mode data */ 115 + /** 116 + * Internal display mode data. 117 + * 118 + * This lives as a field in SDL_DisplayMode, as opaque data. 119 + * 120 + * \since This struct is available since SDL 3.1.3. 121 + * 122 + * \sa SDL_DisplayMode 123 + */ 116 124 typedef struct SDL_DisplayModeData SDL_DisplayModeData; 117 125 118 126 /** ··· 206 214 207 215 208 216 /** 217 + * A magic value used with SDL_WINDOWPOS_UNDEFINED. 218 + * 219 + * Generally this macro isn't used directly, but rather through 220 + * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY. 221 + * 222 + * \since This macro is available since SDL 3.1.3. 223 + */ 224 + #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u 225 + 226 + /** 209 227 * Used to indicate that you don't care what the window position is. 210 228 * 229 + * If you _really_ don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always 230 + * uses the primary display instead of specifying one. 231 + * 232 + * \param X the SDL_DisplayID of the display to use. 233 + * 211 234 * \since This macro is available since SDL 3.1.3. 212 235 */ 213 - #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u 214 236 #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) 237 + 238 + /** 239 + * Used to indicate that you don't care what the window position/display is. 240 + * 241 + * This always uses the primary display. 242 + * 243 + * \since This macro is available since SDL 3.1.3. 244 + */ 215 245 #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) 216 - #define SDL_WINDOWPOS_ISUNDEFINED(X) \ 217 - (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) 246 + 247 + /** 248 + * A macro to test if the window position is marked as "undefined." 249 + * 250 + * \param X the window position value. 251 + * 252 + * \since This macro is available since SDL 3.1.3. 253 + */ 254 + #define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) 218 255 219 256 /** 220 - * Used to indicate that the window position should be centered. 257 + * A magic value used with SDL_WINDOWPOS_CENTERED. 258 + * 259 + * Generally this macro isn't used directly, but rather through 260 + * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY. 221 261 * 222 262 * \since This macro is available since SDL 3.1.3. 223 263 */ 224 264 #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u 265 + 266 + /** 267 + * Used to indicate that the window position should be centered. 268 + * 269 + * SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display 270 + * instead of specifying one. 271 + * 272 + * \param X the SDL_DisplayID of the display to use. 273 + * 274 + * \since This macro is available since SDL 3.1.3. 275 + */ 225 276 #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) 277 + 278 + /** 279 + * Used to indicate that the window position should be centered. 280 + * 281 + * This always uses the primary display. 282 + * 283 + * \since This macro is available since SDL 3.1.3. 284 + */ 226 285 #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) 286 + 287 + /** 288 + * A macro to test if the window position is marked as "centered." 289 + * 290 + * \param X the window position value. 291 + * 292 + * \since This macro is available since SDL 3.1.3. 293 + */ 227 294 #define SDL_WINDOWPOS_ISCENTERED(X) \ 228 295 (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) 296 + 229 297 230 298 /** 231 299 * Window flash operation. ··· 249 317 typedef struct SDL_GLContextState *SDL_GLContext; 250 318 251 319 /** 252 - * Opaque EGL types. 320 + * Opaque type for an EGL display. 253 321 * 254 322 * \since This datatype is available since SDL 3.1.3. 255 323 */ 256 324 typedef void *SDL_EGLDisplay; 325 + 326 + /** 327 + * Opaque type for an EGL config. 328 + * 329 + * \since This datatype is available since SDL 3.1.3. 330 + */ 257 331 typedef void *SDL_EGLConfig; 332 + 333 + /** 334 + * Opaque type for an EGL surface. 335 + * 336 + * \since This datatype is available since SDL 3.1.3. 337 + */ 258 338 typedef void *SDL_EGLSurface; 339 + 340 + /** 341 + * An EGL attribute, used when creating an EGL context. 342 + * 343 + * \since This datatype is available since SDL 3.1.3. 344 + */ 259 345 typedef intptr_t SDL_EGLAttrib; 346 + 347 + /** 348 + * An EGL integer attribute, used when creating an EGL surface. 349 + * 350 + * \since This datatype is available since SDL 3.1.3. 351 + */ 260 352 typedef int SDL_EGLint; 261 353 262 354 /**