summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/resources/android/AndroidManifest-launcher.xml4
-rw-r--r--src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java3
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java11
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java41
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java21
5 files changed, 64 insertions, 16 deletions
diff --git a/make/resources/android/AndroidManifest-launcher.xml b/make/resources/android/AndroidManifest-launcher.xml
index f8bcbc139..0f4daa4f7 100644
--- a/make/resources/android/AndroidManifest-launcher.xml
+++ b/make/resources/android/AndroidManifest-launcher.xml
@@ -14,7 +14,11 @@
android:persistent="false"
>
+ <!-- We use activities with ES1 and ES2,
+ also setting the feature tag didn't fix the tegra issue.
+ Leave it here for documentation, maybe later use.
<uses-feature android:glEsVersion="0x00020000" />
+ -->
<activity android:name="com.jogamp.android.launcher.NEWTLauncherRedSquareES1Activity"
android:finishOnTaskLaunch="true"
android:launchMode="standard"
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
index ed588d894..a1f2288cf 100644
--- a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
+++ b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
@@ -63,9 +63,10 @@ public abstract class NEWTLauncherActivity extends Activity {
// System.setProperty("nativewindow.debug.GraphicsConfiguration", "true");
// System.setProperty("jogl.debug", "all");
- // System.setProperty("jogl.debug.GLProfile", "true");
+ System.setProperty("jogl.debug.GLProfile", "true");
System.setProperty("jogl.debug.GLDrawable", "true");
System.setProperty("jogl.debug.GLSLCode", "true");
+ System.setProperty("jogl.debug.GLSLState", "true");
System.setProperty("jogl.debug.DebugGL", "true");
//System.setProperty("jogl.debug.TraceGL", "true");
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 90b5a8226..f2012215e 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -180,13 +180,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
window.screen = (ScreenImpl) screen;
window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable();
window.setUndecorated(0!=parentWindowHandle);
+ window.instantiationFinished();
return window;
} catch (Throwable t) {
t.printStackTrace();
throw new NativeWindowException(t);
}
}
-
+
public static WindowImpl create(Object[] cstrArguments, Screen screen, CapabilitiesImmutable caps) {
try {
Class<?> windowClass = getWindowClass(screen.getDisplay().getType());
@@ -379,6 +380,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Window: Native implementation
//
+ /**
+ * Notifies the driver impl. that the instantiation is finished,
+ * ie. instance created and all fields set.
+ */
+ protected void instantiationFinished() {
+ // nop
+ }
+
protected boolean canCreateNativeImpl() {
return true; // default: always able to be created
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index 4d903b752..aff95ba96 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
@@ -111,6 +111,35 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return res;
}
+ public static int getFormat(CapabilitiesImmutable rCaps) {
+ int fmt = PixelFormat.UNKNOWN;
+
+ if(rCaps.getRedBits()<=5 &&
+ rCaps.getGreenBits()<=6 &&
+ rCaps.getBlueBits()<=5 &&
+ rCaps.getAlphaBits()==0) {
+ fmt = PixelFormat.RGB_565;
+ } else
+ if(rCaps.getRedBits()<=5 &&
+ rCaps.getGreenBits()<=5 &&
+ rCaps.getBlueBits()<=5 &&
+ rCaps.getAlphaBits()==1) {
+ fmt = PixelFormat.RGBA_5551;
+ } else
+ if(rCaps.getRedBits()<=8 &&
+ rCaps.getGreenBits()<=8 &&
+ rCaps.getBlueBits()<=8 &&
+ rCaps.getAlphaBits()==0) {
+ fmt = PixelFormat.RGBX_8888;
+ } else {
+ fmt = PixelFormat.RGBA_8888;
+ }
+ Log.d(MD.TAG, "getFormat: requested: "+rCaps);
+ Log.d(MD.TAG, "getFormat: returned: "+fmt);
+
+ return fmt;
+ }
+
class AndroidEvents implements /* View.OnKeyListener, */ View.OnTouchListener {
public boolean onTouch(View v, MotionEvent event) {
@@ -128,7 +157,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return false;
} */
}
- public AndroidWindow() {
+
+ @Override
+ protected void instantiationFinished() {
nsv = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext());
AndroidEvents ae = new AndroidEvents();
nsv.setOnTouchListener(ae);
@@ -138,24 +169,28 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
sh.addCallback(this);
// setFormat is done by SurfaceView in SDK 2.3 and newer. Uncomment
// this statement if back-porting to 2.2 or older:
- sh.setFormat(PixelFormat.RGB_565);
+ // sh.setFormat(PixelFormat.RGB_565);
// sh.setFormat(getPixelFormat(requestedCaps)); // n/a at this moment
// sh.setFormat(PixelFormat.RGBA_5551);
// sh.setFormat(PixelFormat.RGBA_8888);
// setType is not needed for SDK 2.0 or newer. Uncomment this
// statement if back-porting this code to older SDKs.
- sh.setType(SurfaceHolder.SURFACE_TYPE_GPU);
+ sh.setFormat(getFormat(getRequestedCapabilities()));
+ // sh.setType(SurfaceHolder.SURFACE_TYPE_GPU);
// sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
}
+
public SurfaceView getView() { return nsv; }
+ @Override
protected boolean canCreateNativeImpl() {
final boolean b = 0 != surfaceHandle;
Log.d(MD.TAG, "canCreateNativeImpl: "+b);
return b;
}
+ @Override
protected void createNativeImpl() {
Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+
", "+x+"/"+y+" "+width+"x"+height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index 38afec7f1..0484b6a77 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -5,7 +5,6 @@ import java.nio.*;
import javax.media.opengl.*;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
-import javax.media.opengl.glu.*;
import com.jogamp.opengl.util.glsl.fixedfunc.*;
@@ -21,8 +20,6 @@ public class RedSquareES1 implements GLEventListener {
long startTime = 0;
long curTime = 0;
- GLU glu = null;
-
public RedSquareES1(int swapInterval) {
this.swapInterval = swapInterval;
}
@@ -74,12 +71,9 @@ public class RedSquareES1 implements GLEventListener {
} catch (Exception e) {e.printStackTrace();}
}
- glu = GLU.createGLU(gl);
-
System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
System.err.println(Thread.currentThread()+" GL:" + gl);
System.err.println(Thread.currentThread()+" GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
- System.err.println(Thread.currentThread()+" GLU: " + glu);
// Allocate vertex arrays
colors = Buffers.newDirectFloatBuffer(16);
@@ -114,11 +108,18 @@ public class RedSquareES1 implements GLEventListener {
// Set location in front of camera
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
- glu.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
- //gl.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
- //glu.gluLookAt(0, 0, -20, 0, 0, 0, 0, 1, 0);
+ gluPerspective(gl, 45.0f, (float)width / (float)height, 1.0f, 100.0f);
+ // gl.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
System.err.println(Thread.currentThread()+" RedSquareES1.reshape FIN");
}
+
+ void gluPerspective(GL2ES1 gl, final float fovy, final float aspect, final float zNear, final float zFar) {
+ float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear;
+ float bottom=-1.0f*top;
+ float left=aspect*bottom;
+ float right=aspect*top;
+ gl.glFrustumf(left, right, bottom, top, zNear, zFar);
+ }
public void display(GLAutoDrawable drawable) {
curTime = System.currentTimeMillis();
@@ -146,8 +147,6 @@ public class RedSquareES1 implements GLEventListener {
GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
- glu.destroy();
- glu = null;
colors.clear();
colors = null;
vertices.clear();