🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
8.6 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
  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. #ifndef SDL_main_h_
  19. #define SDL_main_h_
  20. #include "SDL_stdinc.h"
  21. /**
  22. * \file SDL_main.h
  23. *
  24. * Redefine main() on some platforms so that it is called by SDL.
  25. */
  26. #ifndef SDL_MAIN_HANDLED
  27. #if defined(__WIN32__)
  28. /* On Windows SDL provides WinMain(), which parses the command line and passes
  29. the arguments to your main function.
  30. If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
  31. */
  32. #define SDL_MAIN_AVAILABLE
  33. #elif defined(__WINRT__)
  34. /* On WinRT, SDL provides a main function that initializes CoreApplication,
  35. creating an instance of IFrameworkView in the process.
  36. Please note that #include'ing SDL_main.h is not enough to get a main()
  37. function working. In non-XAML apps, the file,
  38. src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled
  39. into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be
  40. called, with a pointer to the Direct3D-hosted XAML control passed in.
  41. */
  42. #define SDL_MAIN_NEEDED
  43. #elif defined(__GDK__)
  44. /* On GDK, SDL provides a main function that initializes the game runtime.
  45. Please note that #include'ing SDL_main.h is not enough to get a main()
  46. function working. You must either link against SDL2main or, if not possible,
  47. call the SDL_GDKRunApp function from your entry point.
  48. */
  49. #define SDL_MAIN_NEEDED
  50. #elif defined(__IPHONEOS__)
  51. /* On iOS SDL provides a main function that creates an application delegate
  52. and starts the iOS application run loop.
  53. If you link with SDL dynamically on iOS, the main function can't be in a
  54. shared library, so you need to link with libSDLmain.a, which includes a
  55. stub main function that calls into the shared library to start execution.
  56. See src/video/uikit/SDL_uikitappdelegate.m for more details.
  57. */
  58. #define SDL_MAIN_NEEDED
  59. #elif defined(__ANDROID__)
  60. /* On Android SDL provides a Java class in SDLActivity.java that is the
  61. main activity entry point.
  62. See docs/README-android.md for more details on extending that class.
  63. */
  64. #define SDL_MAIN_NEEDED
  65. /* We need to export SDL_main so it can be launched from Java */
  66. #define SDLMAIN_DECLSPEC DECLSPEC
  67. #elif defined(__NACL__)
  68. /* On NACL we use ppapi_simple to set up the application helper code,
  69. then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before
  70. starting the user main function.
  71. All user code is run in a separate thread by ppapi_simple, thus
  72. allowing for blocking io to take place via nacl_io
  73. */
  74. #define SDL_MAIN_NEEDED
  75. #elif defined(__PSP__)
  76. /* On PSP SDL provides a main function that sets the module info,
  77. activates the GPU and starts the thread required to be able to exit
  78. the software.
  79. If you provide this yourself, you may define SDL_MAIN_HANDLED
  80. */
  81. #define SDL_MAIN_AVAILABLE
  82. #elif defined(__PS2__)
  83. #define SDL_MAIN_AVAILABLE
  84. #define SDL_PS2_SKIP_IOP_RESET() \
  85. void reset_IOP(); \
  86. void reset_IOP() {}
  87. #elif defined(__3DS__)
  88. /*
  89. On N3DS, SDL provides a main function that sets up the screens
  90. and storage.
  91. If you provide this yourself, you may define SDL_MAIN_HANDLED
  92. */
  93. #define SDL_MAIN_AVAILABLE
  94. #endif
  95. #endif /* SDL_MAIN_HANDLED */
  96. #ifndef SDLMAIN_DECLSPEC
  97. #define SDLMAIN_DECLSPEC
  98. #endif
  99. /**
  100. * \file SDL_main.h
  101. *
  102. * The application's main() function must be called with C linkage,
  103. * and should be declared like this:
  104. * \code
  105. * #ifdef __cplusplus
  106. * extern "C"
  107. * #endif
  108. * int main(int argc, char *argv[])
  109. * {
  110. * }
  111. * \endcode
  112. */
  113. #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
  114. #define main SDL_main
  115. #endif
  116. #include "begin_code.h"
  117. #ifdef __cplusplus
  118. extern "C" {
  119. #endif
  120. /**
  121. * The prototype for the application's main() function
  122. */
  123. typedef int (*SDL_main_func)(int argc, char *argv[]);
  124. extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
  125. /**
  126. * Circumvent failure of SDL_Init() when not using SDL_main() as an entry
  127. * point.
  128. *
  129. * This function is defined in SDL_main.h, along with the preprocessor rule to
  130. * redefine main() as SDL_main(). Thus to ensure that your main() function
  131. * will not be changed it is necessary to define SDL_MAIN_HANDLED before
  132. * including SDL.h.
  133. *
  134. * \since This function is available since SDL 2.0.0.
  135. *
  136. * \sa SDL_Init
  137. */
  138. extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
  139. #if defined(__WIN32__) || defined(__GDK__)
  140. /**
  141. * Register a win32 window class for SDL's use.
  142. *
  143. * This can be called to set the application window class at startup. It is
  144. * safe to call this multiple times, as long as every call is eventually
  145. * paired with a call to SDL_UnregisterApp, but a second registration attempt
  146. * while a previous registration is still active will be ignored, other than
  147. * to increment a counter.
  148. *
  149. * Most applications do not need to, and should not, call this directly; SDL
  150. * will call it when initializing the video subsystem.
  151. *
  152. * \param name the window class name, in UTF-8 encoding. If NULL, SDL
  153. * currently uses "SDL_app" but this isn't guaranteed.
  154. * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
  155. * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
  156. * what is specified here.
  157. * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
  158. * will use `GetModuleHandle(NULL)` instead.
  159. * \returns 0 on success, -1 on error. SDL_GetError() may have details.
  160. *
  161. * \since This function is available since SDL 2.0.2.
  162. */
  163. extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
  164. /**
  165. * Deregister the win32 window class from an SDL_RegisterApp call.
  166. *
  167. * This can be called to undo the effects of SDL_RegisterApp.
  168. *
  169. * Most applications do not need to, and should not, call this directly; SDL
  170. * will call it when deinitializing the video subsystem.
  171. *
  172. * It is safe to call this multiple times, as long as every call is eventually
  173. * paired with a prior call to SDL_RegisterApp. The window class will only be
  174. * deregistered when the registration counter in SDL_RegisterApp decrements to
  175. * zero through calls to this function.
  176. *
  177. * \since This function is available since SDL 2.0.2.
  178. */
  179. extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  180. #endif /* defined(__WIN32__) || defined(__GDK__) */
  181. #ifdef __WINRT__
  182. /**
  183. * Initialize and launch an SDL/WinRT application.
  184. *
  185. * \param mainFunction the SDL app's C-style main(), an SDL_main_func
  186. * \param reserved reserved for future use; should be NULL
  187. * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
  188. * more information on the failure.
  189. *
  190. * \since This function is available since SDL 2.0.3.
  191. */
  192. extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved);
  193. #endif /* __WINRT__ */
  194. #if defined(__IPHONEOS__)
  195. /**
  196. * Initializes and launches an SDL application.
  197. *
  198. * \param argc The argc parameter from the application's main() function
  199. * \param argv The argv parameter from the application's main() function
  200. * \param mainFunction The SDL app's C-style main(), an SDL_main_func
  201. * \return the return value from mainFunction
  202. *
  203. * \since This function is available since SDL 2.0.10.
  204. */
  205. extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction);
  206. #endif /* __IPHONEOS__ */
  207. #ifdef __GDK__
  208. /**
  209. * Initialize and launch an SDL GDK application.
  210. *
  211. * \param mainFunction the SDL app's C-style main(), an SDL_main_func
  212. * \param reserved reserved for future use; should be NULL
  213. * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
  214. * more information on the failure.
  215. *
  216. * \since This function is available since SDL 2.24.0.
  217. */
  218. extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved);
  219. #endif /* __GDK__ */
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223. #include "close_code.h"
  224. #endif /* SDL_main_h_ */
  225. /* vi: set ts=4 sw=4 expandtab: */