Merge branch 'master' of github.com:hrydgard/native

This commit is contained in:
Henrik Rydgard 2012-10-31 20:44:47 +01:00
commit 79972d5af3
4 changed files with 39 additions and 16 deletions

View file

@ -4,7 +4,7 @@
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
<application
android:icon="@drawable/ic_launcher" >

View file

@ -71,7 +71,7 @@ class Installation {
}
}
public class NativeActivity extends Activity {
// Remember to loadLibrary your JNI .so in a static {} block
@ -86,7 +86,6 @@ public class NativeActivity extends Activity {
public static String runCommand;
public static String commandParameter;
public static String installID;
String getApplicationLibraryDir(ApplicationInfo application) {
@ -184,10 +183,9 @@ public class NativeActivity extends Activity {
// Toast.makeText(this, "Value: " + input.getText().toString(), Toast.LENGTH_LONG).show();
}
@SuppressLint("NewApi")
public void lightsOut() {
if (Build.VERSION.SDK_INT >= 11) {
mGLSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
// mGLSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
}
@ -223,7 +221,7 @@ public class NativeActivity extends Activity {
@Override
protected void onStop() {
super.onStop();
Log.i(TAG, "onStop");
Log.i(TAG, "onStop - do nothing");
}
@Override
@ -241,8 +239,6 @@ public class NativeActivity extends Activity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (!overrideKeys())
return false;
// Eat these keys, to avoid accidental exits / other screwups.
// Maybe there's even more we need to eat on tablets?
if (keyCode == KeyEvent.KEYCODE_BACK) {

View file

@ -3,12 +3,16 @@ package com.turboviking.libnative;
// Touch- and sensor-enabled GLSurfaceView.
// Supports simple multitouch and pressure.
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.Log;
import android.view.MotionEvent;
@ -17,9 +21,29 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener {
private SensorManager mSensorManager;
private Sensor mAccelerometer;
public NativeGLView(NativeActivity activity) {
super(activity);
setEGLContextClientVersion(2);
if (Build.VERSION.SDK_INT >= 11) {
try {
Method method_setPreserveEGLContextOnPause = GLSurfaceView.class.getMethod(
"setPreserveEGLContextOnPause", new Class[] { Boolean.class });
Log.i(TAG, "Invoking setPreserveEGLContextOnPause");
method_setPreserveEGLContextOnPause.invoke(this, true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
// setEGLConfigChooser(5, 5, 5, 0, 16, 0);
// setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
mSensorManager = (SensorManager)activity.getSystemService(Activity.SENSOR_SERVICE);

View file

@ -8,24 +8,26 @@ import android.util.Log;
public class NativeRenderer implements GLSurfaceView.Renderer {
private static String TAG = "RollerballRenderer";
private static String TAG = "NativeRenderer";
NativeActivity mActivity;
NativeRenderer(NativeActivity act) {
mActivity = act;
}
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
Log.i(TAG, "onSurfaceCreated");
displayInit();
}
@Override
public void onDrawFrame(GL10 unused /*use GLES20*/) {
displayRender();
}
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
Log.i(TAG, "onSurfaceCreated - EGL context is new or was lost");
// Actually, it seems that it is here we should recreate lost GL objects.
displayInit();
}
@Override
public void onSurfaceChanged(GL10 unused, int width, int height) {
Log.i(TAG, "onSurfaceChanged");
@ -35,9 +37,10 @@ public class NativeRenderer implements GLSurfaceView.Renderer {
// NATIVE METHODS
public native void displayInit();
// Note: This also means "device lost" and you should reload
// all buffered objects.
public native void displayInit();
public native void displayResize(int w, int h);
public native void displayRender();