From 48113ca0298ca79473dca73b85ebd4ef1a9cd078 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 6 Oct 2011 03:59:43 +0200 Subject: NEWT/Android: Move fullscreen setting to AndroidWindow ; Cleanup AndroidWindow --- src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java | 3 ++- src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java | 2 +- src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java | 3 ++- src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java | 3 ++- src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java | 3 ++- src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java | 2 +- src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java index b36f567bb..442400868 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java @@ -57,7 +57,8 @@ public class NEWTElektronActivity extends NewtBaseActivity { // caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new ElektronenMultiplizierer()); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java index 897df89cd..bc4e7d394 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java @@ -54,7 +54,7 @@ public class NEWTGearsES1Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES1(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index b19c12d4a..164857760 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -54,7 +54,8 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index 99de90f2a..83f35879b 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -57,7 +57,8 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity { caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(0)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index c627ce725..17924d43d 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -58,7 +58,8 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity { caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java index bf5fcce49..6fc3a46d6 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java @@ -54,7 +54,7 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES1(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java index fcffc5244..e9ef981b8 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java @@ -54,7 +54,8 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES2(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { -- cgit v1.2.3 From 78bbe7c3217046372c88d82d75d1d1c5c04a4a6e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 6 Oct 2011 04:04:53 +0200 Subject: ES2 Test Update: Add RedSquareES2 mouse events, toggle: fullscreen / SwapInterval - turns out that on android, we cannot run w/o v-sync .. (?) --- .../test/junit/jogl/demos/es1/RedSquareES1.java | 6 +++ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 15 +++--- .../test/junit/jogl/demos/es2/RedSquareES2.java | 53 +++++++++++++++++++--- .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 2 +- 4 files changed, 61 insertions(+), 15 deletions(-) (limited to 'src/test/com/jogamp/opengl') 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 0484b6a77..8d1c708af 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 @@ -71,6 +71,12 @@ public class RedSquareES1 implements GLEventListener { } catch (Exception e) {e.printStackTrace();} } + System.err.println(Thread.currentThread()+"Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); + System.err.println(Thread.currentThread()+"INIT GL IS: " + gl.getClass().getName()); + System.err.println(Thread.currentThread()+"GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println(Thread.currentThread()+"GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println(Thread.currentThread()+"GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + 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)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index d0eb3b183..9bff38fce 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -56,7 +56,9 @@ public class GearsES2 implements GLEventListener { private GearsObjectES2 gear1=null, gear2=null, gear3=null; private float angle = 0.0f; private int swapInterval = 0; - private boolean initialized = false; + // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); + private MouseListener gearsMouse = new GearsMouseAdapter(); + private KeyListener gearsKeys = new GearsKeyAdapter(); private int prevMouseX, prevMouseY; @@ -92,7 +94,6 @@ public class GearsES2 implements GLEventListener { public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.init ..."); - initialized = true; GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); @@ -156,10 +157,6 @@ public class GearsES2 implements GLEventListener { System.err.println("gear3 reused: "+gear3); } - // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - MouseListener gearsMouse = new GearsMouseAdapter(); - KeyListener gearsKeys = new GearsKeyAdapter(); - if (drawable instanceof Window) { Window window = (Window) drawable; window.addMouseListener(gearsMouse); @@ -197,7 +194,11 @@ public class GearsES2 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.dispose ... "); - initialized = false; + if (drawable instanceof Window) { + Window window = (Window) drawable; + window.removeMouseListener(gearsMouse); + window.removeKeyListener(gearsKeys); + } GL2ES2 gl = drawable.getGL().getGL2ES2(); st.useProgram(gl, false); gear1.destroy(gl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 81c97d861..d06c6da97 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -27,6 +27,9 @@ */ package com.jogamp.opengl.test.junit.jogl.demos.es2; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -34,8 +37,10 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLRunnable; import javax.media.opengl.GLUniformData; public class RedSquareES2 implements GLEventListener { @@ -46,6 +51,8 @@ public class RedSquareES2 implements GLEventListener { GLArrayDataServer colors ; long t0; private int swapInterval = 0; + MyMouseAdapter myMouse = new MyMouseAdapter(); + GLWindow glWindow = null; public RedSquareES2(int swapInterval) { this.swapInterval = swapInterval; @@ -64,7 +71,6 @@ public class RedSquareES2 implements GLEventListener { System.err.println(Thread.currentThread()+"GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); System.err.println(Thread.currentThread()+"GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); System.err.println(Thread.currentThread()+"GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile()); System.err.println(Thread.currentThread()+" GL:" + gl); @@ -104,8 +110,8 @@ public class RedSquareES2 implements GLEventListener { // Allocate Color Array colors= GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); - colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1); - colors.putf(0); colors.putf(0); colors.putf(1); colors.putf(1); + colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1); + colors.putf(0); colors.putf(0); colors.putf(1); colors.putf(1); colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1); colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1); colors.seal(gl, true); @@ -117,6 +123,10 @@ public class RedSquareES2 implements GLEventListener { gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); + if (glad instanceof GLWindow) { + glWindow = (GLWindow) glad; + glWindow.addMouseListener(myMouse); + } t0 = System.currentTimeMillis(); System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); } @@ -124,7 +134,6 @@ public class RedSquareES2 implements GLEventListener { public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES2 gl = glad.getGL().getGL2ES2(); - gl.setSwapInterval(swapInterval); st.useProgram(gl, true); // Set location in front of camera @@ -132,7 +141,7 @@ public class RedSquareES2 implements GLEventListener { pmvMatrix.glLoadIdentity(); pmvMatrix.gluPerspective(45.0F, (float) width / (float) height, 1.0F, 100.0F); //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f); - gl.glUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN"); } @@ -141,8 +150,8 @@ public class RedSquareES2 implements GLEventListener { long t1 = System.currentTimeMillis(); GL2ES2 gl = glad.getGL().getGL2ES2(); - st.useProgram(gl, true); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + st.useProgram(gl, true); // One rotation every four seconds pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); @@ -150,7 +159,8 @@ public class RedSquareES2 implements GLEventListener { float ang = ((float) (t1 - t0) * 360.0F) / 4000.0F; pmvMatrix.glRotatef(ang, 0, 0, 1); pmvMatrix.glRotatef(ang, 0, 1, 0); - gl.glUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + // Draw a square vertices.enableBuffer(gl, true); colors.enableBuffer(gl, true); @@ -162,6 +172,10 @@ public class RedSquareES2 implements GLEventListener { public void dispose(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); + if (null != glWindow) { + glWindow.removeMouseListener(myMouse); + glWindow = null; + } GL2ES2 gl = glad.getGL().getGL2ES2(); st.destroy(gl); st = null; @@ -169,4 +183,29 @@ public class RedSquareES2 implements GLEventListener { pmvMatrix = null; System.err.println(Thread.currentThread()+" RedSquareES2.dispose FIN"); } + + class MyMouseAdapter extends MouseAdapter { + public void mouseClicked(MouseEvent e) { + System.err.println(e); + if(null != glWindow && e.getSource() == glWindow.getWindow()) { + if(e.getX() < glWindow.getWidth()/2) { + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("setFullscreen: "+glWindow.isFullscreen()); + } else { + glWindow.invoke(false, new GLRunnable() { + public boolean run(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + gl.setSwapInterval(gl.getSwapInterval()<=0?1:0); + System.err.println("setSwapInterval: "+gl.getSwapInterval()); + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + return true; + } + }); + } + } + } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index b83bdb45d..63ec215fc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -103,7 +103,7 @@ public class TestRedSquareES2NEWT extends UITestCase { glWindow.setSize(width, height); glWindow.setVisible(true); - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(60, System.err); animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 6 Oct 2011 04:47:07 +0200 Subject: NEWT/Android: Add TRANSLUCENT feature / Demo: 'GearsES2T' --- .../resources/android/AndroidManifest-launcher.xml | 14 ++++ .../android/res-launcher/values/colors.xml | 6 ++ .../android/res-launcher/values/strings.xml | 2 + .../android/res-launcher/values/styles.xml | 20 ++++++ .../NEWTLauncherGearsES2TransActivity.java | 15 +++++ .../jogamp/newt/driver/android/AndroidWindow.java | 9 ++- .../opengl/test/android/NEWTGearsES2Activity.java | 2 +- .../test/android/NEWTGearsES2TransActivity.java | 75 ++++++++++++++++++++++ 8 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 make/resources/android/res-launcher/values/colors.xml create mode 100644 make/resources/android/res-launcher/values/styles.xml create mode 100644 src/android/com/jogamp/android/launcher/NEWTLauncherGearsES2TransActivity.java create mode 100644 src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java (limited to 'src/test/com/jogamp/opengl') diff --git a/make/resources/android/AndroidManifest-launcher.xml b/make/resources/android/AndroidManifest-launcher.xml index 9166dd3c4..88abc8ba5 100644 --- a/make/resources/android/AndroidManifest-launcher.xml +++ b/make/resources/android/AndroidManifest-launcher.xml @@ -70,6 +70,20 @@ + + + + + + + + #ff000000 + #e0000000 + #00000000 + diff --git a/make/resources/android/res-launcher/values/strings.xml b/make/resources/android/res-launcher/values/strings.xml index f4b558df3..8b6928d9c 100644 --- a/make/resources/android/res-launcher/values/strings.xml +++ b/make/resources/android/res-launcher/values/strings.xml @@ -11,6 +11,8 @@ GearsES1 GearsES2 GearsES2 + GearsES2T + GearsES2T GraphUI1p GraphUI 1-pass GraphUI2p diff --git a/make/resources/android/res-launcher/values/styles.xml b/make/resources/android/res-launcher/values/styles.xml new file mode 100644 index 000000000..5b7eb7e2e --- /dev/null +++ b/make/resources/android/res-launcher/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherGearsES2TransActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherGearsES2TransActivity.java new file mode 100644 index 000000000..c55620f4c --- /dev/null +++ b/src/android/com/jogamp/android/launcher/NEWTLauncherGearsES2TransActivity.java @@ -0,0 +1,15 @@ +package com.jogamp.android.launcher; + +public class NEWTLauncherGearsES2TransActivity extends NEWTLauncherActivity { + static String demo = "com.jogamp.opengl.test.android.NEWTGearsES2TransActivity"; + static String pkg = "com.jogamp.opengl.test"; + + @Override + public String getUserActivityName() { + return demo; + } + @Override + public String getUserPackageName() { + return pkg; + } +} diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index c5019bf63..2c7031dae 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -115,7 +115,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { public static int getFormat(CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; - if(rCaps.getRedBits()<=5 && + if(!rCaps.isBackgroundOpaque()) { + fmt = PixelFormat.TRANSLUCENT; + } else if(rCaps.getRedBits()<=5 && rCaps.getGreenBits()<=6 && rCaps.getBlueBits()<=5 && rCaps.getAlphaBits()==0) { @@ -313,7 +315,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { public void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height); - surfaceRealized(holder); + // surfaceRealized(holder); Log.d(MD.TAG, "surfaceCreated: X"); } @@ -389,7 +391,8 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { class MSurfaceView extends SurfaceView { public MSurfaceView (Context ctx) { - super(ctx); + super(ctx); + setBackgroundDrawable(null); } } //---------------------------------------------------------------------- diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 164857760..939bfa210 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -54,7 +54,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - glWindow.setFullscreen(true); + glWindow.setFullscreen(true); setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(1)); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java new file mode 100644 index 000000000..1862b1ba1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -0,0 +1,75 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community 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. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import jogamp.newt.driver.android.NewtBaseActivity; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.opengl.GLWindow; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +import android.os.Bundle; +import android.util.Log; + +public class NEWTGearsES2TransActivity extends NewtBaseActivity { + static String TAG = "NEWTGearsES2TransActivity"; + + @Override + public void onCreate(Bundle savedInstanceState) { + Log.d(TAG, "onCreate - 0"); + super.onCreate(savedInstanceState); + + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + caps.setBackgroundOpaque(false); + Log.d(TAG, "req caps: "+caps); + GLWindow glWindow = GLWindow.create(caps); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); + + glWindow.addGLEventListener(new GearsES2(1)); + glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { + public void screenModeChangeNotify(ScreenMode sm) { } + public void screenModeChanged(ScreenMode sm, boolean success) { + System.err.println("ScreenMode Changed: "+sm); + } + }); + glWindow.setVisible(true); + Animator animator = new Animator(glWindow); + animator.setUpdateFPSFrames(60, System.err); + setAnimator(animator); + + Log.d(TAG, "onCreate - X"); + } +} -- cgit v1.2.3 From fa7627f623141c6fa15856c74d26c8ffe82550d0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 6 Oct 2011 05:51:48 +0200 Subject: NEWT/Android: respect isUndecorated() and custom window size. TODO: custom position and change position ?! --- .../jogamp/newt/driver/android/AndroidWindow.java | 77 +++++++++++----------- .../test/android/NEWTGearsES2TransActivity.java | 4 +- 2 files changed, 43 insertions(+), 38 deletions(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index 2c7031dae..cd3cb489f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -175,13 +175,23 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { // statement if back-porting this code to older SDKs. // sh.setType(SurfaceHolder.SURFACE_TYPE_GPU); // sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL); + + // default size -> TBD ! + this.width = 0; + this.height = 0; } public SurfaceView getAndroidView() { return androidView; } public void setAndroidWindow(android.view.Window window) { + System.err.println("setandroidWindow: "+window+", "+width+"x"+height); androidWindow = window; - androidSetupFullscreen(); + androidWindowConfigurationPreCreate(); + if(width>0 && height>0 && !isFullscreen()) { + if(null != androidWindow) { + androidWindow.setLayout(width, height); + } + } } public android.view.Window getAndroidWindow() { return androidWindow; } @@ -249,11 +259,15 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { protected void requestFocusImpl(boolean reparented) { } - protected void androidSetupFullscreen() { - if( null != androidWindow && isFullscreen() ) { - androidWindow.requestFeature(Window.FEATURE_NO_TITLE); - androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); + protected void androidWindowConfigurationPreCreate() { + if( null != androidWindow) { + if( isFullscreen() || isUndecorated() ) { + androidWindow.requestFeature(Window.FEATURE_NO_TITLE); + } + if( isFullscreen() ) { + androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } } } @@ -315,8 +329,6 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { public void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height); - // surfaceRealized(holder); - Log.d(MD.TAG, "surfaceCreated: X"); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { @@ -333,43 +345,34 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { } getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event + if(0>x || 0>y) { + x = 0; + y = 0; + positionChanged(false, 0, 0); + } + if(0 == surfaceHandle) { - surfaceRealized(holder); - } else { - if(0>x || 0>y) { - x = 0; - y = 0; - positionChanged(false, 0, 0); + surface = holder.getSurface(); + surfaceHandle = getSurfaceHandle0(surface); + acquire0(surfaceHandle); + format = getSurfaceVisualID0(surfaceHandle); + capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); + sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false); + + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ + ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ + ", "+x+"/"+y+" "+width+"x"+height+", visible: "+isVisible()); + + if(isVisible()) { + setVisible(true); } + } else { sizeChanged(false, width, height, false); } windowRepaint(0, 0, width, height); Log.d(MD.TAG, "surfaceChanged: X"); } - private void surfaceRealized(SurfaceHolder holder) { - surface = holder.getSurface(); - surfaceHandle = getSurfaceHandle0(surface); - acquire0(surfaceHandle); - format = getSurfaceVisualID0(surfaceHandle); - capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); - if(0>x || 0>y) { - x = 0; - y = 0; - positionChanged(false, 0, 0); - } - sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false); - - Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ - ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ - ", "+x+"/"+y+" "+width+"x"+height); - - if(isVisible()) { - setVisible(true); - } - Log.d(MD.TAG, "surfaceRealized: X"); - } - public void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed"); windowDestroyNotify(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java index 1862b1ba1..84ff0a5a7 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -55,7 +55,9 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity { caps.setBackgroundOpaque(false); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - glWindow.setFullscreen(true); + glWindow.setSize(300, 300); + // glWindow.setFullscreen(true); + glWindow.setUndecorated(true); setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(1)); -- cgit v1.2.3