# HG changeset patch # User John Tsiombikas # Date 1432516478 -10800 # Node ID 9fc7d52f578d8a27fe84fbfc77c9b8dbd87e12e2 # Parent 7f6e6eb3d20e12de3e6b81cbd43c643c33f3aaa9 FINALLY I'm getting an image out of the camera diff -r 7f6e6eb3d20e -r 9fc7d52f578d src/android/MainActivity.java --- a/src/android/MainActivity.java Sat May 23 23:14:44 2015 +0300 +++ b/src/android/MainActivity.java Mon May 25 04:14:38 2015 +0300 @@ -15,6 +15,7 @@ public class MainActivity extends NativeActivity { public static String tag = "photoshoot3d"; + public static boolean frame_pending; public static void foo() { @@ -30,6 +31,10 @@ int num_cams = Camera.getNumberOfCameras(); Log.i(tag, "Found " + num_cams + " cameras"); + if(num_cams < 1) { + return -1; + } + for(int i=0; iCallStaticVoidMethod(jni, activity_class, method); - return; + return 0; } int cam_is_capturing(void) diff -r 7f6e6eb3d20e -r 9fc7d52f578d src/camera.h --- a/src/camera.h Sat May 23 23:14:44 2015 +0300 +++ b/src/camera.h Mon May 25 04:14:38 2015 +0300 @@ -19,7 +19,7 @@ int cam_start_video(void); int cam_stop_video(void); -void cam_update(void); +int cam_update(void); int cam_is_capturing(void); int cam_take_picture(void); diff -r 7f6e6eb3d20e -r 9fc7d52f578d src/game.c --- a/src/game.c Sat May 23 23:14:44 2015 +0300 +++ b/src/game.c Mon May 25 04:14:38 2015 +0300 @@ -5,7 +5,7 @@ #include "game.h" #include "camera.h" -static void draw_quad(float sz); +static void draw_quad(float hsz, float vsz); static int win_width, win_height; @@ -17,17 +17,20 @@ //glEnable(GL_LIGHTING); glClearColor(0.4, 0.4, 0.4, 1); + + cam_start_video(); return 0; } void game_shutdown(void) { + cam_shutdown(); } void game_display(unsigned long msec) { unsigned int tex = cam_texture(); - //cam_update(); + cam_update(); //float tsec = (float)msec / 1000.0f; @@ -40,21 +43,23 @@ if(tex) { glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex); glEnable(GL_TEXTURE_EXTERNAL_OES); + } - draw_quad(0.5); + draw_quad(0.5 * 1.33333, 0.5); + if(tex) { glDisable(GL_TEXTURE_EXTERNAL_OES); } } -static void draw_quad(float sz) +static void draw_quad(float hsz, float vsz) { static const float varr[] = {-1, -1, 1, -1, 1, 1, -1, 1}; - static const float tcarr[] = {0, 0, 1, 0, 1, 1, 0, 1}; - static const float colarr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + static const float tcarr[] = {0, 1, 1, 1, 1, 0, 0, 0}; + static const float colarr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; glPushMatrix(); - glScalef(sz, sz, sz); + glScalef(hsz, vsz, 1); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -62,9 +67,9 @@ glVertexPointer(2, GL_FLOAT, 0, varr); glTexCoordPointer(2, GL_FLOAT, 0, tcarr); - glColorPointer(3, GL_FLOAT, 0, colarr); + glColorPointer(4, GL_FLOAT, 0, colarr); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);