From 72349449317fefb87372608ea3b81332e1ce0cd3 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 27 Dec 2021 00:04:31 +0200 Subject: [PATCH] android assets loading done --- Makefile | 11 +++++++++++ Makefile.android | 10 +++++++--- RUN | 4 ++++ src/android/assfile.c | 2 +- src/android/logger.c | 2 +- src/android/main.c | 15 ++++++++------- src/demo.c | 1 + 7 files changed, 33 insertions(+), 12 deletions(-) create mode 100755 RUN diff --git a/Makefile b/Makefile index c42664e..21c5164 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,17 @@ libs: clean-libs: $(MAKE) -C libs clean +.PHONY: android +android: + $(MAKE) -f Makefile.android + +.PHONY: android-clean +android-clean: + $(MAKE) -f Makefile.android clean + +.PHONY: android-libs +android-libs: + $(MAKE) -f Makefile.android libs .PHONY: cross cross: diff --git a/Makefile.android b/Makefile.android index cf88345..f3b75eb 100644 --- a/Makefile.android +++ b/Makefile.android @@ -25,7 +25,7 @@ libdir = -Llibs/android CC = $(TC)clang CFLAGS = $(CCSYSROOT) $(ISYS) $(warn) $(dbg) $(opt) $(def) $(incdir) -fPIC -fcommon -MMD -LDFLAGS = $(LDSYSROOT) $(libdir) -landroid -llog -lEGL -lGLESv2 -limago +LDFLAGS = $(LDSYSROOT) $(libdir) -lm -landroid -llog -lEGL -lGLESv2 -limago $(name).apk: $(name).aligned.apk keystore.jks apksigner sign --ks keystore.jks --ks-key-alias androidkey --ks-pass pass:android --key-pass pass:android --out $@ $< @@ -42,10 +42,10 @@ $(name).unsigned.apk: $(lib_so) AndroidManifest.xml mkdir -p apkbuild/assets cp -r data apkbuild/assets cp -r sdr apkbuild/assets - aapt package -f -v -F $@ -I $(PLATFORM_JAR) -M AndroidManifest.xml apkbuild + aapt package -f -F $@ -I $(PLATFORM_JAR) -M AndroidManifest.xml apkbuild $(lib_so): $(obj) Makefile.android - $(CC) -o $@ -shared $(obj) $(LDFLAGS) + $(CC) -o $@ -shared -Wl,-soname,$(lib_so) $(obj) $(LDFLAGS) -include $(dep) @@ -84,3 +84,7 @@ run: .PHONY: stop stop: adb shell am force-stop $(pkg) + +.PHONY: logcat +logcat: + adb logcat $(name):V AndroidRuntime:V DEBUG:V '*:S' diff --git a/RUN b/RUN new file mode 100755 index 0000000..cffff37 --- /dev/null +++ b/RUN @@ -0,0 +1,4 @@ +#!/bin/sh + +make -f Makefile.android install && \ + make -f Makefile.android run diff --git a/src/android/assfile.c b/src/android/assfile.c index ec3d0f9..d5ce9de 100644 --- a/src/android/assfile.c +++ b/src/android/assfile.c @@ -4,7 +4,7 @@ #include "assfile.h" #include "android_native_app_glue.h" -struct android_app *app; /* defined in android/amain.c */ +extern struct android_app *app; /* defined in android/main.c */ static int putback_buf = -1; diff --git a/src/android/logger.c b/src/android/logger.c index 8f6ddeb..20ef008 100644 --- a/src/android/logger.c +++ b/src/android/logger.c @@ -6,7 +6,7 @@ #include "logger.h" #ifndef APP_NAME -#define APP_NAME "xmas_inferno" +#define APP_NAME "andemo" #endif static void *thread_func(void *arg); diff --git a/src/android/main.c b/src/android/main.c index 0e40962..8c12596 100644 --- a/src/android/main.c +++ b/src/android/main.c @@ -12,11 +12,12 @@ static int handle_touch_input(struct android_app *app, AInputEvent *ev); static int init_gl(void); static void destroy_gl(void); -static struct android_app *app; +struct android_app *app; + static EGLDisplay dpy; static EGLSurface surf; static EGLContext ctx; -static int running; +static int init_done, paused; static int width, height; @@ -43,7 +44,7 @@ void android_main(struct android_app *app_ptr) if(app->destroyRequested) { return; } - if(running) { + if(init_done && !paused) { demo_display(); eglSwapBuffers(dpy, surf); } @@ -56,10 +57,10 @@ static void handle_command(struct android_app *app, int32_t cmd) switch(cmd) { case APP_CMD_PAUSE: - running = 0; /* TODO: handle timers */ + paused = 1; /* TODO: handle timers */ break; case APP_CMD_RESUME: - running = 1; + paused = 0; break; case APP_CMD_INIT_WINDOW: @@ -70,11 +71,11 @@ static void handle_command(struct android_app *app, int32_t cmd) exit(1); } demo_reshape(width, height); - running = 1; + init_done = 1; break; case APP_CMD_TERM_WINDOW: - running = 0; + init_done = 0; demo_cleanup(); destroy_gl(); break; diff --git a/src/demo.c b/src/demo.c index 68068b8..1614426 100644 --- a/src/demo.c +++ b/src/demo.c @@ -1,3 +1,4 @@ +#include #include "demo.h" #include "opengl.h" #include "sanegl.h" -- 1.7.10.4