SDL_init.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_init.h
  20. *
  21. * Init and quit header for the SDL library
  22. */
  23. #ifndef SDL_init_h_
  24. #define SDL_init_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/begin_code.h>
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* As of version 0.5, SDL is loaded dynamically into the application */
  32. /**
  33. * \name SDL_INIT_*
  34. *
  35. * These are the flags which may be passed to SDL_Init(). You should
  36. * specify the subsystems which you will be using in your application.
  37. */
  38. /* @{ */
  39. #define SDL_INIT_TIMER 0x00000001u
  40. #define SDL_INIT_AUDIO 0x00000010u
  41. #define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
  42. #define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
  43. #define SDL_INIT_HAPTIC 0x00001000u
  44. #define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
  45. #define SDL_INIT_EVENTS 0x00004000u
  46. #define SDL_INIT_SENSOR 0x00008000u
  47. #define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
  48. #define SDL_INIT_EVERYTHING ( \
  49. SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
  50. SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
  51. )
  52. /* @} */
  53. /**
  54. * Initialize the SDL library.
  55. *
  56. * SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
  57. * two may be used interchangeably. Though for readability of your code
  58. * SDL_InitSubSystem() might be preferred.
  59. *
  60. * The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
  61. * subsystems are initialized by default. Message boxes
  62. * (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
  63. * video subsystem, in hopes of being useful in showing an error dialog when
  64. * SDL_Init fails. You must specifically initialize other subsystems if you
  65. * use them in your application.
  66. *
  67. * Logging (such as SDL_Log) works without initialization, too.
  68. *
  69. * `flags` may be any of the following OR'd together:
  70. *
  71. * - `SDL_INIT_TIMER`: timer subsystem
  72. * - `SDL_INIT_AUDIO`: audio subsystem
  73. * - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
  74. * subsystem
  75. * - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
  76. * events subsystem
  77. * - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
  78. * - `SDL_INIT_GAMECONTROLLER`: controller subsystem; automatically
  79. * initializes the joystick subsystem
  80. * - `SDL_INIT_EVENTS`: events subsystem
  81. * - `SDL_INIT_EVERYTHING`: all of the above subsystems
  82. * - `SDL_INIT_NOPARACHUTE`: compatibility; this flag is ignored
  83. *
  84. * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
  85. * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
  86. * call SDL_Quit() to force shutdown). If a subsystem is already loaded then
  87. * this call will increase the ref-count and return.
  88. *
  89. * \param flags subsystem initialization flags
  90. * \returns 0 on success or a negative error code on failure; call
  91. * SDL_GetError() for more information.
  92. *
  93. * \since This function is available since SDL 3.0.0.
  94. *
  95. * \sa SDL_InitSubSystem
  96. * \sa SDL_Quit
  97. * \sa SDL_SetMainReady
  98. * \sa SDL_WasInit
  99. */
  100. extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
  101. /**
  102. * Compatibility function to initialize the SDL library.
  103. *
  104. * This function and SDL_Init() are interchangeable.
  105. *
  106. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  107. * \returns 0 on success or a negative error code on failure; call
  108. * SDL_GetError() for more information.
  109. *
  110. * \since This function is available since SDL 3.0.0.
  111. *
  112. * \sa SDL_Init
  113. * \sa SDL_Quit
  114. * \sa SDL_QuitSubSystem
  115. */
  116. extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
  117. /**
  118. * Shut down specific SDL subsystems.
  119. *
  120. * If you start a subsystem using a call to that subsystem's init function
  121. * (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
  122. * SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use
  123. * that subsystem's quit function (SDL_VideoQuit()) directly instead. But
  124. * generally, you should not be using those functions directly anyhow; use
  125. * SDL_Init() instead.
  126. *
  127. * You still need to call SDL_Quit() even if you close all open subsystems
  128. * with SDL_QuitSubSystem().
  129. *
  130. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  131. *
  132. * \since This function is available since SDL 3.0.0.
  133. *
  134. * \sa SDL_InitSubSystem
  135. * \sa SDL_Quit
  136. */
  137. extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
  138. /**
  139. * Get a mask of the specified subsystems which are currently initialized.
  140. *
  141. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  142. * \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
  143. * returns the initialization status of the specified subsystems.
  144. *
  145. * The return value does not include SDL_INIT_NOPARACHUTE.
  146. *
  147. * \since This function is available since SDL 3.0.0.
  148. *
  149. * \sa SDL_Init
  150. * \sa SDL_InitSubSystem
  151. */
  152. extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
  153. /**
  154. * Clean up all initialized subsystems.
  155. *
  156. * You should call this function even if you have already shutdown each
  157. * initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
  158. * function even in the case of errors in initialization.
  159. *
  160. * If you start a subsystem using a call to that subsystem's init function
  161. * (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
  162. * then you must use that subsystem's quit function (SDL_VideoQuit()) to shut
  163. * it down before calling SDL_Quit(). But generally, you should not be using
  164. * those functions directly anyhow; use SDL_Init() instead.
  165. *
  166. * You can use this function with atexit() to ensure that it is run when your
  167. * application is shutdown, but it is not wise to do this from a library or
  168. * other dynamically loaded code.
  169. *
  170. * \since This function is available since SDL 3.0.0.
  171. *
  172. * \sa SDL_Init
  173. * \sa SDL_QuitSubSystem
  174. */
  175. extern DECLSPEC void SDLCALL SDL_Quit(void);
  176. /* Ends C function definitions when using C++ */
  177. #ifdef __cplusplus
  178. }
  179. #endif
  180. #include <SDL3/close_code.h>
  181. #endif /* SDL_init_h_ */
  182. /* vi: set ts=4 sw=4 expandtab: */