3dphotoshoot
diff src/android/amain.c @ 6:e31e23ead56f
GAMO TO XRISTO KAI TIN PANAGIA TOU ANDROID
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 21 May 2015 19:03:00 +0300 |
parents | 31cc6615428d |
children | 9fc7d52f578d |
line diff
1.1 --- a/src/android/amain.c Thu May 21 13:47:04 2015 +0300 1.2 +++ b/src/android/amain.c Thu May 21 19:03:00 2015 +0300 1.3 @@ -6,6 +6,7 @@ 1.4 #include "native_glue.h" 1.5 #include "logger.h" 1.6 #include "game.h" 1.7 +#include "camera.h" 1.8 #include "timer.h" 1.9 1.10 1.11 @@ -29,21 +30,7 @@ 1.12 1.13 static unsigned int camtex; 1.14 1.15 -static int call_foo() 1.16 -{ 1.17 - jmethodID foo_id; 1.18 1.19 - printf("call_foo() [activity_class=%p]\n", (void*)activity_class); 1.20 - 1.21 - if(!(foo_id = (*jni)->GetStaticMethodID(jni, activity_class, "foo", "()V"))) { 1.22 - fprintf(stderr, "static method foo not found\n"); 1.23 - return -1; 1.24 - } 1.25 - 1.26 - (*jni)->CallStaticIntMethod(jni, activity_class, foo_id); 1.27 - 1.28 - return 0; 1.29 -} 1.30 1.31 void android_main(struct android_app *app_ptr) 1.32 { 1.33 @@ -78,7 +65,6 @@ 1.34 } 1.35 1.36 if(init_done) { 1.37 - call_foo(); 1.38 game_display(get_time_msec()); 1.39 eglSwapBuffers(dpy, surf); 1.40 } 1.41 @@ -95,6 +81,8 @@ 1.42 1.43 static void handle_command(struct android_app *app, int32_t cmd) 1.44 { 1.45 + struct cam_android_platform_data cam_data; 1.46 + 1.47 switch(cmd) { 1.48 case APP_CMD_SAVE_STATE: 1.49 /* save the application state to be reloaded on restart if needed */ 1.50 @@ -105,12 +93,14 @@ 1.51 exit(1); 1.52 } 1.53 1.54 - // create the camera texture 1.55 - glGenTextures(1, &camtex); 1.56 - glBindTexture(GL_TEXTURE_EXTERNAL_OES, camtex); 1.57 - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1.58 - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1.59 - assert(glGetError() == GL_NO_ERROR); 1.60 + cam_data.vm = jvm; 1.61 + cam_data.jni = jni; 1.62 + cam_data.activity_class = activity_class; 1.63 + 1.64 + if(cam_init(&cam_data) == -1) { 1.65 + exit(1); 1.66 + } 1.67 + cam_start_video(); 1.68 1.69 /* initialize the application */ 1.70 if(game_init() == -1) { 1.71 @@ -123,15 +113,18 @@ 1.72 /* cleanup */ 1.73 init_done = 0; 1.74 game_shutdown(); 1.75 + cam_shutdown(); 1.76 destroy_gl(); 1.77 break; 1.78 1.79 case APP_CMD_GAINED_FOCUS: 1.80 /* app focused */ 1.81 + cam_start_video(); 1.82 break; 1.83 1.84 case APP_CMD_LOST_FOCUS: 1.85 /* app lost focus */ 1.86 + cam_stop_video(); 1.87 break; 1.88 1.89 case APP_CMD_WINDOW_RESIZED: