aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2018-04-02 10:48:02 +0200
committerGitHub <noreply@github.com>2018-04-02 10:48:02 +0200
commite72b96ada12e899bad3ca50fdf9c2e079aa4c3a9 (patch)
treec1f20ade9cce0112bafcf0cdc3e4fea2cda3a887
parentbd2c81d481d76024d7a9e2bf45e81dc7b9c5a12c (diff)
parent2c219fb81458b855c9383cd38885993192d856cd (diff)
downloadraylib-e72b96ada12e899bad3ca50fdf9c2e079aa4c3a9.tar.gz
raylib-e72b96ada12e899bad3ca50fdf9c2e079aa4c3a9.zip
Merge pull request #508 from a3f/master
Allow use of main instead of android_main
-rw-r--r--games/arkanoid.c19
-rw-r--r--games/asteroids.c19
-rw-r--r--games/asteroids_survival.c19
-rw-r--r--games/floppy.c17
-rw-r--r--games/gold_fever.c19
-rw-r--r--games/gorilas.c19
-rw-r--r--games/just_do/just_do.c19
-rw-r--r--games/koala_seasons/koala_seasons.c21
-rw-r--r--games/light_my_ritual/light_my_ritual.c17
-rw-r--r--games/missile_commander.c19
-rw-r--r--games/pang.c19
-rw-r--r--games/skully_escape/skully_escape.c17
-rw-r--r--games/snake.c19
-rw-r--r--games/space_invaders.c19
-rw-r--r--games/tetris.c19
-rw-r--r--games/transmission/transmission.c20
-rw-r--r--games/wave_collector/wave_collector.c18
-rw-r--r--src/core.c18
-rw-r--r--templates/advance_game/advance_game.c19
-rw-r--r--templates/simple_game/simple_game.c17
-rw-r--r--templates/standard_game/standard_game.c19
21 files changed, 77 insertions, 315 deletions
diff --git a/games/arkanoid.c b/games/arkanoid.c
index 1da80a1e..2a4a2e53 100644
--- a/games/arkanoid.c
+++ b/games/arkanoid.c
@@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -83,19 +79,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: arkanoid");
-#endif
InitGame();
@@ -122,9 +110,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -338,4 +325,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/asteroids.c b/games/asteroids.c
index dc8a9e07..80096de6 100644
--- a/games/asteroids.c
+++ b/games/asteroids.c
@@ -15,10 +15,6 @@
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -101,19 +97,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: asteroids");
-#endif
InitGame();
@@ -140,9 +128,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -578,4 +565,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/asteroids_survival.c b/games/asteroids_survival.c
index 12759606..8086433e 100644
--- a/games/asteroids_survival.c
+++ b/games/asteroids_survival.c
@@ -15,10 +15,6 @@
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -84,19 +80,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: asteroids survival");
-#endif
InitGame();
@@ -123,9 +111,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -388,4 +375,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/floppy.c b/games/floppy.c
index d7c4f129..2ca91a14 100644
--- a/games/floppy.c
+++ b/games/floppy.c
@@ -13,10 +13,6 @@
#include "raylib.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -72,19 +68,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
-void android_main(struct android_app *app)
-#else
int main(void)
-#endif
{
// Initialization
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: floppy");
-#endif
InitGame();
@@ -111,9 +99,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
// Module Functions Definitions (local)
@@ -250,4 +237,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/gold_fever.c b/games/gold_fever.c
index 1d8b6b7c..c5f36efa 100644
--- a/games/gold_fever.c
+++ b/games/gold_fever.c
@@ -13,10 +13,6 @@
#include "raylib.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -81,19 +77,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: gold fever");
-#endif
InitGame();
@@ -120,9 +108,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -291,4 +278,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/gorilas.c b/games/gorilas.c
index 75decd96..9ef71b55 100644
--- a/games/gorilas.c
+++ b/games/gorilas.c
@@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -120,19 +116,11 @@ static bool UpdateBall(int playerTurn);
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: gorilas");
-#endif
InitGame();
@@ -159,9 +147,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -576,4 +563,4 @@ static bool UpdateBall(int playerTurn)
}
return false;
-} \ No newline at end of file
+}
diff --git a/games/just_do/just_do.c b/games/just_do/just_do.c
index a9fef18c..c7c76af9 100644
--- a/games/just_do/just_do.c
+++ b/games/just_do/just_do.c
@@ -16,10 +16,6 @@
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines currentScreen
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -53,19 +49,11 @@ 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(void)
-#endif
{
- // Initialization
+ // Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "GGJ15 - JUST DO");
-#endif
// Load global data here (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@@ -104,9 +92,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//----------------------------------------------------------------------------------
@@ -370,4 +357,4 @@ void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/games/koala_seasons/koala_seasons.c b/games/koala_seasons/koala_seasons.c
index 770cf3de..8657d3d5 100644
--- a/games/koala_seasons/koala_seasons.c
+++ b/games/koala_seasons/koala_seasons.c
@@ -15,10 +15,6 @@
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines currentScreen
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -47,12 +43,7 @@ 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(void)
-#endif
-{
+int main(void) {
// Initialization
//---------------------------------------------------------
const int screenWidth = 1280;
@@ -62,11 +53,8 @@ int main(void)
//ShowLogo();
//SetConfigFlags(FLAG_FULLSCREEN_MODE);
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
+ // Note that windowTitle is ignored on Android
InitWindow(screenWidth, screenHeight, windowTitle);
-#endif
// Load global data here (assets that must be available in all screens, i.e. fonts)
font = LoadSpriteFont("resources/graphics/mainfont.png");
@@ -145,9 +133,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
void TransitionToScreen(int screen)
@@ -282,4 +269,4 @@ void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/games/light_my_ritual/light_my_ritual.c b/games/light_my_ritual/light_my_ritual.c
index bc5a4623..985baa04 100644
--- a/games/light_my_ritual/light_my_ritual.c
+++ b/games/light_my_ritual/light_my_ritual.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -55,19 +51,11 @@ 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(void)
-#endif
{
- // Initialization
+ // Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "GGJ16 - LIGHT MY RITUAL!");
-#endif
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@@ -129,9 +117,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
void TransitionToScreen(int screen)
diff --git a/games/missile_commander.c b/games/missile_commander.c
index 245cefd1..15e06f6d 100644
--- a/games/missile_commander.c
+++ b/games/missile_commander.c
@@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -119,19 +115,11 @@ static void UpdateIncomingFire();
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: missile commander");
-#endif
InitGame();
@@ -158,9 +146,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//--------------------------------------------------------------------------------------
@@ -544,4 +531,4 @@ static void UpdateIncomingFire()
missileIndex++;
if (missileIndex == MAX_MISSILES) missileIndex = 0;
}
-} \ No newline at end of file
+}
diff --git a/games/pang.c b/games/pang.c
index 731234ae..a81f32f0 100644
--- a/games/pang.c
+++ b/games/pang.c
@@ -15,10 +15,6 @@
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -110,19 +106,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: pang");
-#endif
InitGame();
@@ -149,9 +137,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -637,4 +624,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/skully_escape/skully_escape.c b/games/skully_escape/skully_escape.c
index 3a0e4cb0..dc545117 100644
--- a/games/skully_escape/skully_escape.c
+++ b/games/skully_escape/skully_escape.c
@@ -14,10 +14,6 @@
#include "player.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -52,19 +48,11 @@ 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(void)
-#endif
{
- // Initialization
+ // Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "SKULLY ESCAPE [KING GAMEJAM]");
-#endif
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@@ -112,9 +100,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
void TransitionToScreen(int screen)
diff --git a/games/snake.c b/games/snake.c
index c971ce15..40d66da8 100644
--- a/games/snake.c
+++ b/games/snake.c
@@ -13,10 +13,6 @@
#include "raylib.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -73,19 +69,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: snake");
-#endif
InitGame();
@@ -112,9 +100,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -298,4 +285,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/space_invaders.c b/games/space_invaders.c
index b80de050..97f14547 100644
--- a/games/space_invaders.c
+++ b/games/space_invaders.c
@@ -13,10 +13,6 @@
#include "raylib.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -90,19 +86,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: space invaders");
-#endif
InitGame();
@@ -129,9 +117,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//------------------------------------------------------------------------------------
@@ -410,4 +397,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
-} \ No newline at end of file
+}
diff --git a/games/tetris.c b/games/tetris.c
index e02d7f18..3c9d5c5c 100644
--- a/games/tetris.c
+++ b/games/tetris.c
@@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -109,19 +105,11 @@ static void DeleteCompleteLines();
//------------------------------------------------------------------------------------
// Program 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)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "sample game: tetris");
-#endif
InitGame();
@@ -148,9 +136,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//--------------------------------------------------------------------------------------
@@ -841,4 +828,4 @@ static void DeleteCompleteLines()
}
}
}
-} \ No newline at end of file
+}
diff --git a/games/transmission/transmission.c b/games/transmission/transmission.c
index a508b5d2..37824a7b 100644
--- a/games/transmission/transmission.c
+++ b/games/transmission/transmission.c
@@ -17,10 +17,6 @@
#include <stdlib.h>
#include <stdio.h>
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -55,20 +51,15 @@ 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(void)
-#endif
{
// Initialization
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
+#ifndef PLATFORM_ANDROID
SetConfigFlags(FLAG_SHOW_LOGO); // | FLAG_FULLSCREEN_MODE);
- InitWindow(screenWidth, screenHeight, "raylib game - transmission mission");
#endif
+ // Note windowTitle is unused on Android
+ InitWindow(screenWidth, screenHeight, "raylib game - transmission mission");
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@@ -138,9 +129,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//----------------------------------------------------------------------------------
@@ -462,4 +452,4 @@ void DrawButton(const char *text)
Vector2 measure = MeasureTextEx(fontMission, text, fontSizeButton, 0);
Vector2 textPos = {textPositionButton.x - measure.x/2 + 10, textPositionButton.y - measure.y/2 - 10};
DrawTextEx(fontMission, text, textPos , fontSizeButton, 0, textColorButton);
-} \ No newline at end of file
+}
diff --git a/games/wave_collector/wave_collector.c b/games/wave_collector/wave_collector.c
index e28c0b84..2099b74c 100644
--- a/games/wave_collector/wave_collector.c
+++ b/games/wave_collector/wave_collector.c
@@ -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
}
//----------------------------------------------------------------------------------
diff --git a/src/core.c b/src/core.c
index 99cc3c5a..347f44b4 100644
--- a/src/core.c
+++ b/src/core.c
@@ -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
diff --git a/templates/advance_game/advance_game.c b/templates/advance_game/advance_game.c
index 5499b2d8..768b2f94 100644
--- a/templates/advance_game/advance_game.c
+++ b/templates/advance_game/advance_game.c
@@ -15,10 +15,6 @@
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines global variable: currentScreen
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -53,19 +49,11 @@ 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(void)
-#endif
{
- // Initialization
+ // Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
-#if defined(PLATFORM_ANDROID)
- InitWindow(screenWidth, screenHeight, app);
-#else
InitWindow(screenWidth, screenHeight, "raylib template - advance game");
-#endif
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@@ -116,9 +104,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
//----------------------------------------------------------------------------------
@@ -299,4 +286,4 @@ static void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/templates/simple_game/simple_game.c b/templates/simple_game/simple_game.c
index 50859221..028b1da8 100644
--- a/templates/simple_game/simple_game.c
+++ b/templates/simple_game/simple_game.c
@@ -14,10 +14,6 @@
#include "raylib.h"
-#if defined(PLATFORM_ANDROID)
- #include "android_native_app_glue.h"
-#endif
-
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
@@ -26,22 +22,14 @@ typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen;
//----------------------------------------------------------------------------------
// 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 - simple game");
-#endif
GameScreen currentScreen = LOGO;
@@ -158,7 +146,6 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-#if !defined(PLATFORM_ANDROID)
+
return 0;
-#endif
}
diff --git a/templates/standard_game/standard_game.c b/templates/standard_game/standard_game.c
index cf059451..8871484e 100644
--- a/templates/standard_game/standard_game.c
+++ b/templates/standard_game/standard_game.c
@@ -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
-} \ No newline at end of file
+}