diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h')
| -rw-r--r-- | contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h b/contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h new file mode 100644 index 0000000..14ebb42 --- /dev/null +++ b/contrib/SDL-3.2.8/include/SDL3/SDL_main_impl.h | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* WIKI CATEGORY: Main */ | ||
| 23 | |||
| 24 | #ifndef SDL_main_impl_h_ | ||
| 25 | #define SDL_main_impl_h_ | ||
| 26 | |||
| 27 | #ifndef SDL_main_h_ | ||
| 28 | #error "This header should not be included directly, but only via SDL_main.h!" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | /* if someone wants to include SDL_main.h but doesn't want the main handing magic, | ||
| 32 | (maybe to call SDL_RegisterApp()) they can #define SDL_MAIN_HANDLED first. | ||
| 33 | SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation, | ||
| 34 | not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) and if the user wants | ||
| 35 | to have the SDL_main implementation (from this header) in another source file | ||
| 36 | than their main() function, for example if SDL_main requires C++ | ||
| 37 | and main() is implemented in plain C */ | ||
| 38 | #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) | ||
| 39 | |||
| 40 | /* the implementations below must be able to use the implement real main(), nothing renamed | ||
| 41 | (the user's main() will be renamed to SDL_main so it can be called from here) */ | ||
| 42 | #ifdef main | ||
| 43 | #undef main | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifdef SDL_MAIN_USE_CALLBACKS | ||
| 47 | |||
| 48 | #if 0 | ||
| 49 | /* currently there are no platforms that _need_ a magic entry point here | ||
| 50 | for callbacks, but if one shows up, implement it here. */ | ||
| 51 | |||
| 52 | #else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */ | ||
| 53 | |||
| 54 | /* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */ | ||
| 55 | #define SDL_MAIN_CALLBACK_STANDARD 1 | ||
| 56 | |||
| 57 | int SDL_main(int argc, char **argv) | ||
| 58 | { | ||
| 59 | return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit); | ||
| 60 | } | ||
| 61 | |||
| 62 | #endif /* platform-specific tests */ | ||
| 63 | |||
| 64 | #endif /* SDL_MAIN_USE_CALLBACKS */ | ||
| 65 | |||
| 66 | |||
| 67 | /* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point, | ||
| 68 | unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */ | ||
| 69 | #if (!defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)) && !defined(SDL_MAIN_EXPORTED) | ||
| 70 | |||
| 71 | #if defined(SDL_PLATFORM_PRIVATE_MAIN) | ||
| 72 | /* Private platforms may have their own ideas about entry points. */ | ||
| 73 | #include "SDL_main_impl_private.h" | ||
| 74 | |||
| 75 | #elif defined(SDL_PLATFORM_WINDOWS) | ||
| 76 | |||
| 77 | /* these defines/typedefs are needed for the WinMain() definition */ | ||
| 78 | #ifndef WINAPI | ||
| 79 | #define WINAPI __stdcall | ||
| 80 | #endif | ||
| 81 | |||
| 82 | typedef struct HINSTANCE__ * HINSTANCE; | ||
| 83 | typedef char *LPSTR; | ||
| 84 | typedef wchar_t *PWSTR; | ||
| 85 | |||
| 86 | /* The VC++ compiler needs main/wmain defined, but not for GDK */ | ||
| 87 | #if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK) | ||
| 88 | |||
| 89 | /* This is where execution begins [console apps] */ | ||
| 90 | #if defined(UNICODE) && UNICODE | ||
| 91 | int wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) | ||
| 92 | { | ||
| 93 | (void)argc; | ||
| 94 | (void)wargv; | ||
| 95 | (void)wenvp; | ||
| 96 | return SDL_RunApp(0, NULL, SDL_main, NULL); | ||
| 97 | } | ||
| 98 | #else /* ANSI */ | ||
| 99 | int main(int argc, char *argv[]) | ||
| 100 | { | ||
| 101 | (void)argc; | ||
| 102 | (void)argv; | ||
| 103 | return SDL_RunApp(0, NULL, SDL_main, NULL); | ||
| 104 | } | ||
| 105 | #endif /* UNICODE */ | ||
| 106 | |||
| 107 | #endif /* _MSC_VER && ! SDL_PLATFORM_GDK */ | ||
| 108 | |||
| 109 | /* This is where execution begins [windowed apps and GDK] */ | ||
| 110 | |||
| 111 | #ifdef __cplusplus | ||
| 112 | extern "C" { | ||
| 113 | #endif | ||
| 114 | |||
| 115 | #if defined(UNICODE) && UNICODE | ||
| 116 | int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw) | ||
| 117 | #else /* ANSI */ | ||
| 118 | int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) | ||
| 119 | #endif | ||
| 120 | { | ||
| 121 | (void)hInst; | ||
| 122 | (void)hPrev; | ||
| 123 | (void)szCmdLine; | ||
| 124 | (void)sw; | ||
| 125 | return SDL_RunApp(0, NULL, SDL_main, NULL); | ||
| 126 | } | ||
| 127 | |||
| 128 | #ifdef __cplusplus | ||
| 129 | } /* extern "C" */ | ||
| 130 | #endif | ||
| 131 | |||
| 132 | /* end of SDL_PLATFORM_WINDOWS impls */ | ||
| 133 | |||
| 134 | #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ | ||
| 135 | int main(int argc, char *argv[]) | ||
| 136 | { | ||
| 137 | return SDL_RunApp(argc, argv, SDL_main, NULL); | ||
| 138 | } | ||
| 139 | |||
| 140 | /* end of impls for standard-conforming platforms */ | ||
| 141 | |||
| 142 | #endif /* SDL_PLATFORM_WIN32 etc */ | ||
| 143 | |||
| 144 | #endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */ | ||
| 145 | |||
| 146 | /* rename users main() function to SDL_main() so it can be called from the wrappers above */ | ||
| 147 | #define main SDL_main | ||
| 148 | |||
| 149 | #endif /* SDL_MAIN_HANDLED */ | ||
| 150 | |||
| 151 | #endif /* SDL_main_impl_h_ */ | ||
