Allow use of main instead of android_main

Inspired by #504.
Instead of requiring the user to do PLATFORM_ANDROID #ifdefery,
have the android_main entry point exported by raylib and call
the user-defined main. This way many games could (in theory)
run unmodified on Android and elsewhere.

This is untested!
This commit is contained in:
Ahmad Fatoum
2018-03-16 21:31:10 +01:00
parent 61e0e4b4f3
commit 2c219fb814
21 changed files with 77 additions and 315 deletions

View File

@ -22,10 +22,6 @@
#include <stdio.h> // Required for: printf()
#include <string.h> // Required for: strcpy()
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -60,11 +56,7 @@ static void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(int argc, char *argv[])
#endif
{
// Initialization
//---------------------------------------------------------
@ -89,12 +81,11 @@ int main(int argc, char *argv[])
}
#endif
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
#ifndef PLATFORM_ANDROID
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "GGJ17 - WAVE COLLECTOR");
#endif
// Note windowTitle is unused on Android
InitWindow(screenWidth, screenHeight, "GGJ17 - WAVE COLLECTOR");
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@ -143,9 +134,8 @@ int main(int argc, char *argv[])
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//----------------------------------------------------------------------------------