summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-05-06 17:27:09 +0200
committerSven Gothel <[email protected]>2013-05-06 17:27:09 +0200
commit6ebf649d1b87944257fe492e0aef842d1b8debc2 (patch)
treeec2f3f0bc98903eac7285f64824cc79abc416efb /src/test/com
parent4d35eaa766071fd8dedab8b6e2ee53710831c567 (diff)
Fix Bug 600 and Bug 721: Adding support for multiple monitors w/ NEWT
- Support for all monitor devices and their available modes - X11: Use RandR 1.3 if available - Retrieve information - Changing a monitor device's mode - Support for dedicated and spannig fullscreen - See <http://jogamp.org/files/screenshots/newt-mmonitor/html/> - TODO: - X11 RandR does _not_ relayout the virtual screen size and neither the CRT's viewport. We may need to relayout them if they were covering a seamless region to achieve same experience! - OSX: No machine to attach a secondary CRT -> TEST! - Tested Manually for Regressions - Linux ARMv6hf (Rasp-Pi/BCM, Panda/X11) - Android (Huawei, Kindle) - Tested Manually and junit: - X11/Linux - NV, ATI-Catalyst w/ 2 CRTs - VBox w/ 4 CRTs - Win/Windows - NV, w/ 2 CRTs - VBox w/ 4 CRTs - X11/OpenIndiana, NV, 1 CRT
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java1
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java119
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java24
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java133
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java212
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java210
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java249
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java75
19 files changed, 916 insertions, 299 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
index 0dead125a..88cd9a719 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
@@ -32,8 +32,8 @@ 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.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer;
@@ -58,11 +58,13 @@ public class NEWTElektronActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new ElektronenMultiplizierer());
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index c020413cf..f10cfc11f 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -32,8 +32,8 @@ 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.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
@@ -63,11 +63,13 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GearsES1(-1));
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 542912c08..2e9774565 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -36,10 +36,10 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.event.MonitorEvent;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
-import com.jogamp.newt.event.ScreenModeListener;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -75,11 +75,13 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
GearsES2 demo = new GearsES2(-1);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
if( null != System.getProperty(forceKillProcessTest) ) {
Log.d(TAG, "forceKillProcessTest");
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
index 5e7a5c489..c87e66189 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
@@ -57,6 +57,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc
// props.setProperty("jogl.debug.DebugGL", "true");
// props.setProperty("jogl.debug.TraceGL", "true");
// props.setProperty("newt.debug", "all");
+ props.setProperty("newt.debug.Screen", "true");
props.setProperty("newt.debug.Window", "true");
props.setProperty("newt.debug.Window.MouseEvent", "true");
props.setProperty("newt.debug.Window.KeyEvent", "true");
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
index 18c3cb042..98e6b7c5f 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -34,8 +34,8 @@ import jogamp.newt.driver.android.NewtBaseActivity;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.event.ScreenModeListener;
+import com.jogamp.newt.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -65,11 +65,13 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GearsES2(-1));
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
Animator animator = new Animator(glWindow);
// glWindow.setSkipContextReleaseThread(animator.getThread());
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
index bbd4f9f20..42db9d8dd 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
@@ -32,8 +32,8 @@ 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.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A;
@@ -61,11 +61,13 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GPUUISceneGLListener0A(0));
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
index 20ba3f484..c68de95cc 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
@@ -33,8 +33,8 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
import com.jogamp.graph.curve.Region;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.event.ScreenModeListener;
+import com.jogamp.newt.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A;
@@ -62,11 +62,13 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT));
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
index 06ce75ac5..08fbf643d 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
@@ -32,8 +32,8 @@ 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.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
@@ -57,11 +57,13 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new RedSquareES1(-1));
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index 02e2d8f01..cefdd842b 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -32,8 +32,8 @@ 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.event.MonitorEvent;
+import com.jogamp.newt.event.MonitorModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
@@ -62,11 +62,13 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
final RedSquareES2 demo = new RedSquareES2(-1);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
- glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) { }
- public void screenModeChanged(ScreenMode sm, boolean success) {
- System.err.println("ScreenMode Changed: "+sm);
- }
+ glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
+ @Override
+ public void monitorModeChangeNotify(MonitorEvent me) { }
+ @Override
+ public void monitorModeChanged(MonitorEvent me, boolean success) {
+ System.err.println("MonitorMode Changed (success "+success+"): "+me);
+ }
});
Animator animator = new Animator(glWindow);
// animator.setRunAsFastAsPossible(true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index 50f759079..4c6cae501 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -163,13 +163,25 @@ public class TestGearsES2NEWT extends UITestCase {
});
glWindow.addKeyListener(new KeyAdapter() {
- public void keyTyped(KeyEvent e) {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() ) {
+ return;
+ }
if(e.getKeyChar()=='f') {
new Thread() {
public void run() {
final Thread t = glWindow.setExclusiveContextThread(null);
System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setFullscreen(!glWindow.isFullscreen());
+ if( glWindow.isFullscreen() ) {
+ glWindow.setFullscreen( false );
+ } else {
+ if( e.isAltDown() ) {
+ glWindow.setFullscreen( null );
+ } else {
+ glWindow.setFullscreen( true );
+ }
+ }
System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
glWindow.setExclusiveContextThread(t);
} }.start();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
index 98620e0c1..90d4a9c1f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
@@ -28,8 +28,8 @@
package com.jogamp.opengl.test.junit.jogl.glsl;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.util.MonitorMode;
+import com.jogamp.newt.MonitorDevice;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -109,11 +109,13 @@ public class TestRulerNEWT01 extends UITestCase {
Assert.assertNotNull(winctx);
Assert.assertNotNull(winctx.window);
Assert.assertNotNull(winctx.window.getScreen());
- ScreenMode sm = winctx.window.getScreen().getCurrentScreenMode();
- Assert.assertNotNull(sm);
- System.err.println(sm);
- final MonitorMode mmode = sm.getMonitorMode();
- final DimensionImmutable sdim = mmode.getScreenSizeMM();
+ final MonitorDevice monitor = winctx.window.getMainMonitor();
+ Assert.assertNotNull(monitor);
+ System.err.println(monitor);
+ final MonitorMode mmode = monitor.getCurrentMode();
+ Assert.assertNotNull(mmode);
+ System.err.println(mmode);
+ final DimensionImmutable sdim = monitor.getSizeMM();
final DimensionImmutable spix = mmode.getSurfaceSize().getResolution();
final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2));
final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java
index 29ec443f7..a7b65545a 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java
@@ -35,11 +35,12 @@ import javax.media.opengl.GLProfile;
import com.jogamp.opengl.util.Animator;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
+import com.jogamp.newt.util.MonitorModeUtil;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.List;
@@ -72,8 +73,8 @@ public class ManualScreenMode03NEWT extends UITestCase {
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- List<ScreenMode> screenModes = screen.getScreenModes();
- if(null==screenModes) {
+ List<MonitorMode> monitorModes = screen.getMonitorModes();
+ if(null==monitorModes) {
// no support ..
System.err.println("Your platform has no ScreenMode change support, sorry");
return;
@@ -81,18 +82,21 @@ public class ManualScreenMode03NEWT extends UITestCase {
Animator animator = new Animator(window);
animator.start();
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- ScreenMode smOrig = screen.getOriginalScreenMode();
- System.err.println("[0] current/orig: "+smCurrent);
+ MonitorDevice monitor = window.getMainMonitor();
+ MonitorMode mmCurrent = monitor.queryCurrentMode();
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
- ScreenMode sm = (ScreenMode) screenModes.get(0);
- System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
+ MonitorMode mm = (MonitorMode) monitorModes.get(0);
+ System.err.println("[0] set current: "+mm);
+ monitor.setCurrentMode(mm);
System.err.print("[0] post setting .. wait <");
try {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
index 577119bcd..f64cf2eb8 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
@@ -35,18 +35,23 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.util.ArrayHashSet;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.Screen;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.util.MonitorMode;
-import com.jogamp.newt.util.ScreenModeUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.Iterator;
import java.util.List;
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.SurfaceSize;
+import javax.media.opengl.GLProfile;
+
+import jogamp.newt.MonitorDeviceImpl;
+import jogamp.newt.MonitorModeProps;
public class TestScreenMode00NEWT extends UITestCase {
static int screenIdx = 0;
@@ -59,6 +64,7 @@ public class TestScreenMode00NEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi)
NativeWindowFactory.initSingleton();
width = 640;
height = 480;
@@ -66,31 +72,46 @@ public class TestScreenMode00NEWT extends UITestCase {
@Test
public void testScreenModeInfo00() throws InterruptedException {
- DimensionImmutable res = new Dimension(640, 480);
- SurfaceSize surfsz = new SurfaceSize(res, 32);
- DimensionImmutable mm = new Dimension(500, 400);
- MonitorMode mon = new MonitorMode(surfsz, mm, 60);
- ScreenMode sm_out = new ScreenMode(mon, 90);
- System.err.println("00 out: "+sm_out);
-
- int[] props = ScreenModeUtil.streamOut(sm_out);
- ScreenMode sm_in = ScreenModeUtil.streamIn(props, 0);
- System.err.println("00 in : "+sm_in);
-
- Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize().getResolution(),
- sm_out.getMonitorMode().getSurfaceSize().getResolution());
-
- Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize(),
- sm_out.getMonitorMode().getSurfaceSize());
-
- Assert.assertEquals(sm_in.getMonitorMode().getScreenSizeMM(),
- sm_out.getMonitorMode().getScreenSizeMM());
-
- Assert.assertEquals(sm_in.getMonitorMode(), sm_out.getMonitorMode());
-
- Assert.assertEquals(sm_in, sm_out);
+ final DimensionImmutable res = new Dimension(640, 480);
+ final SurfaceSize surfsz = new SurfaceSize(res, 32);
+ final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0);
+ System.err.println("00 out: "+modeOut);
+ final MonitorModeProps.Cache cache = new MonitorModeProps.Cache();
+ cache.monitorModes.add(modeOut);
+ {
+ final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut);
+ final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0);
+ System.err.println("00 in : "+modeIn);
+
+ Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution());
+
+ Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize());
+
+ Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode());
+
+ Assert.assertEquals(modeOut, modeIn);
+ }
- Assert.assertEquals(sm_out.hashCode(), sm_in.hashCode());
+ final DimensionImmutable sizeMM = new Dimension(50, 50);
+ final Rectangle viewport = new Rectangle(0, 0, 1920, 1080);
+ final ArrayHashSet<MonitorMode> supportedModes = new ArrayHashSet<MonitorMode>();
+ supportedModes.add(modeOut);
+ final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes);
+ System.err.println("01 out : "+monOut);
+ cache.monitorDevices.add(monOut);
+ {
+ final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut);
+ final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0);
+ System.err.println("01 in : "+monIn);
+
+ Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode());
+ Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes());
+ Assert.assertEquals(monOut.getViewport(), monIn.getViewport());
+ Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode());
+ Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode());
+ Assert.assertEquals(monOut.hashCode(), monIn.hashCode());
+ Assert.assertEquals(monOut, monIn);
+ }
}
@Test
@@ -101,21 +122,37 @@ public class TestScreenMode00NEWT extends UITestCase {
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,screen.getDisplay().isNativeValid());
System.err.println("Screen: "+screen.toString());
-
- List<ScreenMode> screenModes = screen.getScreenModes();
- Assert.assertTrue(screenModes.size()>0);
- int i=0;
- for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
- System.err.println(i+": "+iter.next());
+ List<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ Assert.assertTrue(allMonitorModes.size()>0);
+ {
+ int i=0;
+ for(Iterator<MonitorMode> iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) {
+ System.err.println("All["+i+"]: "+iMode.next());
+ }
+ }
+
+ List<MonitorDevice> monitors = screen.getMonitorDevices();
+ Assert.assertTrue(monitors.size()>0);
+ int j=0;
+ for(Iterator<MonitorDevice> iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) {
+ MonitorDevice monitor = iMonitor.next();
+ System.err.println(j+": "+monitor);
+ List<MonitorMode> modes = monitor.getSupportedModes();
+ Assert.assertTrue(modes.size()>0);
+ int i=0;
+ for(Iterator<MonitorMode> iMode=modes.iterator(); iMode.hasNext(); i++) {
+ System.err.println("["+j+"]["+i+"]: "+iMode.next());
+ }
+ Assert.assertTrue(allMonitorModes.containsAll(modes));
+
+ MonitorMode sm_o = monitor.getOriginalMode();
+ Assert.assertNotNull(sm_o);
+ MonitorMode sm_c = monitor.queryCurrentMode();
+ System.err.println("[0] orig : "+sm_o);
+ System.err.println("[0] current: "+sm_c);
+ Assert.assertNotNull(sm_c);
+ Assert.assertEquals(sm_o, sm_c);
}
- ScreenMode sm_o = screen.getOriginalScreenMode();
- Assert.assertNotNull(sm_o);
- ScreenMode sm_c = screen.getCurrentScreenMode();
- Assert.assertNotNull(sm_c);
- System.err.println("orig SM: "+sm_o);
- System.err.println("curr SM: "+sm_c);
- System.err.println("curr sz: "+screen.getWidth()+"x"+screen.getHeight());
- Assert.assertEquals(sm_o, sm_c);
screen.removeReference();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
index 75a312686..f4eaec5fa 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
@@ -36,9 +36,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -81,23 +82,24 @@ public class TestScreenMode00bNEWT extends UITestCase {
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,display.isNativeValid());
- List<ScreenMode> screenModes = screen.getScreenModes();
+ List<MonitorMode> screenModes = screen.getMonitorModes();
Assert.assertTrue(screenModes.size()>0);
int i=0;
- for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
+ for(Iterator<MonitorMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
System.err.println(i+": "+iter.next());
}
- ScreenMode sm_o = screen.getOriginalScreenMode();
+ MonitorDevice monitor = window.getMainMonitor();
+ MonitorMode mm_o = monitor.getOriginalMode();
- Assert.assertNotNull(sm_o);
- ScreenMode sm_c = screen.getCurrentScreenMode();
- Assert.assertNotNull(sm_c);
- System.err.println("orig: "+sm_o);
- System.err.println("curr: "+sm_c);
+ Assert.assertNotNull(mm_o);
+ MonitorMode mm_c = monitor.queryCurrentMode();
+ Assert.assertNotNull(mm_c);
+ System.err.println("orig: "+mm_o);
+ System.err.println("curr: "+mm_c);
for(i=0; i<50; i++) {
- sm_c = screen.getCurrentScreenMode();
- Assert.assertNotNull(sm_c);
+ mm_c = monitor.queryCurrentMode();
+ Assert.assertNotNull(mm_c);
System.err.print("."+i);
}
System.err.println("!");
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
index f253f3b58..78dd9fbc1 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
@@ -40,12 +40,13 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
+import com.jogamp.newt.util.MonitorModeUtil;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -149,14 +150,16 @@ public class TestScreenMode01NEWT extends UITestCase {
Animator animator = new Animator(window);
animator.start();
+ final MonitorDevice monitor = window.getMainMonitor();
+
Assert.assertEquals(false, window.isFullscreen());
Assert.assertEquals(width, window.getWidth());
Assert.assertEquals(height, window.getHeight());
window.setFullscreen(true);
- Assert.assertEquals(true, window.isFullscreen());
- Assert.assertEquals(window.getScreen().getWidth(), window.getWidth());
- Assert.assertEquals(window.getScreen().getHeight(), window.getHeight());
+ Assert.assertEquals(true, window.isFullscreen());
+ Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth());
+ Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight());
Thread.sleep(waitTimeShort);
@@ -192,45 +195,53 @@ public class TestScreenMode01NEWT extends UITestCase {
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
Assert.assertNotNull(window);
- List<ScreenMode> screenModes = screen.getScreenModes();
- if(screenModes.size()==1) {
+ MonitorDevice monitor = window.getMainMonitor();
+
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ Assert.assertTrue(monitorModes.size()>0);
+ if(monitorModes.size()==1) {
// no support ..
- System.err.println("Your platform has no ScreenMode change support, sorry");
+ System.err.println("Your platform has no MonitorMode change support, sorry");
destroyWindow(window);
return;
}
- Assert.assertTrue(screenModes.size()>0);
Animator animator = new Animator(window);
animator.start();
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
-
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
+ MonitorMode mmCurrent = monitor.queryCurrentMode();
+ Assert.assertNotNull(mmCurrent);
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
+
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
- ScreenMode sm = (ScreenMode) screenModes.get(0);
+ MonitorMode sm = (MonitorMode) monitorModes.get(0);
System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
- Assert.assertEquals(sm, screen.getCurrentScreenMode());
- Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
-
+ monitor.setCurrentMode(sm);
+ Assert.assertTrue(monitor.isModeChangedByUs());
+ Assert.assertEquals(sm, monitor.getCurrentMode());
+ Assert.assertNotSame(mmOrig, monitor.getCurrentMode());
+ Assert.assertEquals(sm, monitor.queryCurrentMode());
+
Thread.sleep(waitTimeLong);
// check reset ..
@@ -258,15 +269,14 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
- smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
+ mmCurrent = monitor.getCurrentMode();
+ System.err.println("[1] current/orig: "+mmCurrent);
screen.destroy();
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(smCurrent, smOrig);
-
+ Assert.assertNotNull(mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
cleanupGL();
}
@@ -291,27 +301,30 @@ public class TestScreenMode01NEWT extends UITestCase {
Animator animator = new Animator(window);
animator.start();
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
+ MonitorDevice monitor = window.getMainMonitor();
+ MonitorMode mmCurrent = monitor.queryCurrentMode();
+ Assert.assertNotNull(mmCurrent);
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
- List<ScreenMode> screenModes = screen.getScreenModes();
- if(screenModes.size()==1) {
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ if(monitorModes.size()==1) {
// no support ..
destroyWindow(window);
return;
}
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
-
- ScreenMode screenMode = (ScreenMode) screenModes.get(0);
- Assert.assertNotNull(screenMode);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
+
+ MonitorMode monitorMode = (MonitorMode) monitorModes.get(0);
+ Assert.assertNotNull(monitorMode);
if(preFS) {
System.err.println("[0] set FS pre 0: "+window.isFullscreen());
@@ -321,8 +334,8 @@ public class TestScreenMode01NEWT extends UITestCase {
System.err.println("[0] set FS pre X: "+window.isFullscreen());
}
- System.err.println("[0] set current: "+screenMode);
- screen.setCurrentScreenMode(screenMode);
+ System.err.println("[0] set current: "+monitorMode);
+ monitor.setCurrentMode(monitorMode);
if(!preFS) {
System.err.println("[0] set FS post 0: "+window.isFullscreen());
@@ -358,14 +371,14 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
- smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
+ mmCurrent = monitor.getCurrentMode();
+ System.err.println("[1] current/orig: "+mmCurrent);
screen.destroy();
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(smCurrent, smOrig);
+ Assert.assertNotNull(mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
cleanupGL();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java
new file mode 100644
index 000000000..35390636f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java
@@ -0,0 +1,212 @@
+/**
+ * Copyright 2010 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.junit.newt;
+
+import java.io.IOException;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.MonitorMode;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.newt.util.MonitorModeUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.util.List;
+import javax.media.nativewindow.util.Dimension;
+
+/**
+ * Documents remedy B) for NV RANDR/GL bug
+ *
+ * @see TestScreenMode01NEWT#cleanupGL()
+ */
+public class TestScreenMode01aNEWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+
+ static int waitTimeShort = 2000;
+ static int waitTimeLong = 2000;
+
+ @BeforeClass
+ public static void initClass() {
+ width = 100;
+ height = 100;
+ glp = GLProfile.getDefault();
+ }
+
+ @AfterClass
+ public static void releaseClass() throws InterruptedException {
+ Thread.sleep(waitTimeShort);
+ }
+
+ static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(screen, caps);
+ // Window window = NewtFactory.createWindow(screen, caps);
+ window.setTitle(name);
+ window.setPosition(x, y);
+ window.setSize(width, height);
+ window.addGLEventListener(new GearsES2());
+ Assert.assertNotNull(window);
+ window.setVisible(true);
+ return window;
+ }
+
+ static void destroyWindow(Window window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ @Test
+ public void testScreenModeChange01() throws InterruptedException {
+ Thread.sleep(waitTimeShort);
+
+ GLCapabilities caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height);
+ Assert.assertNotNull(window0);
+
+ List<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ Assert.assertTrue(allMonitorModes.size()>0);
+ if(allMonitorModes.size()==1) {
+ // no support ..
+ System.err.println("Your platform has no MonitorMode change support (all), sorry");
+ destroyWindow(window0);
+ return;
+ }
+
+ MonitorDevice monitor = window0.getMainMonitor();
+
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ Assert.assertTrue(monitorModes.size()>0);
+ if(monitorModes.size()==1) {
+ // no support ..
+ System.err.println("Your platform has no MonitorMode change support (monitor), sorry");
+ destroyWindow(window0);
+ return;
+ }
+ Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
+
+ MonitorMode mmCurrent = monitor.queryCurrentMode();
+ Assert.assertNotNull(mmCurrent);
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
+
+
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+
+ MonitorMode sm = (MonitorMode) monitorModes.get(0);
+ System.err.println("[0] set current: "+sm);
+ Assert.assertTrue(monitor.setCurrentMode(sm));
+ Assert.assertTrue(monitor.isModeChangedByUs());
+ Assert.assertEquals(sm, monitor.getCurrentMode());
+ Assert.assertNotSame(mmOrig, monitor.getCurrentMode());
+ Assert.assertEquals(sm, monitor.queryCurrentMode());
+
+ Thread.sleep(waitTimeShort);
+
+ // check manual reset ..
+
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(true,window0.isNativeValid());
+ Assert.assertEquals(true,window0.isVisible());
+
+ screen.addReference(); // keep it alive !
+ Assert.assertTrue(monitor.setCurrentMode(mmOrig));
+ Assert.assertFalse(monitor.isModeChangedByUs());
+ Assert.assertEquals(mmOrig, monitor.getCurrentMode());
+ Assert.assertNotSame(sm, monitor.getCurrentMode());
+ Assert.assertEquals(mmOrig, monitor.queryCurrentMode());
+
+ destroyWindow(window0);
+ Assert.assertEquals(false,window0.isVisible());
+ Assert.assertEquals(false,window0.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid()); // alive !
+ Assert.assertEquals(true,display.isNativeValid());
+
+ Thread.sleep(waitTimeShort);
+
+ Window window1 = createWindow(screen, caps, "win1",
+ width+window0.getInsets().getTotalWidth(), 0,
+ width, height);
+ Assert.assertNotNull(window1);
+ Assert.assertEquals(true,window1.isNativeValid());
+ Assert.assertEquals(true,window1.isVisible());
+
+ Thread.sleep(waitTimeShort);
+
+ destroyWindow(window1);
+ Assert.assertEquals(false,window1.isNativeValid());
+ Assert.assertEquals(false,window1.isVisible());
+
+ screen.removeReference();
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(false,display.isNativeValid());
+ }
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestScreenMode01aNEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
index 38612faa8..7e18f396a 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2013 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:
@@ -29,7 +29,6 @@
package com.jogamp.opengl.test.junit.newt;
import java.io.IOException;
-import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -39,34 +38,36 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
+import com.jogamp.newt.util.MonitorModeUtil;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
import java.util.List;
import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.RectangleImmutable;
/**
- * Documents remedy B) for NV RANDR/GL bug
- *
- * @see TestScreenMode01NEWT#cleanupGL()
+ * Mode change on separate monitors ..
*/
public class TestScreenMode01bNEWT extends UITestCase {
static GLProfile glp;
static int width, height;
- static int waitTimeShort = 2000;
- static int waitTimeLong = 2000;
+ static long waitTimeShort = 2000;
+ static long duration = 6000;
@BeforeClass
public static void initClass() {
- width = 100;
- height = 100;
+ width = 200;
+ height = 200;
glp = GLProfile.getDefault();
}
@@ -75,7 +76,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
Thread.sleep(waitTimeShort);
}
- static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) {
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException {
Assert.assertNotNull(caps);
GLWindow window = GLWindow.create(screen, caps);
@@ -85,7 +86,9 @@ public class TestScreenMode01bNEWT extends UITestCase {
window.setSize(width, height);
window.addGLEventListener(new GearsES2());
Assert.assertNotNull(window);
+ final long t0 = System.currentTimeMillis();
window.setVisible(true);
+ System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms");
return window;
}
@@ -96,93 +99,150 @@ public class TestScreenMode01bNEWT extends UITestCase {
}
@Test
- public void testScreenModeChange01() throws InterruptedException {
+ public void testScreenModeChangeSingleQ1() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport();
+ testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY());
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ @Test
+ public void testScreenModeChangeSingleQ2() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ if( 2 > screen.getMonitorDevices().size() ) {
+ System.err.println("Test Disabled (1): Monitor count < 2: "+screen);
+ return;
+ }
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport();
+ testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY());
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException {
Thread.sleep(waitTimeShort);
- GLCapabilities caps = new GLCapabilities(glp);
+ final GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
- Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height);
+ final Display display = screen.getDisplay();
+ System.err.println("Test.0: Window screen: "+screen);
+
+ System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport());
+
+ GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height);
Assert.assertNotNull(window0);
+ System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
- List<ScreenMode> screenModes = screen.getScreenModes();
- if(screenModes.size()==1) {
+ final Animator anim = new Animator(window0);
+ anim.start();
+
+ List<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ Assert.assertTrue(allMonitorModes.size()>0);
+ if(allMonitorModes.size()==1) {
// no support ..
- System.err.println("Your platform has no ScreenMode change support, sorry");
+ System.err.println("Your platform has no MonitorMode change support (all), sorry");
destroyWindow(window0);
return;
}
- Assert.assertTrue(screenModes.size()>0);
-
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
-
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
-
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- ScreenMode sm = (ScreenMode) screenModes.get(0);
- System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
- Assert.assertEquals(sm, screen.getCurrentScreenMode());
- Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
-
- Thread.sleep(waitTimeShort);
-
- // check reset ..
+ MonitorDevice monitor = window0.getMainMonitor();
+ System.err.println("Test.0: Window monitor: "+monitor);
+
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ Assert.assertTrue(monitorModes.size()>0);
+ if(monitorModes.size()==1) {
+ // no support ..
+ System.err.println("Your platform has no MonitorMode change support (monitor), sorry");
+ destroyWindow(window0);
+ return;
+ }
+ Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
+
+ MonitorMode mmCurrent = monitor.getCurrentMode();
+ Assert.assertNotNull(mmCurrent);
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
+
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+
+ MonitorMode sm = (MonitorMode) monitorModes.get(0);
+ System.err.println("[1] set current: "+sm);
+ Assert.assertTrue(monitor.setCurrentMode(sm));
+ mmCurrent = monitor.getCurrentMode();
+ System.err.println("[1] current: "+mmCurrent);
+ Assert.assertTrue(monitor.isModeChangedByUs());
+ Assert.assertEquals(sm, monitor.getCurrentMode());
+ Assert.assertNotSame(mmOrig, monitor.getCurrentMode());
+ Assert.assertEquals(sm, monitor.queryCurrentMode());
+
+ System.err.println("Test.1: Window screen: "+screen);
+ System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
+ System.err.println("Test.1: Window monitor: "+window0.getMainMonitor());
+
+ Thread.sleep(duration);
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window0.isNativeValid());
Assert.assertEquals(true,window0.isVisible());
- screen.addReference(); // keep it alive !
- screen.setCurrentScreenMode(smOrig);
+ Assert.assertTrue(monitor.setCurrentMode(mmOrig));
+ Assert.assertFalse(monitor.isModeChangedByUs());
+ Assert.assertEquals(mmOrig, monitor.getCurrentMode());
+ Assert.assertNotSame(sm, monitor.getCurrentMode());
+ Assert.assertEquals(mmOrig, monitor.queryCurrentMode());
+
+ System.err.println("Test.2: Window screen: "+screen);
+ System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
+ System.err.println("Test.2: Window monitor: "+window0.getMainMonitor());
+ Thread.sleep(duration);
+ anim.stop();
destroyWindow(window0);
Assert.assertEquals(false,window0.isVisible());
Assert.assertEquals(false,window0.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid()); // alive !
Assert.assertEquals(true,display.isNativeValid());
-
- Thread.sleep(waitTimeShort);
-
- Window window1 = createWindow(screen, caps, "win1",
- width+window0.getInsets().getTotalWidth(), 0,
- width, height);
- Assert.assertNotNull(window1);
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
-
- Thread.sleep(waitTimeShort);
-
- destroyWindow(window1);
- Assert.assertEquals(false,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
-
- screen.removeReference();
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
}
public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
String tstname = TestScreenMode01bNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java
new file mode 100644
index 000000000..30c06e932
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java
@@ -0,0 +1,249 @@
+/**
+ * Copyright 2013 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.junit.newt;
+
+import java.io.IOException;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.MonitorMode;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.media.nativewindow.util.Rectangle;
+import javax.media.nativewindow.util.RectangleImmutable;
+
+/**
+ * Fullscreen on separate monitors ..
+ */
+public class TestScreenMode01cNEWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+
+ static long waitTimeShort = 2000;
+ static long duration = 4000;
+
+ @BeforeClass
+ public static void initClass() {
+ width = 200;
+ height = 200;
+ glp = GLProfile.getDefault();
+ }
+
+ @AfterClass
+ public static void releaseClass() throws InterruptedException {
+ Thread.sleep(waitTimeShort);
+ }
+
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(screen, caps);
+ // Window window = NewtFactory.createWindow(screen, caps);
+ window.setTitle(name);
+ window.setPosition(x, y);
+ window.setSize(width, height);
+ window.addGLEventListener(new GearsES2());
+ Assert.assertNotNull(window);
+ final long t0 = System.currentTimeMillis();
+ window.setVisible(true);
+ System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms");
+ return window;
+ }
+
+ static void destroyWindow(Window window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ @Test
+ public void testScreenFullscreenSingleQ1() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport();
+ testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ @Test
+ public void testScreenFullscreenSingleQ2() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ if( 2 > screen.getMonitorDevices().size() ) {
+ System.err.println("Test Disabled (1): Monitor count < 2: "+screen);
+ return;
+ }
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport();
+ testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ @Test
+ public void testScreenFullscreenSpanQ1Q2() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ final int crtCount = screen.getMonitorDevices().size();
+ if( 2 >= crtCount ) {
+ System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen);
+ return;
+ }
+ final ArrayList<MonitorDevice> monitors = new ArrayList<MonitorDevice>();
+ monitors.add(screen.getMonitorDevices().get(0)); // Q1
+ monitors.add(screen.getMonitorDevices().get(1)); // Q2
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport();
+ testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors);
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ @Test
+ public void testScreenFullscreenSpanALL() throws InterruptedException {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ screen.addReference(); // trigger creation
+ try {
+ if( 2 > screen.getMonitorDevices().size() ) {
+ System.err.println("Test Disabled (3): Monitor count < 2: "+screen);
+ return;
+ }
+ RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport();
+ testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null);
+ } finally {
+ screen.removeReference();
+ }
+ }
+
+ void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List<MonitorDevice> monitors) throws InterruptedException {
+ Thread.sleep(waitTimeShort);
+
+ final GLCapabilities caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ final Display display = screen.getDisplay();
+
+ System.err.println("Test.0: Window screen: "+screen);
+
+ System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport());
+
+ GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height);
+ Assert.assertNotNull(window0);
+ System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
+
+ final Animator anim = new Animator(window0);
+ anim.start();
+
+ List<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ Assert.assertTrue(allMonitorModes.size()>0);
+
+ MonitorDevice monitor = window0.getMainMonitor();
+ System.err.println("Test.0: Window monitor: "+monitor);
+ if( !spanAcrossMonitors ) {
+ window0.setFullscreen(true);
+ } else {
+ window0.setFullscreen(monitors);
+ }
+
+ monitor = window0.getMainMonitor();
+ System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
+ System.err.println("Test.1: Window monitor: "+monitor.getViewport());
+ Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight());
+ if( !spanAcrossMonitors ) {
+ Assert.assertEquals(monitor.getViewport(), window0Rect);
+ } else {
+ List<MonitorDevice> monitorsUsed = monitors;
+ if( null == monitorsUsed ) {
+ monitorsUsed = window0.getScreen().getMonitorDevices();
+ }
+ Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed);
+ Assert.assertEquals(monitorsUsedViewport, window0Rect);
+ }
+
+ Thread.sleep(duration);
+
+ window0.setFullscreen(false);
+
+ window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight());
+ monitor = window0.getMainMonitor();
+ System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport());
+ System.err.println("Test.2: Window monitor: "+monitor.getViewport());
+
+ Thread.sleep(duration);
+ anim.stop();
+ destroyWindow(window0);
+ Assert.assertEquals(false,window0.isVisible());
+ Assert.assertEquals(false,window0.isNativeValid());
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ String tstname = TestScreenMode01cNEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
index 1c9cb91f3..d30f90e44 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
@@ -39,13 +39,15 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.os.Platform;
import com.jogamp.newt.Display;
+import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.MonitorMode;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
+import com.jogamp.newt.util.MonitorModeUtil;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.List;
@@ -102,48 +104,55 @@ public class TestScreenMode02NEWT extends UITestCase {
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
Assert.assertNotNull(window);
- List<ScreenMode> screenModes = screen.getScreenModes();
- if(screenModes.size()==1) {
+ MonitorDevice monitor = window.getMainMonitor();
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ if(monitorModes.size()==1) {
// no support ..
System.err.println("Your platform has no ScreenMode change support, sorry");
destroyWindow(window);
return;
}
- Assert.assertTrue(screenModes.size()>0);
+ Assert.assertTrue(monitorModes.size()>0);
Animator animator = new Animator(window);
animator.start();
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
-
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 90);
- if(null==screenModes) {
+ MonitorMode mmCurrent = monitor.getCurrentMode();
+ Assert.assertNotNull(mmCurrent);
+ MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ System.err.println("[0] orig : "+mmOrig);
+ System.err.println("[0] current: "+mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
+
+ monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90);
+ if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) {
// no rotation support ..
System.err.println("Your platform has no rotation support, sorry");
destroyWindow(window);
return;
}
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
-
- ScreenMode sm = (ScreenMode) screenModes.get(0);
+ monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+ monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
+ Assert.assertNotNull(monitorModes);
+ Assert.assertTrue(monitorModes.size()>0);
+
+ MonitorMode sm = (MonitorMode) monitorModes.get(0);
System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
- Assert.assertEquals(sm, screen.getCurrentScreenMode());
- Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
+ monitor.setCurrentMode(sm);
+ Assert.assertTrue(monitor.isModeChangedByUs());
+ Assert.assertEquals(sm, monitor.getCurrentMode());
+ Assert.assertNotSame(mmOrig, monitor.getCurrentMode());
+ Assert.assertEquals(sm, monitor.queryCurrentMode());
Thread.sleep(waitTimeLong);
@@ -167,11 +176,11 @@ public class TestScreenMode02NEWT extends UITestCase {
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
- smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
+ mmCurrent = monitor.getCurrentMode();
+ System.err.println("[1] current/orig: "+mmCurrent);
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(smCurrent, smOrig);
+ Assert.assertNotNull(mmCurrent);
+ Assert.assertEquals(mmCurrent, mmOrig);
screen.destroy();