diff options
| author | Ray <raysan5@gmail.com> | 2018-04-02 10:48:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-02 10:48:02 +0200 |
| commit | e72b96ada12e899bad3ca50fdf9c2e079aa4c3a9 (patch) | |
| tree | c1f20ade9cce0112bafcf0cdc3e4fea2cda3a887 /src | |
| parent | bd2c81d481d76024d7a9e2bf45e81dc7b9c5a12c (diff) | |
| parent | 2c219fb81458b855c9383cd38885993192d856cd (diff) | |
| download | raylib-e72b96ada12e899bad3ca50fdf9c2e079aa4c3a9.tar.gz raylib-e72b96ada12e899bad3ca50fdf9c2e079aa4c3a9.zip | |
Merge pull request #508 from a3f/master
Allow use of main instead of android_main
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -499,17 +499,33 @@ void InitWindow(int width, int height, void *data) #endif #if defined(PLATFORM_ANDROID) +/* To allow easier porting to android, we allow the user to define a main function + * which we call from android_main, that we define ourselves + */ +extern int main(int argc, char *argv[]); +void android_main(struct android_app *_app) { + char arg0[] = "raylib"; /* argv[] are mutable */ + app = _app; + /* TODO should we maybe report != 0 return codes somewhere? */ + (void)main(1, (char*[]){ arg0, NULL }); +} +/* TODO add this to header, if apps really need it) */ +struct android_app *GetAndroidApp(void) +{ + return app; +} + // Initialize window and OpenGL context (and Android activity) // NOTE: data parameter could be used to pass any kind of required data to the initialization void InitWindow(int width, int height, void *data) { + (void)data; // ignored TraceLog(LOG_INFO, "Initializing raylib (v1.9.6-dev)"); screenWidth = width; screenHeight = height; // Input data is android app pointer - app = (struct android_app *)data; internalDataPath = app->activity->internalDataPath; // Set desired windows flags before initializing anything |
