android assets loading done
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 26 Dec 2021 22:04:31 +0000 (00:04 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 26 Dec 2021 22:04:31 +0000 (00:04 +0200)
Makefile
Makefile.android
RUN [new file with mode: 0755]
src/android/assfile.c
src/android/logger.c
src/android/main.c
src/demo.c

index c42664e..21c5164 100644 (file)
--- 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:
index cf88345..f3b75eb 100644 (file)
@@ -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 (executable)
index 0000000..cffff37
--- /dev/null
+++ b/RUN
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+make -f Makefile.android install && \
+       make -f Makefile.android run
index ec3d0f9..d5ce9de 100644 (file)
@@ -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;
 
index 8f6ddeb..20ef008 100644 (file)
@@ -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);
index 0e40962..8c12596 100644 (file)
@@ -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;
index 68068b8..1614426 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include "demo.h"
 #include "opengl.h"
 #include "sanegl.h"