summaryrefslogtreecommitdiffhomepage
path: root/examples/web/text
diff options
context:
space:
mode:
authorRay San <[email protected]>2017-11-03 20:01:48 +0100
committerRay San <[email protected]>2017-11-03 20:01:48 +0100
commitd918334a2e1ce32961c0797a4b13fdd5b4ce5630 (patch)
tree1f16feb32953200c2a47cf425352f1bba70ab99a /examples/web/text
parente4041e4eb8c55db0a37c8af575c7a98c17963a9a (diff)
downloadraylib.com-d918334a2e1ce32961c0797a4b13fdd5b4ce5630.tar.gz
raylib.com-d918334a2e1ce32961c0797a4b13fdd5b4ce5630.zip
Updated to support Android platform
Diffstat (limited to 'examples/web/text')
-rw-r--r--examples/web/text/text_bmfont_ttf.c19
-rw-r--r--examples/web/text/text_bmfont_unordered.c17
-rw-r--r--examples/web/text/text_format_text.c19
-rw-r--r--examples/web/text/text_input_box.c17
-rw-r--r--examples/web/text/text_raylib_fonts.c19
-rw-r--r--examples/web/text/text_sprite_fonts.c19
-rw-r--r--examples/web/text/text_ttf_loading.c17
-rw-r--r--examples/web/text/text_writing_anim.c19
8 files changed, 125 insertions, 21 deletions
diff --git a/examples/web/text/text_bmfont_ttf.c b/examples/web/text/text_bmfont_ttf.c
index 41466e8..3c1cb6b 100644
--- a/examples/web/text/text_bmfont_ttf.c
+++ b/examples/web/text/text_bmfont_ttf.c
@@ -15,6 +15,10 @@
#include <emscripten/emscripten.h>
#endif
+#if defined(PLATFORM_ANDROID)
+ #include "android_native_app_glue.h"
+#endif
+
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
@@ -38,12 +42,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 [text] example - bmfont and ttf sprite fonts loading");
-
+#endif
+
fontBm = LoadSpriteFont("resources/bmfont.fnt"); // BMFont (AngelCode)
fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font
@@ -70,8 +82,9 @@ int main()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_bmfont_unordered.c b/examples/web/text/text_bmfont_unordered.c
index a42c39a..ffd2454 100644
--- a/examples/web/text/text_bmfont_unordered.c
+++ b/examples/web/text/text_bmfont_unordered.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 [text] example - bmfont unordered loading and drawing");
+#endif
// NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
font = LoadSpriteFont("resources/pixantiqua.fnt"); // BMFont (AngelCode)
@@ -63,8 +75,9 @@ int main()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_format_text.c b/examples/web/text/text_format_text.c
index c941935..13ecb9a 100644
--- a/examples/web/text/text_format_text.c
+++ b/examples/web/text/text_format_text.c
@@ -15,6 +15,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 [text] example - text formatting");
-
+#endif
+
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
@@ -56,8 +68,9 @@ int main()
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_input_box.c b/examples/web/text/text_input_box.c
index 5765df9..70ac08c 100644
--- a/examples/web/text/text_input_box.c
+++ b/examples/web/text/text_input_box.c
@@ -17,6 +17,10 @@
#include <emscripten/emscripten.h>
#endif
+#if defined(PLATFORM_ANDROID)
+ #include "android_native_app_glue.h"
+#endif
+
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
@@ -39,11 +43,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 [text] example - input box");
+#endif
textBox = (Rectangle){ screenWidth/2 - 100, 180, 225, 50 };
@@ -64,8 +76,9 @@ int main()
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_raylib_fonts.c b/examples/web/text/text_raylib_fonts.c
index 340b78f..45f0f51 100644
--- a/examples/web/text/text_raylib_fonts.c
+++ b/examples/web/text/text_raylib_fonts.c
@@ -15,6 +15,10 @@
#include <emscripten/emscripten.h>
#endif
+#if defined(PLATFORM_ANDROID)
+ #include "android_native_app_glue.h"
+#endif
+
#define MAX_FONTS 8
//----------------------------------------------------------------------------------
@@ -38,12 +42,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 [text] example - raylib fonts");
-
+#endif
+
Color tempColors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
colors = tempColors;
@@ -100,8 +112,9 @@ int main()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_sprite_fonts.c b/examples/web/text/text_sprite_fonts.c
index 42d41d0..724d290 100644
--- a/examples/web/text/text_sprite_fonts.c
+++ b/examples/web/text/text_sprite_fonts.c
@@ -15,6 +15,10 @@
#include <emscripten/emscripten.h>
#endif
+#if defined(PLATFORM_ANDROID)
+ #include "android_native_app_glue.h"
+#endif
+
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
@@ -39,12 +43,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 [text] example - sprite fonts usage");
-
+#endif
+
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
font1 = LoadSpriteFont("resources/custom_mecha.png"); // SpriteFont loading
font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading
@@ -79,8 +91,9 @@ int main()
UnloadSpriteFont(font3); // SpriteFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_ttf_loading.c b/examples/web/text/text_ttf_loading.c
index 0209743..bb2fc2b 100644
--- a/examples/web/text/text_ttf_loading.c
+++ b/examples/web/text/text_ttf_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
//----------------------------------------------------------------------------------
@@ -43,11 +47,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 [text] example - ttf loading");
+#endif
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
@@ -85,8 +97,9 @@ int main()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------
diff --git a/examples/web/text/text_writing_anim.c b/examples/web/text/text_writing_anim.c
index 1522a06..c01c30c 100644
--- a/examples/web/text/text_writing_anim.c
+++ b/examples/web/text/text_writing_anim.c
@@ -15,6 +15,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 [text] example - text writing anim");
-
+#endif
+
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
@@ -56,8 +68,9 @@ int main()
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
-
+#if !defined(PLATFORM_ANDROID)
return 0;
+#endif
}
//----------------------------------------------------------------------------------