mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-29 18:29:18 -05:00
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:
@ -15,29 +15,17 @@
|
||||
#include "raylib.h"
|
||||
#include "screens/screens.h" // NOTE: Defines global variable: currentScreen
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
#include "android_native_app_glue.h"
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main entry point
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
void android_main(struct android_app *app)
|
||||
#else
|
||||
int main(void)
|
||||
#endif
|
||||
{
|
||||
// Initialization
|
||||
// Initialization (Note windowTitle is unused on Android)
|
||||
//---------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
InitWindow(screenWidth, screenHeight, app);
|
||||
#else
|
||||
InitWindow(screenWidth, screenHeight, "raylib template - standard game");
|
||||
#endif
|
||||
|
||||
// TODO: Load global data here (assets that must be available in all screens, i.e. fonts)
|
||||
|
||||
@ -150,7 +138,6 @@ int main(void)
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user