diff options
| author | Ray San <[email protected]> | 2017-11-06 14:19:36 +0100 |
|---|---|---|
| committer | Ray San <[email protected]> | 2017-11-06 14:19:36 +0100 |
| commit | d27a373c8f23071f5f463552b0c056a38aaed4b2 (patch) | |
| tree | 28fd73b4b699a148a692d2fd75dc2ceca218b870 /examples | |
| parent | d918334a2e1ce32961c0797a4b13fdd5b4ce5630 (diff) | |
| download | raylib.com-d27a373c8f23071f5f463552b0c056a38aaed4b2.tar.gz raylib.com-d27a373c8f23071f5f463552b0c056a38aaed4b2.zip | |
Examples reviewed to compile for Android
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/web/models/models_billboard.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_box_collisions.c | 19 | ||||
| -rw-r--r-- | examples/web/models/models_cubicmap.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_geometric_shapes.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_heightmap.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_material_pbr.c | 20 | ||||
| -rw-r--r-- | examples/web/models/models_mesh_generation.c | 19 | ||||
| -rw-r--r-- | examples/web/models/models_mesh_picking.c | 20 | ||||
| -rw-r--r-- | examples/web/models/models_obj_loading.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_skybox.c | 17 | ||||
| -rw-r--r-- | examples/web/models/models_yaw_pitch_roll.c | 26 |
11 files changed, 170 insertions, 36 deletions
diff --git a/examples/web/models/models_billboard.c b/examples/web/models/models_billboard.c index 53b72e1..15e5cc4 100644 --- a/examples/web/models/models_billboard.c +++ b/examples/web/models/models_billboard.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -35,11 +39,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - drawing billboards"); +#endif bill = LoadTexture("resources/billboard.png"); // Our texture billboard @@ -64,8 +76,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_box_collisions.c b/examples/web/models/models_box_collisions.c index 97f0731..ea35d25 100644 --- a/examples/web/models/models_box_collisions.c +++ b/examples/web/models/models_box_collisions.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -45,12 +49,20 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - box collisions"); - +#endif + playerColor = GREEN; #if defined(PLATFORM_WEB) @@ -70,8 +82,9 @@ int main() //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_cubicmap.c b/examples/web/models/models_cubicmap.c index bc0e716..8d5e69e 100644 --- a/examples/web/models/models_cubicmap.c +++ b/examples/web/models/models_cubicmap.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -37,11 +41,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - cubesmap loading and drawing"); +#endif Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) @@ -78,8 +90,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_geometric_shapes.c b/examples/web/models/models_geometric_shapes.c index 9247f51..daaded4 100644 --- a/examples/web/models/models_geometric_shapes.c +++ b/examples/web/models/models_geometric_shapes.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -32,11 +36,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - geometric shapes"); +#endif #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); @@ -55,8 +67,9 @@ int main() //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_heightmap.c b/examples/web/models/models_heightmap.c index e1937c4..1b9d619 100644 --- a/examples/web/models/models_heightmap.c +++ b/examples/web/models/models_heightmap.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -37,11 +41,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - heightmap loading and drawing"); +#endif Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) @@ -74,8 +86,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_material_pbr.c b/examples/web/models/models_material_pbr.c index 051384a..768bc73 100644 --- a/examples/web/models/models_material_pbr.c +++ b/examples/web/models/models_material_pbr.c @@ -19,6 +19,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define CUBEMAP_SIZE 512 // Cubemap texture size #define IRRADIANCE_SIZE 32 // Irradiance texture size #define PREFILTERED_SIZE 256 // Prefiltered HDR environment texture size @@ -46,15 +50,20 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness); //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#if defined(PLATFORM_ANDROID) +void android_main(struct android_app *app) +#else +int main(void) +#endif { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) +#if defined(PLATFORM_ANDROID) + InitWindow(screenWidth, screenHeight, app); +#else InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material"); +#endif // Load model and PBR material model = LoadModel("resources/pbr/trooper.obj"); @@ -90,8 +99,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_mesh_generation.c b/examples/web/models/models_mesh_generation.c index 73c8e95..9c3cf07 100644 --- a/examples/web/models/models_mesh_generation.c +++ b/examples/web/models/models_mesh_generation.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define NUM_MODELS 7 // We generate 7 parametric 3d shapes //---------------------------------------------------------------------------------- @@ -41,12 +45,20 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - mesh generation"); - +#endif + // We generate a checked image for texturing Image checked = GenImageChecked(2, 2, 1, 1, RED, GREEN); Texture2D texture = LoadTextureFromImage(checked); @@ -85,8 +97,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_mesh_picking.c b/examples/web/models/models_mesh_picking.c index d659e2d..3a85221 100644 --- a/examples/web/models/models_mesh_picking.c +++ b/examples/web/models/models_mesh_picking.c @@ -19,6 +19,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -55,14 +59,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#if defined(PLATFORM_ANDROID) +void android_main(struct android_app *app) +#else +int main(void) +#endif { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - +#if defined(PLATFORM_ANDROID) + InitWindow(screenWidth, screenHeight, app); +#else InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d mesh picking"); +#endif // Define the camera to look into our 3d world camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position @@ -101,8 +110,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_obj_loading.c b/examples/web/models/models_obj_loading.c index f58a3ad..1e11bdd 100644 --- a/examples/web/models/models_obj_loading.c +++ b/examples/web/models/models_obj_loading.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -37,11 +41,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - obj model loading"); +#endif dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture @@ -67,8 +79,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_skybox.c b/examples/web/models/models_skybox.c index 8f2bcfd..364562e 100644 --- a/examples/web/models/models_skybox.c +++ b/examples/web/models/models_skybox.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -34,11 +38,19 @@ void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#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, "raylib [models] example - skybox loading and drawing"); +#endif // Load skybox model Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f); @@ -79,8 +91,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/models/models_yaw_pitch_roll.c b/examples/web/models/models_yaw_pitch_roll.c index 33fef31..7699d6b 100644 --- a/examples/web/models/models_yaw_pitch_roll.c +++ b/examples/web/models/models_yaw_pitch_roll.c @@ -15,13 +15,14 @@ #include "raylib.h" #include "raymath.h" -// Draw angle gauge controls -void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color); - #if defined(PLATFORM_WEB) #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -48,17 +49,25 @@ float yaw = 0.0f; //---------------------------------------------------------------------------------- void UpdateDrawFrame(void); // Update and Draw one frame +// Draw angle gauge controls +void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color); + //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() +#if defined(PLATFORM_ANDROID) +void android_main(struct android_app *app) +#else +int main(void) +#endif { // Initialization //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - +#if defined(PLATFORM_ANDROID) + InitWindow(screenWidth, screenHeight, app); +#else InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)"); +#endif texAngleGauge = LoadTexture("resources/angle_gauge.png"); texBackground = LoadTexture("resources/background.png"); @@ -106,8 +115,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- |
