🛠️🐜 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.

235 lines
7.4 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(__IPHONEOS__)
  44. /* On iOS SDL provides a main function that creates an application delegate
  45. and starts the iOS application run loop.
  46. If you link with SDL dynamically on iOS, the main function can't be in a
  47. shared library, so you need to link with libSDLmain.a, which includes a
  48. stub main function that calls into the shared library to start execution.
  49. See src/video/uikit/SDL_uikitappdelegate.m for more details.
  50. */
  51. #define SDL_MAIN_NEEDED
  52. #elif defined(__ANDROID__)
  53. /* On Android SDL provides a Java class in SDLActivity.java that is the
  54. main activity entry point.
  55. See docs/README-android.md for more details on extending that class.
  56. */
  57. #define SDL_MAIN_NEEDED
  58. /* We need to export SDL_main so it can be launched from Java */
  59. #define SDLMAIN_DECLSPEC DECLSPEC
  60. #elif defined(__NACL__)
  61. /* On NACL we use ppapi_simple to set up the application helper code,
  62. then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before
  63. starting the user main function.
  64. All user code is run in a separate thread by ppapi_simple, thus
  65. allowing for blocking io to take place via nacl_io
  66. */
  67. #define SDL_MAIN_NEEDED
  68. #elif defined(__PSP__)
  69. /* On PSP SDL provides a main function that sets the module info,
  70. activates the GPU and starts the thread required to be able to exit
  71. the software.
  72. If you provide this yourself, you may define SDL_MAIN_HANDLED
  73. */
  74. #define SDL_MAIN_AVAILABLE
  75. #endif
  76. #endif /* SDL_MAIN_HANDLED */
  77. #ifndef SDLMAIN_DECLSPEC
  78. #define SDLMAIN_DECLSPEC
  79. #endif
  80. /**
  81. * \file SDL_main.h
  82. *
  83. * The application's main() function must be called with C linkage,
  84. * and should be declared like this:
  85. * \code
  86. * #ifdef __cplusplus
  87. * extern "C"
  88. * #endif
  89. * int main(int argc, char *argv[])
  90. * {
  91. * }
  92. * \endcode
  93. */
  94. #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
  95. #define main SDL_main
  96. #endif
  97. #include "begin_code.h"
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif
  101. /**
  102. * The prototype for the application's main() function
  103. */
  104. typedef int (*SDL_main_func)(int argc, char *argv[]);
  105. extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
  106. /**
  107. * Circumvent failure of SDL_Init() when not using SDL_main() as an entry
  108. * point.
  109. *
  110. * This function is defined in SDL_main.h, along with the preprocessor rule to
  111. * redefine main() as SDL_main(). Thus to ensure that your main() function
  112. * will not be changed it is necessary to define SDL_MAIN_HANDLED before
  113. * including SDL.h.
  114. *
  115. * \since This function is available since SDL 2.0.0.
  116. *
  117. * \sa SDL_Init
  118. */
  119. extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
  120. #ifdef __WIN32__
  121. /**
  122. * Register a win32 window class for SDL's use.
  123. *
  124. * This can be called to set the application window class at startup. It is
  125. * safe to call this multiple times, as long as every call is eventually
  126. * paired with a call to SDL_UnregisterApp, but a second registration attempt
  127. * while a previous registration is still active will be ignored, other than
  128. * to increment a counter.
  129. *
  130. * Most applications do not need to, and should not, call this directly; SDL
  131. * will call it when initializing the video subsystem.
  132. *
  133. * \param name the window class name, in UTF-8 encoding. If NULL, SDL
  134. * currently uses "SDL_app" but this isn't guaranteed.
  135. * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
  136. * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
  137. * what is specified here.
  138. * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
  139. * will use `GetModuleHandle(NULL)` instead.
  140. * \returns 0 on success, -1 on error. SDL_GetError() may have details.
  141. *
  142. * \since This function is available since SDL 2.0.2.
  143. */
  144. extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
  145. /**
  146. * Deregister the win32 window class from an SDL_RegisterApp call.
  147. *
  148. * This can be called to undo the effects of SDL_RegisterApp.
  149. *
  150. * Most applications do not need to, and should not, call this directly; SDL
  151. * will call it when deinitializing the video subsystem.
  152. *
  153. * It is safe to call this multiple times, as long as every call is eventually
  154. * paired with a prior call to SDL_RegisterApp. The window class will only be
  155. * deregistered when the registration counter in SDL_RegisterApp decrements to
  156. * zero through calls to this function.
  157. *
  158. * \since This function is available since SDL 2.0.2.
  159. */
  160. extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  161. #endif /* __WIN32__ */
  162. #ifdef __WINRT__
  163. /**
  164. * Initialize and launch an SDL/WinRT application.
  165. *
  166. * \param mainFunction the SDL app's C-style main(), an SDL_main_func
  167. * \param reserved reserved for future use; should be NULL
  168. * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
  169. * more information on the failure.
  170. *
  171. * \since This function is available since SDL 2.0.3.
  172. */
  173. extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved);
  174. #endif /* __WINRT__ */
  175. #if defined(__IPHONEOS__)
  176. /**
  177. * Initializes and launches an SDL application.
  178. *
  179. * \param argc The argc parameter from the application's main() function
  180. * \param argv The argv parameter from the application's main() function
  181. * \param mainFunction The SDL app's C-style main(), an SDL_main_func
  182. * \return the return value from mainFunction
  183. *
  184. * \since This function is available since SDL 2.0.10.
  185. */
  186. extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction);
  187. #endif /* __IPHONEOS__ */
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #include "close_code.h"
  192. #endif /* SDL_main_h_ */
  193. /* vi: set ts=4 sw=4 expandtab: */