aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRami Santina <[email protected]>2011-10-06 20:21:31 +0300
committerRami Santina <[email protected]>2011-10-06 20:21:31 +0300
commitfe8e357ac03d8dd5e244879647fcec7fca60dedc (patch)
tree9f45329f07d379902dcc9c62c630f7972f96b73b
parent25204678f889de889a6b23c170e17bd7f13d2c01 (diff)
parentfa7627f623141c6fa15856c74d26c8ffe82550d0 (diff)
Merge branch 'master' of git://github.com/sgothel/jogl
-rw-r--r--make/resources/android/AndroidManifest-launcher.xml15
-rw-r--r--make/resources/android/res-launcher/values/colors.xml6
-rw-r--r--make/resources/android/res-launcher/values/strings.xml2
-rw-r--r--make/resources/android/res-launcher/values/styles.xml20
-rwxr-xr-xmake/scripts/tests.sh4
-rw-r--r--src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java9
-rw-r--r--src/android/com/jogamp/android/launcher/NEWTLauncherGearsES2TransActivity.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java10
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java10
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java145
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java41
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java6
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java77
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java2
25 files changed, 334 insertions, 129 deletions
diff --git a/make/resources/android/AndroidManifest-launcher.xml b/make/resources/android/AndroidManifest-launcher.xml
index e48b61e45..88abc8ba5 100644
--- a/make/resources/android/AndroidManifest-launcher.xml
+++ b/make/resources/android/AndroidManifest-launcher.xml
@@ -3,6 +3,7 @@
sharedUserId="com.jogamp.Community"
package="com.jogamp.android.launcher">
+ <uses-permission android:name="android.permission.INTERNET" /> <!-- required for NV's perfhud -->
<uses-sdk android:minSdkVersion="9" />
<uses-library android:name="com.jogamp.common" android:required="true" />
<uses-library android:name="javax.media.opengl" android:required="true" />
@@ -69,6 +70,20 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="com.jogamp.android.launcher.NEWTLauncherGearsES2TransActivity"
+ android:finishOnTaskLaunch="true"
+ android:launchMode="standard"
+ android:configChanges="keyboardHidden|orientation"
+ android:label="@string/activity_gearses2t_name"
+ android:description="@string/activity_gearses2t_descr"
+ android:exported="true"
+ android:theme="@style/Theme.Transparent"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
<activity android:name="com.jogamp.android.launcher.NEWTLauncherGraphUI1pActivity"
android:finishOnTaskLaunch="true"
android:launchMode="standard"
diff --git a/make/resources/android/res-launcher/values/colors.xml b/make/resources/android/res-launcher/values/colors.xml
new file mode 100644
index 000000000..f4d188b25
--- /dev/null
+++ b/make/resources/android/res-launcher/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <drawable name="screen_background_black">#ff000000</drawable>
+ <drawable name="translucent_background">#e0000000</drawable>
+ <drawable name="transparent_background">#00000000</drawable>
+</resources>
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 @@
<string name="activity_gearses1_descr">GearsES1</string>
<string name="activity_gearses2_name">GearsES2</string>
<string name="activity_gearses2_descr">GearsES2</string>
+ <string name="activity_gearses2t_name">GearsES2T</string>
+ <string name="activity_gearses2t_descr">GearsES2T</string>
<string name="activity_graphui1p_name">GraphUI1p</string>
<string name="activity_graphui1p_descr">GraphUI 1-pass</string>
<string name="activity_graphui2p_name">GraphUI2p</string>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="Theme" parent="android:Theme">
+ </style>
+
+ <style name="Theme.Translucent" parent="android:style/Theme.Translucent">
+ <item name="android:windowBackground">@drawable/translucent_background</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:colorForeground">#fff</item>
+ </style>
+
+ <style name="Theme.Transparent">
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
+ <item name="android:windowBackground">@drawable/transparent_background</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:colorForeground">#fff</item>
+ </style>
+
+</resources>
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index fdba483e6..69068a23a 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -167,7 +167,7 @@ function testawtmt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
@@ -250,7 +250,7 @@ function testawtmt() {
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 $*
-testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $*
+#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
index b79be888f..3120fc73e 100644
--- a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
+++ b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java
@@ -64,8 +64,8 @@ public abstract class NEWTLauncherActivity extends Activity {
// System.setProperty("jogl.debug", "all");
// System.setProperty("jogl.debug.GLProfile", "true");
- // System.setProperty("jogl.debug.GLDrawable", "true");
- // System.setProperty("jogl.debug.GLContext", "true");
+ System.setProperty("jogl.debug.GLDrawable", "true");
+ System.setProperty("jogl.debug.GLContext", "true");
System.setProperty("jogl.debug.GLSLCode", "true");
System.setProperty("jogl.debug.CapabilitiesChooser", "true");
@@ -107,11 +107,6 @@ public abstract class NEWTLauncherActivity extends Activity {
throw e;
}
- // Make window fullscreen
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
callMethod(activityObject, mSetIsInvokedByExternalActivity, this);
callMethod(activityObject, mOnCreate, savedInstanceState);
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/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
index 9ccd38bf1..747dd5c49 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -39,6 +39,8 @@ import java.util.*;
import javax.media.opengl.*;
+import com.jogamp.common.nio.Buffers;
+
public class ShaderUtil {
static abstract class Impl {
public abstract String getShaderInfoLog(GL gl, int shaderObj);
@@ -237,11 +239,11 @@ public class ShaderUtil {
throw new GLException("No sources specified");
}
- int[] lengths = new int[count];
+ IntBuffer lengths = Buffers.newDirectIntBuffer(count);
for(int i=0; i<count; i++) {
- lengths[i] = source[i].length();
+ lengths.put(i, source[i].length());
}
- gl.glShaderSource(shader, count, source, lengths, 0);
+ gl.glShaderSource(shader, count, source, lengths);
}
public void shaderSource(GL _gl, IntBuffer shaders, java.lang.String[][] sources)
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 36a93f348..8c1cf882c 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -301,15 +301,21 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
if(0<=nativeVisualID) {
+ List/*<EGLGLCapabilities>*/ removedCaps = new ArrayList();
for(int i=0; i<availableCaps.size(); ) {
EGLGLCapabilities ecap = (EGLGLCapabilities) availableCaps.get(i);
if(ecap.getNativeVisualID()!=nativeVisualID) {
- availableCaps.remove(i);
+ removedCaps.add(availableCaps.remove(i));
} else {
i++;
}
}
- if(DEBUG) {
+ if(0==availableCaps.size()) {
+ availableCaps = removedCaps;
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID ("+nativeVisualID+") no config found, revert to all");
+ }
+ } else if(DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID ("+nativeVisualID+") got configs: "+availableCaps.size());
}
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index f2012215e..00911443a 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -288,9 +288,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
}
- // always flag visible,
- // allowing to retry if visible && !isNativeValid()
- visible = true;
}
} finally {
if(null!=parentWindow) {
@@ -699,6 +696,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
nativeWindowCreated = createNative();
madeVisible = nativeWindowCreated;
}
+ // always flag visible, allowing a retry ..
+ WindowImpl.this.visible = true;
} else if(WindowImpl.this.visible != visible) {
if(isNativeValid()) {
setVisibleImpl(visible, x, y, width, height);
@@ -745,11 +744,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void setVisible(boolean visible) {
- if( !isNativeValid() && visible && 0>=width*height ) {
- // fast-path: not realized yet, make visible, but zero size
- return;
- }
-
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
Thread.dumpStack();
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index b9301b05a..cd3cb489f 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
@@ -57,6 +57,8 @@ import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback2;
import android.view.SurfaceView;
import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
static {
@@ -113,24 +115,21 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
public static int getFormat(CapabilitiesImmutable rCaps) {
int fmt = PixelFormat.UNKNOWN;
- /*
- if(rCaps.getAlphaBits()==0) {
- fmt = PixelFormat.RGB_565;
- } else {
- fmt = PixelFormat.RGBA_5551;
- } */
- if(rCaps.getRedBits()<=5 &&
+ if(!rCaps.isBackgroundOpaque()) {
+ fmt = PixelFormat.TRANSLUCENT;
+ } else if(rCaps.getRedBits()<=5 &&
rCaps.getGreenBits()<=6 &&
rCaps.getBlueBits()<=5 &&
rCaps.getAlphaBits()==0) {
fmt = PixelFormat.RGB_565;
- } else
- if(rCaps.getRedBits()<=5 &&
+ }
+ /* else if(rCaps.getRedBits()<=5 &&
rCaps.getGreenBits()<=5 &&
rCaps.getBlueBits()<=5 &&
rCaps.getAlphaBits()==1) {
fmt = PixelFormat.RGBA_5551; // FIXME: Supported ?
- } else {
+ } */
+ else {
fmt = PixelFormat.RGBA_8888;
}
Log.d(MD.TAG, "getFormat: requested: "+rCaps);
@@ -159,28 +158,42 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
@Override
protected void instantiationFinished() {
- nsv = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext());
+ androidView = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext());
AndroidEvents ae = new AndroidEvents();
- nsv.setOnTouchListener(ae);
- nsv.setClickable(false);
+ androidView.setOnTouchListener(ae);
+ androidView.setClickable(false);
// nsv.setOnKeyListener(ae);
- SurfaceHolder sh = nsv.getHolder();
+ SurfaceHolder sh = androidView.getHolder();
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(getPixelFormat(requestedCaps)); // n/a at this moment
// sh.setFormat(PixelFormat.RGBA_5551);
// sh.setFormat(PixelFormat.RGBA_8888);
+ sh.setFormat(getFormat(getRequestedCapabilities()));
// setType is not needed for SDK 2.0 or newer. Uncomment this
// statement if back-porting this code to older SDKs.
- sh.setFormat(getFormat(getRequestedCapabilities()));
// sh.setType(SurfaceHolder.SURFACE_TYPE_GPU);
// sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
+
+ // default size -> TBD !
+ this.width = 0;
+ this.height = 0;
}
-
- public SurfaceView getView() { return nsv; }
+ public SurfaceView getAndroidView() { return androidView; }
+
+ public void setAndroidWindow(android.view.Window window) {
+ System.err.println("setandroidWindow: "+window+", "+width+"x"+height);
+ androidWindow = window;
+ androidWindowConfigurationPreCreate();
+ if(width>0 && height>0 && !isFullscreen()) {
+ if(null != androidWindow) {
+ androidWindow.setLayout(width, height);
+ }
+ }
+ }
+ public android.view.Window getAndroidWindow() { return androidWindow; }
@Override
protected boolean canCreateNativeImpl() {
@@ -202,12 +215,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
}
final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice();
- // final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(eglDevice)
- // .chooseGraphicsConfiguration(capsByFormat, getRequestedCapabilities(), capabilitiesChooser, getScreen().getGraphicsScreen());
final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(),
- (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(),
- format); // JAU FIXME: filter out by android visualID ??
+ (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), format);
if (eglConfig == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
@@ -219,8 +229,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID.get(0)));
- // JAU FIXME
- setSurfaceVisualID0(surfaceHandle, nativeVisualID.get(0));
+ if(nativeVisualID.get(0)>0) {
+ setSurfaceVisualID0(surfaceHandle, nativeVisualID.get(0));
+ }
eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null);
if (EGL.EGL_NO_SURFACE==eglSurface) {
@@ -248,14 +259,22 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
protected void requestFocusImpl(boolean reparented) { }
- protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
- if(0!=getWindowHandle()) {
- if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
- if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) {
- System.err.println("reconfigureWindowImpl.setFullscreen n/a");
- return false;
- }
+ 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);
+ }
+ }
+ }
+
+ protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
+ if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
+ System.err.println("reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a");
+ return false;
}
if(width>0 || height>0) {
if(0!=getWindowHandle()) {
@@ -273,7 +292,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return true;
}
- /***
+ /**
Canvas cLock = null;
@Override
@@ -310,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) {
@@ -328,46 +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);
- 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);
-
- capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities());
- // capsByFormat = (GLCapabilitiesImmutable) fixCapsAlpha(getRequestedCapabilities());
- // capsByFormat = (GLCapabilitiesImmutable) getRequestedCapabilities();
-
- if(isVisible()) {
- setVisible(true);
- }
- Log.d(MD.TAG, "surfaceRealized: X");
- }
-
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(MD.TAG, "surfaceDestroyed");
windowDestroyNotify();
@@ -379,17 +384,18 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
}
- private MSurfaceView nsv;
+ private MSurfaceView androidView;
+ private android.view.Window androidWindow;
private int format; // stored current PixelFormat
private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat
private Surface surface = null;
private volatile long surfaceHandle = 0;
private long eglSurface = 0;
- static class MSurfaceView extends SurfaceView {
+ class MSurfaceView extends SurfaceView {
public MSurfaceView (Context ctx) {
super(ctx);
-
+ setBackgroundDrawable(null);
}
}
//----------------------------------------------------------------------
@@ -403,5 +409,4 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
protected static native int getHeight0(long surfaceHandle);
protected static native void acquire0(long surfaceHandle);
protected static native void release0(long surfaceHandle);
-
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
index 9a2a0ea2c..5e5b90770 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
@@ -40,7 +40,7 @@ import android.os.Bundle;
import android.util.Log;
public class NewtBaseActivity extends Activity {
- AndroidWindow window = null;
+ AndroidWindow newtWindow = null;
Animator animator = null;
boolean isInvokedByExternalActivity = false;
@@ -54,25 +54,39 @@ public class NewtBaseActivity extends Activity {
return null != extActivity;
}
- public void setContentView(Window window) {
- if(window instanceof GLWindow) {
- window = ((GLWindow)window).getWindow();
+ public Activity getActivity() {
+ if(isInvokedByExternalActivity) {
+ return extActivity;
+ } else {
+ return this;
+ }
+ }
+
+ public void setContentView(android.view.Window androidWindow, Window newtWindow) {
+ if(newtWindow instanceof GLWindow) {
+ newtWindow = ((GLWindow)newtWindow).getWindow();
}
- if(window instanceof AndroidWindow) {
- this.window = (AndroidWindow)window;
+ if(newtWindow instanceof AndroidWindow) {
+ this.newtWindow = (AndroidWindow)newtWindow;
+ this.newtWindow.setAndroidWindow(androidWindow);
if(isInvokedByExternalActivity) {
- extActivity.setContentView(this.window.getView());
+ extActivity.setContentView(this.newtWindow.getAndroidView());
} else {
- super.setContentView(this.window.getView());
+ super.setContentView(this.newtWindow.getAndroidView());
}
} else {
- throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+window.getClass());
+ throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass());
}
}
public void setAnimator(Animator animator) {
this.animator = animator;
}
+
+ @Override
+ public android.view.Window getWindow() {
+ return getActivity().getWindow();
+ }
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -83,7 +97,8 @@ public class NewtBaseActivity extends Activity {
jogamp.common.os.android.StaticContext.setContext(getApplicationContext());
} else {
jogamp.common.os.android.StaticContext.setContext(extActivity.getApplicationContext());
- }
+ }
+ extActivity.getWindow();
// init GLProfile
GLProfile.initSingleton(true);
@@ -142,9 +157,9 @@ public class NewtBaseActivity extends Activity {
animator.stop();
animator = null;
}
- if(null != window) {
- window.destroy();
- window = null;
+ if(null != newtWindow) {
+ newtWindow.destroy();
+ newtWindow = null;
}
if(!isInvokedByExternalActivity) {
super.onDestroy();
diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
index 9661fc7fb..ecf1f72cd 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -28,6 +28,8 @@
package jogamp.newt.driver.android.event;
+import java.awt.event.MouseEvent;
+
import com.jogamp.common.util.IntIntHashMap;
import com.jogamp.newt.Window;
@@ -163,7 +165,7 @@ public class AndroidNewtEventFactory {
(null==newtSource)?null:(Object)newtSource, event.getEventTime(),
modifiers ,
x, y, pressure, pointers, clickCount,
- 0, rotation);
+ pointers.length==1 ? MouseEvent.BUTTON1 : 0, rotation);
if(type == com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED) {
com.jogamp.newt.event.MouseEvent me2 =
@@ -172,7 +174,7 @@ public class AndroidNewtEventFactory {
(null==newtSource)?null:(Object)newtSource, event.getEventTime(),
modifiers ,
x, y, pressure, pointers, clickCount,
- 0, rotation);
+ pointers.length==1 ? MouseEvent.BUTTON1 : 0, rotation);
res = new com.jogamp.newt.event.MouseEvent[2];
res[0] = me1;
res[1] = me2;
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..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,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/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
new file mode 100644
index 000000000..84ff0a5a7
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -0,0 +1,77 @@
+/**
+ * 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.setSize(300, 300);
+ // glWindow.setFullscreen(true);
+ glWindow.setUndecorated(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");
+ }
+}
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() {
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()<duration) {