diff --git a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java
index d14a27e30..9254944a5 100644
--- a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java
+++ b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java
@@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
+import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.*;
@@ -21,7 +22,6 @@ import com.jme3.input.android.AndroidSensorJoyInput;
import com.jme3.input.controls.TouchListener;
import com.jme3.input.controls.TouchTrigger;
import com.jme3.input.event.TouchEvent;
-import com.jme3.renderer.android.AndroidGLSurfaceView;
import com.jme3.system.AppSettings;
import com.jme3.system.SystemListener;
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
@@ -195,7 +195,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
*/
protected int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
protected OGLESContext ctx;
- protected AndroidGLSurfaceView view = null;
+ protected GLSurfaceView view = null;
protected boolean isGLThreadPaused = true;
protected ImageView splashImageView = null;
protected FrameLayout frameLayout = null;
diff --git a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java
index f2ea5a4b4..9bccb5752 100644
--- a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java
+++ b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java
@@ -32,6 +32,7 @@
package com.jme3.input.android;
+import android.opengl.GLSurfaceView;
import android.os.Build;
import android.view.View;
import com.jme3.input.RawInputListener;
@@ -41,7 +42,6 @@ import com.jme3.input.event.KeyInputEvent;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.input.event.TouchEvent;
-import com.jme3.renderer.android.AndroidGLSurfaceView;
import com.jme3.system.AppSettings;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
@@ -67,7 +67,7 @@ public class AndroidInputHandler implements TouchInput {
// Internal
- private AndroidGLSurfaceView view;
+ private GLSurfaceView view;
private AndroidTouchHandler touchHandler;
private AndroidKeyHandler keyHandler;
private AndroidGestureHandler gestureHandler;
@@ -112,7 +112,7 @@ public class AndroidInputHandler implements TouchInput {
if (gestureHandler != null) {
gestureHandler.setView(view);
}
- this.view = (AndroidGLSurfaceView)view;
+ this.view = (GLSurfaceView)view;
}
public View getView() {
diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGLSurfaceView.java b/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGLSurfaceView.java
deleted file mode 100644
index b328c6b79..000000000
--- a/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGLSurfaceView.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.jme3.renderer.android;
-
-import android.content.Context;
-import android.opengl.GLSurfaceView;
-import android.util.AttributeSet;
-import java.util.logging.Logger;
-
-/**
- * AndroidGLSurfaceView
is derived from GLSurfaceView
- * @author iwgeric
- *
- */
-public class AndroidGLSurfaceView extends GLSurfaceView {
-
- private final static Logger logger = Logger.getLogger(AndroidGLSurfaceView.class.getName());
-
- public AndroidGLSurfaceView(Context ctx, AttributeSet attribs) {
- super(ctx, attribs);
- }
-
- public AndroidGLSurfaceView(Context ctx) {
- super(ctx);
- }
-
-
-}
\ No newline at end of file
diff --git a/jme3-android/src/main/java/com/jme3/system/android/AndroidTimer.java b/jme3-android/src/main/java/com/jme3/system/android/AndroidTimer.java
deleted file mode 100644
index 965895c41..000000000
--- a/jme3-android/src/main/java/com/jme3/system/android/AndroidTimer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2009-2012 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.jme3.system.android;
-
-import com.jme3.system.Timer;
-
-/**
- * AndroidTimer
is a System.nanoTime implementation of Timer
.
- */
-public class AndroidTimer extends Timer {
-
- //private static final long TIMER_RESOLUTION = 1000L;
- //private static final float INVERSE_TIMER_RESOLUTION = 1f/1000L;
- private static final long TIMER_RESOLUTION = 1000000000L;
- private static final float INVERSE_TIMER_RESOLUTION = 1f/1000000000L;
-
- private long startTime;
- private long previousTime;
- private float tpf;
- private float fps;
-
- public AndroidTimer() {
- //startTime = System.currentTimeMillis();
- startTime = System.nanoTime();
- }
-
- /**
- * Returns the time in seconds. The timer starts
- * at 0.0 seconds.
- *
- * @return the current time in seconds
- */
- @Override
- public float getTimeInSeconds() {
- return getTime() * INVERSE_TIMER_RESOLUTION;
- }
-
- public long getTime() {
- //return System.currentTimeMillis() - startTime;
- return System.nanoTime() - startTime;
- }
-
- public long getResolution() {
- return TIMER_RESOLUTION;
- }
-
- public float getFrameRate() {
- return fps;
- }
-
- public float getTimePerFrame() {
- return tpf;
- }
-
- public void update() {
- tpf = (getTime() - previousTime) * (1.0f / TIMER_RESOLUTION);
- fps = 1.0f / tpf;
- previousTime = getTime();
- }
-
- public void reset() {
- //startTime = System.currentTimeMillis();
- startTime = System.nanoTime();
- previousTime = getTime();
- }
-}
diff --git a/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java b/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java
index cf49c1cee..a01d1a480 100644
--- a/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java
+++ b/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java
@@ -47,13 +47,11 @@ import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.FrameLayout;
import com.jme3.input.*;
-import com.jme3.input.android.AndroidInput;
import com.jme3.input.android.AndroidSensorJoyInput;
import com.jme3.input.android.AndroidInputHandler;
import com.jme3.input.controls.SoftTextDialogInputListener;
import com.jme3.input.dummy.DummyKeyInput;
import com.jme3.input.dummy.DummyMouseInput;
-import com.jme3.renderer.android.AndroidGLSurfaceView;
import com.jme3.renderer.android.OGLESShaderRenderer;
import com.jme3.system.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -80,11 +78,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
protected AndroidInputHandler androidInput;
protected int minFrameDuration = 0; // No FPS cap
protected JoyInput androidSensorJoyInput = null;
- /**
- * EGL_RENDERABLE_TYPE: EGL_OPENGL_ES_BIT = OpenGL ES 1.0 |
- * EGL_OPENGL_ES2_BIT = OpenGL ES 2.0
- */
- protected int clientOpenGLESVersion = 1;
public OGLESContext() {
}
@@ -103,12 +96,17 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
*
* @return GLSurfaceView The newly created view
*/
- public AndroidGLSurfaceView createView() {
- AndroidGLSurfaceView view;
- int buildVersion = Build.VERSION.SDK_INT;
-
+ public GLSurfaceView createView() {
+ Context appContext = JmeAndroidSystem.getActivity().getApplication();
+
+ ActivityManager am = (ActivityManager) appContext.getSystemService(Context.ACTIVITY_SERVICE);
+ ConfigurationInfo info = am.getDeviceConfigurationInfo();
+ if (info.reqGlEsVersion < 0x20000) {
+ throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
+ }
+
// Start to set up the view
- view = new AndroidGLSurfaceView(JmeAndroidSystem.getActivity().getApplication());
+ GLSurfaceView view = new GLSurfaceView(appContext);
if (androidInput == null) {
androidInput = new AndroidInputHandler();
}
@@ -117,20 +115,11 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
// setEGLContextClientVersion must be set before calling setRenderer
// this means it cannot be set in AndroidConfigChooser (too late)
- int rawOpenGLESVersion = getOpenGLESVersion();
-// logger.log(Level.FINE, "clientOpenGLESVersion {0}.{1}",
-// new Object[]{clientOpenGLESVersion>>16, clientOpenGLESVersion<<16});
- if (rawOpenGLESVersion < 0x20000) {
- throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
- } else {
- clientOpenGLESVersion = 2;
- view.setEGLContextClientVersion(clientOpenGLESVersion);
- }
+ view.setEGLContextClientVersion(2);
view.setFocusableInTouchMode(true);
view.setFocusable(true);
- view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
-
+
// setFormat must be set before AndroidConfigChooser is called by the surfaceview.
// if setFormat is called after ConfigChooser is called, then execution
// stops at the setFormat call without a crash.
@@ -160,25 +149,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
// Not destroying and recreating the EGL context
// will help with resume time by reusing the existing context to avoid
// reloading all the OpenGL objects.
- if (buildVersion >= 11) {
+ if (Build.VERSION.SDK_INT >= 11) {
view.setPreserveEGLContextOnPause(true);
}
return view;
}
- /**
- * Get the OpenGL ES version
- * @return version returns the int value of the GLES version
- */
- public int getOpenGLESVersion() {
- ActivityManager am =
- (ActivityManager) JmeAndroidSystem.getActivity().getApplication().getSystemService(Context.ACTIVITY_SERVICE);
- ConfigurationInfo info = am.getDeviceConfigurationInfo();
- logger.log(Level.FINE, "OpenGL Version {0}:", info.getGlEsVersion());
- return info.reqGlEsVersion;
-// return (info.reqGlEsVersion >= 0x20000);
- }
-
+
// renderer:initialize
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig cfg) {
@@ -207,7 +184,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
}
});
- timer = new AndroidTimer();
+ timer = new NanoTimer();
renderer = new OGLESShaderRenderer();
renderer.initialize();