SDL Library
SDL_main.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | #ifndef _SDL_main_h |
miruga27 | 0:7fb6877b5d7c | 23 | #define _SDL_main_h |
miruga27 | 0:7fb6877b5d7c | 24 | |
miruga27 | 0:7fb6877b5d7c | 25 | #include "SDL_stdinc.h" |
miruga27 | 0:7fb6877b5d7c | 26 | |
miruga27 | 0:7fb6877b5d7c | 27 | /** |
miruga27 | 0:7fb6877b5d7c | 28 | * \file SDL_main.h |
miruga27 | 0:7fb6877b5d7c | 29 | * |
miruga27 | 0:7fb6877b5d7c | 30 | * Redefine main() on some platforms so that it is called by SDL. |
miruga27 | 0:7fb6877b5d7c | 31 | */ |
miruga27 | 0:7fb6877b5d7c | 32 | |
miruga27 | 0:7fb6877b5d7c | 33 | #ifndef SDL_MAIN_HANDLED |
miruga27 | 0:7fb6877b5d7c | 34 | #if defined(__WIN32__) |
miruga27 | 0:7fb6877b5d7c | 35 | /* On Windows SDL provides WinMain(), which parses the command line and passes |
miruga27 | 0:7fb6877b5d7c | 36 | the arguments to your main function. |
miruga27 | 0:7fb6877b5d7c | 37 | |
miruga27 | 0:7fb6877b5d7c | 38 | If you provide your own WinMain(), you may define SDL_MAIN_HANDLED |
miruga27 | 0:7fb6877b5d7c | 39 | */ |
miruga27 | 0:7fb6877b5d7c | 40 | #define SDL_MAIN_AVAILABLE |
miruga27 | 0:7fb6877b5d7c | 41 | |
miruga27 | 0:7fb6877b5d7c | 42 | #elif defined(__IPHONEOS__) |
miruga27 | 0:7fb6877b5d7c | 43 | /* On iOS SDL provides a main function that creates an application delegate |
miruga27 | 0:7fb6877b5d7c | 44 | and starts the iOS application run loop. |
miruga27 | 0:7fb6877b5d7c | 45 | |
miruga27 | 0:7fb6877b5d7c | 46 | See src/video/uikit/SDL_uikitappdelegate.m for more details. |
miruga27 | 0:7fb6877b5d7c | 47 | */ |
miruga27 | 0:7fb6877b5d7c | 48 | #define SDL_MAIN_NEEDED |
miruga27 | 0:7fb6877b5d7c | 49 | |
miruga27 | 0:7fb6877b5d7c | 50 | #elif defined(__ANDROID__) |
miruga27 | 0:7fb6877b5d7c | 51 | /* On Android SDL provides a Java class in SDLActivity.java that is the |
miruga27 | 0:7fb6877b5d7c | 52 | main activity entry point. |
miruga27 | 0:7fb6877b5d7c | 53 | |
miruga27 | 0:7fb6877b5d7c | 54 | See README-android.txt for more details on extending that class. |
miruga27 | 0:7fb6877b5d7c | 55 | */ |
miruga27 | 0:7fb6877b5d7c | 56 | #define SDL_MAIN_NEEDED |
miruga27 | 0:7fb6877b5d7c | 57 | |
miruga27 | 0:7fb6877b5d7c | 58 | #endif |
miruga27 | 0:7fb6877b5d7c | 59 | #endif /* SDL_MAIN_HANDLED */ |
miruga27 | 0:7fb6877b5d7c | 60 | |
miruga27 | 0:7fb6877b5d7c | 61 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 62 | #define C_LINKAGE "C" |
miruga27 | 0:7fb6877b5d7c | 63 | #else |
miruga27 | 0:7fb6877b5d7c | 64 | #define C_LINKAGE |
miruga27 | 0:7fb6877b5d7c | 65 | #endif /* __cplusplus */ |
miruga27 | 0:7fb6877b5d7c | 66 | |
miruga27 | 0:7fb6877b5d7c | 67 | /** |
miruga27 | 0:7fb6877b5d7c | 68 | * \file SDL_main.h |
miruga27 | 0:7fb6877b5d7c | 69 | * |
miruga27 | 0:7fb6877b5d7c | 70 | * The application's main() function must be called with C linkage, |
miruga27 | 0:7fb6877b5d7c | 71 | * and should be declared like this: |
miruga27 | 0:7fb6877b5d7c | 72 | * \code |
miruga27 | 0:7fb6877b5d7c | 73 | * #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 74 | * extern "C" |
miruga27 | 0:7fb6877b5d7c | 75 | * #endif |
miruga27 | 0:7fb6877b5d7c | 76 | * int main(int argc, char *argv[]) |
miruga27 | 0:7fb6877b5d7c | 77 | * { |
miruga27 | 0:7fb6877b5d7c | 78 | * } |
miruga27 | 0:7fb6877b5d7c | 79 | * \endcode |
miruga27 | 0:7fb6877b5d7c | 80 | */ |
miruga27 | 0:7fb6877b5d7c | 81 | |
miruga27 | 0:7fb6877b5d7c | 82 | #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) |
miruga27 | 0:7fb6877b5d7c | 83 | #define main SDL_main |
miruga27 | 0:7fb6877b5d7c | 84 | #endif |
miruga27 | 0:7fb6877b5d7c | 85 | |
miruga27 | 0:7fb6877b5d7c | 86 | /** |
miruga27 | 0:7fb6877b5d7c | 87 | * The prototype for the application's main() function |
miruga27 | 0:7fb6877b5d7c | 88 | */ |
miruga27 | 0:7fb6877b5d7c | 89 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); |
miruga27 | 0:7fb6877b5d7c | 90 | |
miruga27 | 0:7fb6877b5d7c | 91 | |
miruga27 | 0:7fb6877b5d7c | 92 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 93 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 94 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 95 | #endif |
miruga27 | 0:7fb6877b5d7c | 96 | |
miruga27 | 0:7fb6877b5d7c | 97 | /** |
miruga27 | 0:7fb6877b5d7c | 98 | * This is called by the real SDL main function to let the rest of the |
miruga27 | 0:7fb6877b5d7c | 99 | * library know that initialization was done properly. |
miruga27 | 0:7fb6877b5d7c | 100 | * |
miruga27 | 0:7fb6877b5d7c | 101 | * Calling this yourself without knowing what you're doing can cause |
miruga27 | 0:7fb6877b5d7c | 102 | * crashes and hard to diagnose problems with your application. |
miruga27 | 0:7fb6877b5d7c | 103 | */ |
miruga27 | 0:7fb6877b5d7c | 104 | extern DECLSPEC void SDLCALL SDL_SetMainReady(void); |
miruga27 | 0:7fb6877b5d7c | 105 | |
miruga27 | 0:7fb6877b5d7c | 106 | #ifdef __WIN32__ |
miruga27 | 0:7fb6877b5d7c | 107 | |
miruga27 | 0:7fb6877b5d7c | 108 | /** |
miruga27 | 0:7fb6877b5d7c | 109 | * This can be called to set the application class at startup |
miruga27 | 0:7fb6877b5d7c | 110 | */ |
miruga27 | 0:7fb6877b5d7c | 111 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, |
miruga27 | 0:7fb6877b5d7c | 112 | void *hInst); |
miruga27 | 0:7fb6877b5d7c | 113 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); |
miruga27 | 0:7fb6877b5d7c | 114 | |
miruga27 | 0:7fb6877b5d7c | 115 | #endif /* __WIN32__ */ |
miruga27 | 0:7fb6877b5d7c | 116 | |
miruga27 | 0:7fb6877b5d7c | 117 | |
miruga27 | 0:7fb6877b5d7c | 118 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 119 | } |
miruga27 | 0:7fb6877b5d7c | 120 | #endif |
miruga27 | 0:7fb6877b5d7c | 121 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 122 | |
miruga27 | 0:7fb6877b5d7c | 123 | #endif /* _SDL_main_h */ |
miruga27 | 0:7fb6877b5d7c | 124 | |
miruga27 | 0:7fb6877b5d7c | 125 | /* vi: set ts=4 sw=4 expandtab: */ |