Keep working on Android custom building...
...almost there! raylib already works, issues with OpenAL Soft linkage...
This commit is contained in:
parent
ccd6271a7f
commit
c418aa2fb0
17 changed files with 1351 additions and 17 deletions
|
@ -44,27 +44,38 @@ ANDROID_BUILD_TOOLS = C:/android-sdk/build-tools/26.0.1
|
|||
JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_144
|
||||
|
||||
# Compilers
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
||||
|
||||
# Define compiler flags
|
||||
CFLAGS = -Wall -std=c99 -DPLATFORM_ANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||
# Compiler flags for arquitecture
|
||||
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||
# Compilation functions attributes options
|
||||
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
||||
# Compiler options for the linker
|
||||
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
|
||||
# Preprocessor macro definitions
|
||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16
|
||||
|
||||
# Define any directories containing required header files
|
||||
INCLUDES = -I. -Ijni/include -I$(ANDROID_NDK)/sources/android/native_app_glue
|
||||
# Paths containing required header files
|
||||
INCLUDES = -I. -Isrc/include -I$(ANDROID_NDK)/sources/android/native_app_glue
|
||||
|
||||
# Define library paths containing required libs
|
||||
LFLAGS = -L. -Ljni -Llib -Ljni/libs
|
||||
# Linker options
|
||||
LFLAGS = -Wl,-soname,lib$(LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
||||
LFLAGS = -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
|
||||
# Force linking of library module to define symbol
|
||||
LFLAGS = -u ANativeActivity_onCreate
|
||||
# Library paths containing required libs
|
||||
LFLAGS += -L. -Lsrc -Llib -Lsrc/libs
|
||||
|
||||
# Define any libraries to link into executable
|
||||
# if you want to link libraries (libname.so or libname.a), use the -lname
|
||||
LIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES
|
||||
LIBS = -lnative_app_glue -lraylib -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm
|
||||
|
||||
# Building APK
|
||||
# NOTE: typing 'make' will invoke the default target entry called 'all',
|
||||
all: project_dirs \
|
||||
native_app_glue \
|
||||
project_code \
|
||||
project_code_ok \
|
||||
gen_keystore \
|
||||
project_package \
|
||||
project_class \
|
||||
|
@ -90,13 +101,17 @@ native_app_glue:
|
|||
|
||||
# Compile project code as shared libraries
|
||||
# OUTPUT: $(PROJECT_DIR)/lib/lib$(LIBRARY_NAME).so
|
||||
project_code:
|
||||
$(CC) -c src/core.c -o temp/obj/core.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC
|
||||
$(CC) -c src/rlgl.c -o temp/obj/rlgl.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC -DGRAPHICS_API_OPENGL_ES2
|
||||
$(CC) -c src/utils.c -o temp/obj/utils.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC
|
||||
$(CC) -c src/game_crash.c -o temp/obj/game_crash.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC
|
||||
$(CC) -o lib/armeabi-v7a/lib$(LIBRARY_NAME).so temp/obj/game_crash.o temp/obj/core.o temp/obj/rlgl.o temp/obj/utils.o -shared $(INCLUDES) $(LFLAGS) -lnative_app_glue $(LIBS) -u ANativeActivity_onCreate
|
||||
project_code_ok:
|
||||
$(CC) -c src/game_basic.c -o temp/obj/game_basic.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
||||
$(CC) -o lib/armeabi-v7a/lib$(LIBRARY_NAME).so temp/obj/game_basic.o -shared $(INCLUDES) $(LFLAGS) $(LIBS)
|
||||
|
||||
project_code:
|
||||
$(CC) -c src/core.c -o temp/obj/core.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
||||
$(CC) -c src/rlgl.c -o temp/obj/rlgl.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -DGRAPHICS_API_OPENGL_ES2
|
||||
$(CC) -c src/utils.c -o temp/obj/utils.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
||||
$(CC) -c src/game_crash.c -o temp/obj/game_crash.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
||||
$(CC) -o lib/armeabi-v7a/lib$(LIBRARY_NAME).so temp/obj/game_crash.o temp/obj/core.o temp/obj/rlgl.o temp/obj/utils.o -shared $(INCLUDES) $(LFLAGS) $(LIBS)
|
||||
|
||||
# Generate key for APK signing
|
||||
# OUTPUT: $(PROJECT_DIR)/temp/$(PROJECT_NAME).keystore
|
||||
gen_keystore:
|
||||
|
@ -125,7 +140,7 @@ project_class_dex:
|
|||
# NOTE: Use -A resources to define additional directory in which to find raw asset files
|
||||
project_apk:
|
||||
$(ANDROID_BUILD_TOOLS)/aapt package -v -f -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F temp/bin/$(PROJECT_NAME).unsigned.apk temp/bin
|
||||
$(ANDROID_BUILD_TOOLS)/aapt add -v $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).unsigned.apk lib/armeabi-v7a/lib$(LIBRARY_NAME).so
|
||||
$(ANDROID_BUILD_TOOLS)/aapt add -v $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).unsigned.apk lib/armeabi-v7a/lib$(LIBRARY_NAME).so lib/armeabi-v7a/libopenal.so
|
||||
|
||||
# Create temp/bin/$(PROJECT_NAME).signed.apk
|
||||
apk_signing:
|
||||
|
@ -139,7 +154,7 @@ apk_zip_align:
|
|||
deploy:
|
||||
$(ANDROID_HOME)/platform-tools/adb install -r $(PROJECT_NAME).apk
|
||||
$(ANDROID_HOME)/platform-tools/adb logcat -c
|
||||
$(ANDROID_HOME)/platform-tools/adb logcat *:W
|
||||
$(ANDROID_HOME)/platform-tools/adb -d logcat raylib:V *:S
|
||||
|
||||
#$(ANDROID_HOME)/platform-tools/adb logcat *:W
|
||||
#$(ANDROID_HOME)/platform-tools/adb -d logcat raylib:V *:S
|
||||
|
|
BIN
templates/android_project/assets/ambient.ogg
Normal file
BIN
templates/android_project/assets/ambient.ogg
Normal file
Binary file not shown.
BIN
templates/android_project/assets/coin.wav
Normal file
BIN
templates/android_project/assets/coin.wav
Normal file
Binary file not shown.
BIN
templates/android_project/assets/raylib_logo.png
Normal file
BIN
templates/android_project/assets/raylib_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
172
templates/android_project/src/game_basic.c
Normal file
172
templates/android_project/src/game_basic.c
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib - Android Basic Game template
|
||||
*
|
||||
* <Game title>
|
||||
* <Game description>
|
||||
*
|
||||
* This game has been created using raylib v1.2 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "android_native_app_glue.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Android Main entry point
|
||||
//----------------------------------------------------------------------------------
|
||||
void android_main(struct android_app *app)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
GameScreen currentScreen = LOGO;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, app);
|
||||
|
||||
// TODO: Initialize all required variables and load all required data here!
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Texture2D texture = LoadTexture("raylib_logo.png"); // Load texture (placed on assets folder)
|
||||
|
||||
Sound fx = LoadSound("coin.wav"); // Load WAV audio file (placed on assets folder)
|
||||
Music ambient = LoadMusicStream("ambient.ogg");
|
||||
PlayMusicStream(ambient);
|
||||
|
||||
int framesCounter = 0; // Used to count frames
|
||||
|
||||
SetTargetFPS(60); // Not required on Android, already locked to 60 fps
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateMusicStream(ambient);
|
||||
|
||||
switch(currentScreen)
|
||||
{
|
||||
case LOGO:
|
||||
{
|
||||
// TODO: Update LOGO screen variables here!
|
||||
|
||||
framesCounter++; // Count frames
|
||||
|
||||
// Wait for 4 seconds (240 frames) before jumping to TITLE screen
|
||||
if (framesCounter > 240)
|
||||
{
|
||||
currentScreen = TITLE;
|
||||
}
|
||||
} break;
|
||||
case TITLE:
|
||||
{
|
||||
// TODO: Update TITLE screen variables here!
|
||||
|
||||
// Press enter to change to GAMEPLAY screen
|
||||
if (IsGestureDetected(GESTURE_TAP))
|
||||
{
|
||||
PlaySound(fx);
|
||||
currentScreen = GAMEPLAY;
|
||||
}
|
||||
} break;
|
||||
case GAMEPLAY:
|
||||
{
|
||||
// TODO: Update GAMEPLAY screen variables here!
|
||||
|
||||
// Press enter to change to ENDING screen
|
||||
if (IsGestureDetected(GESTURE_TAP))
|
||||
{
|
||||
PlaySound(fx);
|
||||
currentScreen = ENDING;
|
||||
}
|
||||
} break;
|
||||
case ENDING:
|
||||
{
|
||||
// TODO: Update ENDING screen variables here!
|
||||
|
||||
// Press enter to return to TITLE screen
|
||||
if (IsGestureDetected(GESTURE_TAP))
|
||||
{
|
||||
PlaySound(fx);
|
||||
currentScreen = TITLE;
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
switch(currentScreen)
|
||||
{
|
||||
case LOGO:
|
||||
{
|
||||
// TODO: Draw LOGO screen here!
|
||||
DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
|
||||
DrawText("WAIT for 4 SECONDS...", 290, 400, 20, GRAY);
|
||||
|
||||
} break;
|
||||
case TITLE:
|
||||
{
|
||||
// TODO: Draw TITLE screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
|
||||
DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
|
||||
DrawText("TAP SCREEN to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
|
||||
|
||||
} break;
|
||||
case GAMEPLAY:
|
||||
{
|
||||
// TODO: Draw GAMEPLAY screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE);
|
||||
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
|
||||
DrawText("TAP SCREEN to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
|
||||
|
||||
} break;
|
||||
case ENDING:
|
||||
{
|
||||
// TODO: Draw ENDING screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
|
||||
DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
|
||||
DrawText("TAP SCREEN to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
|
||||
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// TODO: Unload all loaded data (textures, fonts, audio) here!
|
||||
|
||||
UnloadSound(fx); // Unload sound data
|
||||
UnloadMusicStream(ambient); // Unload music stream data
|
||||
|
||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
UnloadTexture(texture); // Unload texture data
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
1147
templates/android_project/src/include/raylib.h
Normal file
1147
templates/android_project/src/include/raylib.h
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue