SDL_init.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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/SDL_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. * Initialization flags for SDL_Init and/or SDL_InitSubSystem
  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. * \sa SDL_Init
  39. * \sa SDL_Quit
  40. * \sa SDL_InitSubSystem
  41. * \sa SDL_QuitSubSystem
  42. * \sa SDL_WasInit
  43. */
  44. typedef enum
  45. {
  46. SDL_INIT_TIMER = 0x00000001,
  47. SDL_INIT_AUDIO = 0x00000010,
  48. SDL_INIT_VIDEO = 0x00000020, /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` */
  49. SDL_INIT_JOYSTICK = 0x00000200, /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */
  50. SDL_INIT_HAPTIC = 0x00001000,
  51. SDL_INIT_GAMEPAD = 0x00002000, /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
  52. SDL_INIT_EVENTS = 0x00004000,
  53. SDL_INIT_SENSOR = 0x00008000
  54. } SDL_InitFlags;
  55. /**
  56. * Initialize the SDL library.
  57. *
  58. * SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
  59. * two may be used interchangeably. Though for readability of your code
  60. * SDL_InitSubSystem() might be preferred.
  61. *
  62. * The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
  63. * subsystems are initialized by default. Message boxes
  64. * (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
  65. * video subsystem, in hopes of being useful in showing an error dialog when
  66. * SDL_Init fails. You must specifically initialize other subsystems if you
  67. * use them in your application.
  68. *
  69. * Logging (such as SDL_Log) works without initialization, too.
  70. *
  71. * `flags` may be any of the following OR'd together:
  72. *
  73. * - `SDL_INIT_TIMER`: timer subsystem
  74. * - `SDL_INIT_AUDIO`: audio subsystem
  75. * - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
  76. * subsystem
  77. * - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
  78. * events subsystem
  79. * - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
  80. * - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
  81. * joystick subsystem
  82. * - `SDL_INIT_EVENTS`: events subsystem
  83. * - `SDL_INIT_SENSOR`: sensor subsystem
  84. *
  85. * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
  86. * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
  87. * call SDL_Quit() to force shutdown). If a subsystem is already loaded then
  88. * this call will increase the ref-count and return.
  89. *
  90. * \param flags subsystem initialization flags
  91. * \returns 0 on success or a negative error code on failure; call
  92. * SDL_GetError() for more information.
  93. *
  94. * \since This function is available since SDL 3.0.0.
  95. *
  96. * \sa SDL_InitSubSystem
  97. * \sa SDL_Quit
  98. * \sa SDL_SetMainReady
  99. * \sa SDL_WasInit
  100. */
  101. extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
  102. /**
  103. * Compatibility function to initialize the SDL library.
  104. *
  105. * This function and SDL_Init() are interchangeable.
  106. *
  107. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  108. * \returns 0 on success or a negative error code on failure; call
  109. * SDL_GetError() for more information.
  110. *
  111. * \since This function is available since SDL 3.0.0.
  112. *
  113. * \sa SDL_Init
  114. * \sa SDL_Quit
  115. * \sa SDL_QuitSubSystem
  116. */
  117. extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
  118. /**
  119. * Shut down specific SDL subsystems.
  120. *
  121. * You still need to call SDL_Quit() even if you close all open subsystems
  122. * with SDL_QuitSubSystem().
  123. *
  124. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  125. *
  126. * \since This function is available since SDL 3.0.0.
  127. *
  128. * \sa SDL_InitSubSystem
  129. * \sa SDL_Quit
  130. */
  131. extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
  132. /**
  133. * Get a mask of the specified subsystems which are currently initialized.
  134. *
  135. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
  136. * \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
  137. * returns the initialization status of the specified subsystems.
  138. *
  139. * \since This function is available since SDL 3.0.0.
  140. *
  141. * \sa SDL_Init
  142. * \sa SDL_InitSubSystem
  143. */
  144. extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
  145. /**
  146. * Clean up all initialized subsystems.
  147. *
  148. * You should call this function even if you have already shutdown each
  149. * initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
  150. * function even in the case of errors in initialization.
  151. *
  152. * You can use this function with atexit() to ensure that it is run when your
  153. * application is shutdown, but it is not wise to do this from a library or
  154. * other dynamically loaded code.
  155. *
  156. * \since This function is available since SDL 3.0.0.
  157. *
  158. * \sa SDL_Init
  159. * \sa SDL_QuitSubSystem
  160. */
  161. extern DECLSPEC void SDLCALL SDL_Quit(void);
  162. /* Ends C function definitions when using C++ */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #include <SDL3/SDL_close_code.h>
  167. #endif /* SDL_init_h_ */