Permalink
Browse files

Merge branch 'develop' of github.com:openframeworks/openFrameworks in…

…to fix-elapsedtime-ull
  • Loading branch information...
2 parents 4225e3e + 23a4f89 commit 60146de272631d25e45b64ddc6967770b1a99615 @kylemcdonald kylemcdonald committed Nov 8, 2012
Showing with 348 additions and 582 deletions.
  1. +7 −2 addons/ofxAndroid/ofAndroidLib/src/cc/openframeworks/OFAndroid.java
  2. +54 −4 addons/ofxAndroid/ofAndroidLib/src/cc/openframeworks/OFAndroidVideoGrabber.java
  3. +3 −1 addons/ofxAndroid/src/ofAppAndroidWindow.cpp
  4. +1 −1 examples/3d/advanced3dExample/src/testApp.cpp
  5. +1 −1 examples/3d/normalsExample/src/testApp.cpp
  6. +59 −533 examples/android/androidEmptyExample/.cproject
  7. +0 −8 examples/android/androidEmptyExample/.project
  8. +54 −8 examples/android/androidEmptyExample/src/testApp.cpp
  9. +17 −4 examples/android/androidEmptyExample/src/testApp.h
  10. +1 −1 libs/openFrameworks/3d/of3dUtils.cpp
  11. +9 −4 libs/openFrameworks/3d/ofCamera.cpp
  12. +1 −0 libs/openFrameworks/3d/ofMesh.cpp
  13. +4 −3 libs/openFrameworks/3d/ofNode.cpp
  14. +4 −0 libs/openFrameworks/gl/ofFbo.cpp
  15. +37 −2 libs/openFrameworks/gl/ofGLRenderer.cpp
  16. +6 −1 libs/openFrameworks/gl/ofGLRenderer.h
  17. +25 −0 libs/openFrameworks/graphics/ofGraphics.cpp
  18. +5 −0 libs/openFrameworks/graphics/ofGraphics.h
  19. +31 −0 libs/openFrameworks/graphics/ofRendererCollection.h
  20. +7 −1 libs/openFrameworks/types/ofBaseTypes.h
  21. +1 −1 libs/openFrameworksCompiled/project/android/makefile
  22. +2 −2 libs/openFrameworksCompiled/project/linux/makefile
  23. +2 −2 libs/openFrameworksCompiled/project/linux64/makefile
  24. +8 −1 libs/openFrameworksCompiled/project/makefileCommon/Makefile.android
  25. +1 −1 libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples
  26. +2 −0 libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj
  27. +2 −1 scripts/dev/pull_and_build.sh
  28. +4 −0 scripts/osx/template/emptyExample.xcodeproj/project.pbxproj
