diff options
| author | Ray San <[email protected]> | 2017-11-03 20:01:48 +0100 |
|---|---|---|
| committer | Ray San <[email protected]> | 2017-11-03 20:01:48 +0100 |
| commit | d918334a2e1ce32961c0797a4b13fdd5b4ce5630 (patch) | |
| tree | 1f16feb32953200c2a47cf425352f1bba70ab99a /examples/web/textures | |
| parent | e4041e4eb8c55db0a37c8af575c7a98c17963a9a (diff) | |
| download | raylib.com-d918334a2e1ce32961c0797a4b13fdd5b4ce5630.tar.gz raylib.com-d918334a2e1ce32961c0797a4b13fdd5b4ce5630.zip | |
Updated to support Android platform
Diffstat (limited to 'examples/web/textures')
| -rw-r--r-- | examples/web/textures/textures_image_drawing.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_image_generation.c | 20 | ||||
| -rw-r--r-- | examples/web/textures/textures_image_loading.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_image_processing.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_logo_raylib.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_particles_blending.c | 21 | ||||
| -rw-r--r-- | examples/web/textures/textures_raw_data.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_rectangle.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_srcrec_dstrec.c | 19 | ||||
| -rw-r--r-- | examples/web/textures/textures_to_image.c | 19 |
10 files changed, 160 insertions, 33 deletions
diff --git a/examples/web/textures/textures_image_drawing.c b/examples/web/textures/textures_image_drawing.c index 3e0dd47..4e0508f 100644 --- a/examples/web/textures/textures_image_drawing.c +++ b/examples/web/textures/textures_image_drawing.c @@ -17,6 +17,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -33,12 +37,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 [textures] example - image drawing"); - +#endif + Image cat = LoadImage("resources/cat.png"); // Load image in CPU memory (RAM) ImageCrop(&cat, (Rectangle){ 100, 10, 280, 380 }); // Crop an image piece ImageFlipHorizontal(&cat); // Flip cropped image horizontally @@ -74,8 +86,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_image_generation.c b/examples/web/textures/textures_image_generation.c index 9932ab6..e5dba4a 100644 --- a/examples/web/textures/textures_image_generation.c +++ b/examples/web/textures/textures_image_generation.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define NUM_TEXTURES 7 // Currently we have 7 generation algorithms //---------------------------------------------------------------------------------- @@ -35,14 +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 //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - +#if defined(PLATFORM_ANDROID) + InitWindow(screenWidth, screenHeight, app); +#else InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation"); +#endif Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, RED, BLUE); Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE); @@ -90,8 +99,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_image_loading.c b/examples/web/textures/textures_image_loading.c index 6455221..17680a0 100644 --- a/examples/web/textures/textures_image_loading.c +++ b/examples/web/textures/textures_image_loading.c @@ -17,6 +17,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -34,12 +38,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 [textures] example - image loading"); - +#endif + Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM @@ -64,8 +76,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_image_processing.c b/examples/web/textures/textures_image_processing.c index 39b40fe..68b894e 100644 --- a/examples/web/textures/textures_image_processing.c +++ b/examples/web/textures/textures_image_processing.c @@ -19,6 +19,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define NUM_PROCESSES 8 //---------------------------------------------------------------------------------- @@ -65,12 +69,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 [textures] example - image processing"); - +#endif + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM) @@ -99,8 +111,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_logo_raylib.c b/examples/web/textures/textures_logo_raylib.c index 836735a..a5f1154 100644 --- a/examples/web/textures/textures_logo_raylib.c +++ b/examples/web/textures/textures_logo_raylib.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,12 +36,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 [textures] example - texture loading and drawing"); - +#endif + texture = LoadTexture("resources/raylib_logo.png"); // Texture loading #if defined(PLATFORM_WEB) @@ -59,8 +71,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_particles_blending.c b/examples/web/textures/textures_particles_blending.c index 1ddacf8..c9f468a 100644 --- a/examples/web/textures/textures_particles_blending.c +++ b/examples/web/textures/textures_particles_blending.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define MAX_PARTICLES 200 //---------------------------------------------------------------------------------- @@ -50,13 +54,21 @@ 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 [textures] example - particles blending"); - - // Initialize particles +#endif + + // Initialize particles for (int i = 0; i < MAX_PARTICLES; i++) { mouseTail[i].position = (Vector2){ 0, 0 }; @@ -88,8 +100,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_raw_data.c b/examples/web/textures/textures_raw_data.c index f06c798..f3fe93e 100644 --- a/examples/web/textures/textures_raw_data.c +++ b/examples/web/textures/textures_raw_data.c @@ -19,6 +19,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -36,12 +40,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 [textures] example - texture from raw data"); - +#endif + // Load RAW image data (512x512, 32bit RGBA, no file header) Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0); fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM) @@ -91,8 +103,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_rectangle.c b/examples/web/textures/textures_rectangle.c index 0783f88..3efe9a0 100644 --- a/examples/web/textures/textures_rectangle.c +++ b/examples/web/textures/textures_rectangle.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + #define MAX_FRAME_SPEED 15 #define MIN_FRAME_SPEED 1 @@ -43,12 +47,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 [texture] example - texture rectangle"); - +#endif + scarfy = LoadTexture("resources/scarfy.png"); // Texture loading position = (Vector2){ 350.0f, 280.0f }; @@ -74,8 +86,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_srcrec_dstrec.c b/examples/web/textures/textures_srcrec_dstrec.c index 5a93818..3eadacb 100644 --- a/examples/web/textures/textures_srcrec_dstrec.c +++ b/examples/web/textures/textures_srcrec_dstrec.c @@ -15,6 +15,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -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 [textures] examples - texture source and destination rectangles"); - +#endif + scarfy = LoadTexture("resources/scarfy.png"); // Texture loading frameWidth = scarfy.width/6; @@ -82,8 +94,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- diff --git a/examples/web/textures/textures_to_image.c b/examples/web/textures/textures_to_image.c index df7b458..eb494d5 100644 --- a/examples/web/textures/textures_to_image.c +++ b/examples/web/textures/textures_to_image.c @@ -17,6 +17,10 @@ #include <emscripten/emscripten.h> #endif +#if defined(PLATFORM_ANDROID) + #include "android_native_app_glue.h" +#endif + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -37,12 +41,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 [textures] example - texture to image"); - +#endif + image = LoadImage("resources/raylib_logo.png"); // Load image data into CPU memory (RAM) texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (RAM -> VRAM) UnloadImage(image); // Unload image data from CPU memory (RAM) @@ -72,8 +84,9 @@ int main() CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - +#if !defined(PLATFORM_ANDROID) return 0; +#endif } //---------------------------------------------------------------------------------- |
