diff options
Diffstat (limited to 'src/test/com/jogamp/opengl')
7 files changed, 112 insertions, 56 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index 8ee182939..99e81af04 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -60,8 +60,8 @@ public class TestSharedContextListAWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - width = 512; - height = 512; + width = 256; + height = 256; } private void initShared() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java index 231a45ca0..73a227740 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import com.jogamp.newt.opengl.GLWindow; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; @@ -58,8 +59,8 @@ public class TestSharedContextListNEWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - width = 512; - height = 512; + width = 256; + height = 256; } private void initShared() { @@ -86,7 +87,6 @@ public class TestSharedContextListNEWT extends UITestCase { } glWindow.setSize(width, height); - glWindow.setPosition(x, y); Gears gears = new Gears(vsync ? 1 : 0); if(useShared) { @@ -98,6 +98,9 @@ public class TestSharedContextListNEWT extends UITestCase { glWindow.setVisible(true); + /** insets (if supported) are available only if window is set visible and hence is created */ + glWindow.setTopLevelPosition(x, y); + return glWindow; } @@ -106,8 +109,9 @@ public class TestSharedContextListNEWT extends UITestCase { initShared(); Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); - GLWindow f2 = runTestGL(animator, width, 0, true, false); - GLWindow f3 = runTestGL(animator, 0, height, false, true); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false); + GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true); animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java index c230ffd6d..e78efb396 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import com.jogamp.newt.opengl.GLWindow; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; @@ -57,8 +58,8 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - width = 512; - height = 512; + width = 256; + height = 256; } private void initShared() { @@ -85,7 +86,6 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { } glWindow.setSize(width, height); - glWindow.setPosition(x, y); GearsES1 gears = new GearsES1(vsync ? 1 : 0); if(useShared) { @@ -97,6 +97,9 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { glWindow.setVisible(true); + /** insets (if supported) are available only if window is set visible and hence is created */ + glWindow.setTopLevelPosition(x, y); + return glWindow; } @@ -105,8 +108,9 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { initShared(); Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); - GLWindow f2 = runTestGL(animator, width, 0, true, false); - GLWindow f3 = runTestGL(animator, 0, height, false, true); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false); + GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true); animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java index 602f5c3b5..a37c43c58 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import com.jogamp.newt.opengl.GLWindow; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; @@ -57,8 +58,8 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - width = 512; - height = 512; + width = 256; + height = 256; } private void initShared() { @@ -85,7 +86,6 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { } glWindow.setSize(width, height); - glWindow.setPosition(x, y); GearsES2 gears = new GearsES2(vsync ? 1 : 0); if(useShared) { @@ -96,6 +96,9 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { animator.add(glWindow); glWindow.setVisible(true); + + /** insets (if supported) are available only if window is set visible and hence is created */ + glWindow.setTopLevelPosition(x, y); return glWindow; } @@ -105,8 +108,9 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { initShared(); Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); - GLWindow f2 = runTestGL(animator, width, 0, true, false); - GLWindow f3 = runTestGL(animator, 0, height, false, true); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false); + GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true); animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { 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 c8c92ea48..3c7a8a006 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 @@ -90,12 +90,23 @@ public class TestGearsES2NEWT extends UITestCase { if(e.getKeyChar()=='f') { new Thread() { public void run() { + System.err.println("[set fullscreen pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets()); f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets()); } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { + System.err.println("[set undecorated pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets()); f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); + System.err.println("[set undecorated post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets()); + } }.start(); + } else if(e.getKeyChar()=='s') { + new Thread() { + public void run() { + System.err.println("[set position pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); + f_glWindow.setPosition(100, 100); + System.err.println("[set position post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); } }.start(); } } @@ -103,6 +114,9 @@ public class TestGearsES2NEWT extends UITestCase { glWindow.setSize(width, height); glWindow.setVisible(true); + + System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); + animator.setUpdateFPSFrames(1, null); animator.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java new file mode 100644 index 000000000..e3cf132f6 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -0,0 +1,66 @@ +/** + * 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.junit.newt.parenting; + +import java.awt.Frame; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.opengl.GLWindow; + +class NewtAWTReparentingKeyAdapter extends KeyAdapter { + Frame frame; + NewtCanvasAWT newtCanvasAWT; + GLWindow glWindow; + + public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow) { + this.frame = frame; + this.newtCanvasAWT = newtCanvasAWT; + this.glWindow = glWindow; + } + + public void keyTyped(KeyEvent e) { + if(e.getKeyChar()=='d') { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } else if(e.getKeyChar()=='f') { + glWindow.setFullscreen(!glWindow.isFullscreen()); + } else if(e.getKeyChar()=='r') { + if(glWindow.getParent()==null) { + System.err.println("XXX glWin to home"); + glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); + } else { + System.err.println("XXX glWin to TOP"); + glWindow.setUndecorated(false); + glWindow.reparentWindow(null); + glWindow.setTopLevelPosition(frame.getX()+frame.getWidth(), frame.getY()); + } + glWindow.requestFocus(); + } + } +}
\ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java index 1f2259d1d..ec481d3a1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java @@ -71,6 +71,7 @@ public class TestParenting03bAWT extends UITestCase { } public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException { + Frame frame1 = new Frame("AWT Parent Frame"); GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUpdateFPSFrames(1, null); glWindow1.setUndecorated(true); @@ -80,25 +81,7 @@ public class TestParenting03bAWT extends UITestCase { GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - final NewtCanvasAWT f_newtCanvasAWT1 = newtCanvasAWT1; - final GLWindow f_glWindow1 = glWindow1; - glWindow1.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='d') { - f_glWindow1.setUndecorated(!f_glWindow1.isUndecorated()); - } else if(e.getKeyChar()=='f') { - f_glWindow1.setFullscreen(!f_glWindow1.isFullscreen()); - } else if(e.getKeyChar()=='r') { - if(f_glWindow1.getParent()==null) { - System.err.println("XXX glWin1 to home"); - f_glWindow1.reparentWindow(f_newtCanvasAWT1.getNativeWindow()); - } else { - System.err.println("XXX glWin1 to TOP"); - f_glWindow1.reparentWindow(null); - } - } - } - }); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); @@ -111,25 +94,7 @@ public class TestParenting03bAWT extends UITestCase { GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); - final NewtCanvasAWT f_newtCanvasAWT2 = newtCanvasAWT2; - final GLWindow f_glWindow2 = glWindow2; - glWindow2.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='d') { - f_glWindow2.setUndecorated(!f_glWindow2.isUndecorated()); - } else if(e.getKeyChar()=='f') { - f_glWindow2.setFullscreen(!f_glWindow2.isFullscreen()); - } else if(e.getKeyChar()=='r') { - if(f_glWindow2.getParent()==null) { - System.err.println("XXX glWin2 to home"); - f_glWindow2.reparentWindow(f_newtCanvasAWT2.getNativeWindow()); - } else { - System.err.println("XXX glWin2 to TOP"); - f_glWindow2.reparentWindow(null); - } - } - } - }); + glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); GLAnimatorControl animator2 = new Animator(glWindow2); animator2.start(); @@ -144,7 +109,6 @@ public class TestParenting03bAWT extends UITestCase { cont2.setVisible(true); final Container f_cont2 = cont2; - Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(cont1, BorderLayout.EAST); frame1.add(new Label("center"), BorderLayout.CENTER); |