@@ -246,12 +246,14 @@ public void resume(){
Log.i("OF","onResume");
enableTouchEvents();
mGLView.onResume();
-
+
for(OFAndroidObject object : OFAndroidObject.ofObjects){
object.onResume();
}
onResume();
+
+ if(OFAndroid.orientation!=-1) OFAndroid.setScreenOrientation(OFAndroid.orientation);
if(wl!=null) lockScreenSleep();
}
@@ -512,7 +514,10 @@ public static void setFullscreen(boolean fs){
//ofActivity.getWindow().setAttributes(attrs);
}
+
+ private static int orientation=-1;
public static void setScreenOrientation(int orientation){
+ OFAndroid.orientation = orientation;
switch(orientation){
case 0:
ofActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@@ -1095,4 +1100,4 @@ public void onDrawFrame(GL10 gl) {
static boolean initialized;
static boolean setup;
int w,h;
-}
+}
@@ -1,16 +1,24 @@
package cc.openframeworks;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import javax.microedition.khronos.opengles.GL10;
+
import android.content.Context;
+import android.app.Activity;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.hardware.Camera.Size;
+import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.OrientationEventListener;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.ViewGroup;
public class OFAndroidVideoGrabber extends OFAndroidObject implements Runnable, Camera.PreviewCallback {
@@ -28,11 +36,24 @@ public static OFAndroidVideoGrabber getInstance(int id){
return camera_instances.get(id);
}
- void setDeviceID(int id){
+ public void setDeviceID(int id){
deviceID = id;
}
- void initGrabber(int w, int h, int _targetFps){
+ public static boolean supportsTextureRendering(){
+ try {
+ Class surfaceTextureClass = Class.forName("android.graphics.SurfaceTexture");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public void initGrabber(int w, int h, int _targetFps){
+ initGrabber(w,h,_targetFps,-1);
+ }
+
+ public void initGrabber(int w, int h, int _targetFps, int texID){
if(deviceID==-1)
camera = Camera.open();
else{
@@ -60,6 +81,21 @@ void initGrabber(int w, int h, int _targetFps){
camera = Camera.open();
}
}
+
+ if(supportsTextureRendering()){
+ try {
+ Class surfaceTextureClass = Class.forName("android.graphics.SurfaceTexture");
+ Constructor constructor = surfaceTextureClass.getConstructor(int.class);
+ Object surfaceTexture = constructor.newInstance(0);
+ Method setPreviewTexture = camera.getClass().getMethod("setPreviewTexture", surfaceTextureClass);
+ setPreviewTexture.invoke(camera, surfaceTexture);
+ } catch (Exception e1) {
+ Log.e("OF","Error initializing gl surface",e1);
+ }
+ }
+
+
+
Camera.Parameters config = camera.getParameters();
Log.i("OF","Grabber supported sizes");
@@ -106,7 +142,10 @@ void initGrabber(int w, int h, int _targetFps){
targetFps = _targetFps;
Log.i("OF","camera settings: " + width + "x" + height);
- buffer = new byte[width*height*2];
+ // it actually needs (width*height) * 3/2
+ int bufferSize = width * height;
+ bufferSize = bufferSize * ImageFormat.getBitsPerPixel(config.getPreviewFormat()) / 8;
+ buffer = new byte[bufferSize];
orientationListener = new OrientationListener(OFAndroid.getContext());
orientationListener.enable();
@@ -161,7 +200,16 @@ public void appStop(){
} catch (InterruptedException e) {
Log.e("OF", "problem trying to close camera thread", e);
}
+ camera.setPreviewCallback(null);
camera.release();
+ if(supportsTextureRendering()){
+ try {
+ Class surfaceTextureClass = Class.forName("android.graphics.SurfaceTexture");
+ Method setPreviewTexture = camera.getClass().getMethod("setPreviewTexture", surfaceTextureClass);
+ setPreviewTexture.invoke(camera, (Object)null);
+ } catch (Exception e) {
+ }
+ }
orientationListener.disable();
}
}
@@ -272,10 +320,12 @@ public void onOrientationChanged(int orientation) {
private int id;
private static int nextId=0;
public static Map<Integer,OFAndroidVideoGrabber> camera_instances = new HashMap<Integer,OFAndroidVideoGrabber>();
+ //private static OFCameraSurface cameraSurface = null;
+ //private static ViewGroup rootViewGroup = null;
private boolean initialized = false;
private boolean previewStarted = false;
private Method addBufferMethod;
private OrientationListener orientationListener;
-}
+}
@@ -121,6 +121,9 @@ ofAppAndroidWindow::~ofAppAndroidWindow() {
void ofAppAndroidWindow::runAppViaInfiniteLoop(ofBaseApp * appPtr){
androidApp = dynamic_cast<ofxAndroidApp*>( appPtr );
+ if(androidApp){
+ ofxRegisterMultitouch(androidApp);
+ }
}
ofPoint ofAppAndroidWindow::getWindowSize(){
@@ -315,7 +318,6 @@ Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){
androidApp->reloadTextures();
}
ofSetStyle(ofGetStyle());
- ofSetOrientation(ofGetOrientation());
surfaceDestroyed = false;
}
@@ -292,7 +292,7 @@ void testApp::drawScene(int iCameraDraw){
// from the inverseCameraMatrix object
// to OpenGL, and apply that matrix to
// the current OpenGL transform
- glMultMatrixf(inverseCameraMatrix.getPtr());
+ ofMultMatrix( inverseCameraMatrix );
//
//--
@@ -99,7 +99,7 @@ void testApp::draw(){
mesh.drawFaces();
ofSetColor(255,255,255);
- light.customDraw();
+ light.draw();
// draw our normals, and show that they are perpendicular to the vector from the center to the vertex
Oops, something went wrong.

0 comments on commit 60146de

Please sign in to comment.