aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-10 16:16:13 +0200
committerSven Gothel <[email protected]>2015-08-10 16:16:13 +0200
commit2d837a7a7130702ad36b694875613fae77c7ef06 (patch)
treef9027493d91511e9f799a852d3058d9fb29f9645 /src/test/com/jogamp
parent1e4bfc26e2f220e046f42f7d26c05e4971bc509d (diff)
Bug 1188, Bug 1186: NEWT Window: Support non-resizable, minimize, maximize, alwaysOnBottom and sticky/all-desktop (Part 1)
Change also implements Bug 1186: 'NEWT Window: Use a Bitfield holding all state flags and expose it accordingly', since it is essential for an efficient implementation. Part 1: - Bug 1186 - Using Bitfield, holding public (Window) and private state bits/mask - Bug 1188 - Window adds: - [is|set]AlwaysOnBottom(..), - [is|set]Resizable(..), - [is|set]Sticky(..), - [is|set]Maximized(..), - isChildWindow(), - Full implementation for X11 - TODO: Implement for OSX and Windows - Manual tests: - TestGearsES2NEWT, TestGearsES2NEWTSimple and TestGearsES2NewtCanvasAWT utilize new NewtDemoListener, which has a key-listener to perform all [new] actions. See source code of NewtDemoListener.
Diffstat (limited to 'src/test/com/jogamp')
-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/newt/TestGearsES2NEWT.java270
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java49
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java170
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java251
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java468
6 files changed, 593 insertions, 630 deletions
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 f70df89dc..e1abcc752 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
@@ -587,12 +587,6 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
return "GearsES2[obj "+sid()+" isInit "+isInit+", usesShared "+usesSharedGears+", 1 "+gear1+", 2 "+gear2+", 3 "+gear3+", sharedGears "+sharedGears+"]";
}
- boolean confinedFixedCenter = false;
-
- public void setConfinedFixedCenter(final boolean v) {
- confinedFixedCenter = v;
- }
-
class GearsKeyAdapter extends KeyAdapter {
public void keyPressed(final KeyEvent e) {
final int kc = e.getKeyCode();
@@ -669,8 +663,8 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
}
private void navigate(final MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
+ final int x = e.getX();
+ final int y = e.getY();
int width, height;
final Object source = e.getSource();
@@ -694,11 +688,6 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
final float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
view_rotx += thetaX;
view_roty += thetaY;
- if(e.isConfined() && confinedFixedCenter && null!=window) {
- x=window.getSurfaceWidth()/2;
- y=window.getSurfaceHeight()/2;
- window.warpPointer(x, y);
- }
prevMouseX = x;
prevMouseY = y;
// System.err.println("rotXY.1: "+view_rotx+"/"+view_roty+", source "+e);
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 90164d349..d5afdcfda 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
@@ -30,31 +30,24 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.net.URLConnection;
-import com.jogamp.common.util.IOUtil;
import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.Display;
import com.jogamp.newt.Display.PointerIcon;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.MouseAdapter;
-import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.util.EDTUtil;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.NEWTDemoListener;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.AnimatorBase;
-import com.jogamp.opengl.util.Gamma;
-import com.jogamp.opengl.util.PNGPixelRect;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.nativewindow.NativeWindowFactory;
@@ -71,7 +64,6 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import jogamp.newt.DefaultEDTUtil;
-import jogamp.newt.driver.PNGIcon;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -92,6 +84,11 @@ public class TestGearsES2NEWT extends UITestCase {
static int forceAlpha = -1;
static boolean undecorated = false;
static boolean alwaysOnTop = false;
+ static boolean alwaysOnBottom = false;
+ static boolean resizable = true;
+ static boolean sticky = false;
+ static boolean max_vert= false;
+ static boolean max_horz= false;
static boolean fullscreen = false;
static int swapInterval = 1;
static boolean waitForKey = false;
@@ -123,13 +120,6 @@ public class TestGearsES2NEWT extends UITestCase {
public static void releaseClass() {
}
- private void setTitle(final Window win, final GLCapabilitiesImmutable caps) {
- final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
- final float[] sDPI = win.getPixelsPerMM(new float[2]);
- sDPI[0] *= 25.4f;
- sDPI[1] *= 25.4f;
- win.setTitle("GLWindow["+capsA+"], swapI "+swapInterval+", win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]);
- }
protected void runTestGL(final GLCapabilitiesImmutable caps, final boolean undecorated) throws InterruptedException {
System.err.println("requested: vsync "+swapInterval+", "+caps);
final Display dpy = NewtFactory.createDisplay(null);
@@ -144,6 +134,10 @@ public class TestGearsES2NEWT extends UITestCase {
}
glWindow.setUndecorated(undecorated);
glWindow.setAlwaysOnTop(alwaysOnTop);
+ glWindow.setAlwaysOnBottom(alwaysOnBottom);
+ glWindow.setResizable(resizable);
+ glWindow.setSticky(sticky);
+ glWindow.setMaximized(max_horz, max_vert);
glWindow.setFullscreen(fullscreen);
glWindow.setPointerVisible(mouseVisible);
glWindow.confinePointer(mouseConfined);
@@ -187,238 +181,23 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.addWindowListener(new WindowAdapter() {
public void windowResized(final WindowEvent e) {
System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
- setTitle(glWindow, caps);
+ NEWTDemoListener.setTitle(glWindow);
}
public void windowMoved(final WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
- setTitle(glWindow, caps);
+ NEWTDemoListener.setTitle(glWindow);
}
});
- final PointerIcon[] pointerIcons = { null, null, null, null, null };
- {
- final Display disp = glWindow.getScreen().getDisplay();
- disp.createNative();
- int idx = 0;
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 8, 8);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
- pointerIcons[idx] = _pointerIcon;
- }
- idx++;
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 0, 0);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
- pointerIcons[idx] = _pointerIcon;
- }
- idx++;
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-red-alpha-64x64.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 0, 0);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
- pointerIcons[idx] = _pointerIcon;
- }
- idx++;
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-blue-alpha-64x64.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 0, 0);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
- pointerIcons[idx] = _pointerIcon;
- }
- idx++;
- if( PNGIcon.isAvailable() ) {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } );
- try {
- final URLConnection urlConn = res.resolve(0);
- final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, image.toString());
- _pointerIcon = disp.createPointerIcon(image, 32, 0);
- System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
- pointerIcons[idx] = _pointerIcon;
- }
- idx++;
- }
+ final PointerIcon[] pointerIcons = NEWTDemoListener.createPointerIcons(glWindow);
if( setPointerIcon ) {
glWindow.setPointerIcon(pointerIcons[0]);
System.err.println("Set PointerIcon: "+glWindow.getPointerIcon());
}
- glWindow.addKeyListener(new KeyAdapter() {
- int pointerIconIdx = 0;
- float gamma = 1f;
- float brightness = 0f;
- float contrast = 1f;
-
- @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.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- 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.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if( e.getKeySymbol()== KeyEvent.VK_G ) {
- new Thread() {
- public void run() {
- final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f );
- System.err.println("[set gamma]: "+gamma+" -> "+newGamma);
- if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) {
- gamma = newGamma;
- }
- } }.start();
- } else if(e.getKeyChar()=='a') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set alwaysontop pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
- System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='d') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- // while( null != glWindow.getExclusiveContextThread() ) ;
- System.err.println("[set undecorated pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
- glWindow.setUndecorated(!glWindow.isUndecorated());
- System.err.println("[set undecorated post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='s') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set position pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
- glWindow.setPosition(100, 100);
- System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='c') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set pointer-icon pre]");
- final PointerIcon currentPI = glWindow.getPointerIcon();
- final PointerIcon newPI;
- if( pointerIconIdx >= pointerIcons.length ) {
- newPI=null;
- pointerIconIdx=0;
- } else {
- newPI=pointerIcons[pointerIconIdx++];
- }
- glWindow.setPointerIcon( newPI );
- System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='i') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible());
- glWindow.setPointerVisible(!glWindow.isPointerVisible());
- System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='j') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
- glWindow.confinePointer(!glWindow.isPointerConfined());
- System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
- if(!glWindow.isPointerConfined()) {
- demo.setConfinedFixedCenter(false);
- }
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='J') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
- glWindow.confinePointer(!glWindow.isPointerConfined());
- System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
- demo.setConfinedFixedCenter(glWindow.isPointerConfined());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='w') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse pos pre]");
- glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2);
- System.err.println("[set mouse pos post]");
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='x') {
- final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]);
- final float[] reqSurfacePixelScale;
- if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
- reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
- } else {
- reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- }
- System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
- glWindow.setSurfaceScale(reqSurfacePixelScale);
- final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
- final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
- System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
- reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
- valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
- hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
- setTitle(glWindow, caps);
- }
- }
- });
- glWindow.addMouseListener(new MouseAdapter() {
- public void mouseClicked(final MouseEvent e) {
- if(e.getClickCount() == 2 && e.getPointerCount() == 1) {
- glWindow.setFullscreen(!glWindow.isFullscreen());
- System.err.println("setFullscreen: "+glWindow.isFullscreen());
- }
- }
- });
+ final NEWTDemoListener newtDemoListener = new NEWTDemoListener(glWindow, pointerIcons);
+ glWindow.addKeyListener(newtDemoListener);
+ glWindow.addMouseListener(newtDemoListener);
if( useAnimator ) {
animator.add(glWindow);
@@ -484,7 +263,7 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
- setTitle(glWindow, caps);
+ NEWTDemoListener.setTitle(glWindow);
snap.setMakeSnapshot();
@@ -620,6 +399,16 @@ public class TestGearsES2NEWT extends UITestCase {
undecorated = true;
} else if(args[i].equals("-atop")) {
alwaysOnTop = true;
+ } else if(args[i].equals("-abottom")) {
+ alwaysOnBottom = true;
+ } else if(args[i].equals("-noresize")) {
+ resizable = false;
+ } else if(args[i].equals("-sticky")) {
+ sticky = true;
+ } else if(args[i].equals("-maxv")) {
+ max_vert = true;
+ } else if(args[i].equals("-maxh")) {
+ max_horz = true;
} else if(args[i].equals("-fullscreen")) {
fullscreen = true;
} else if(args[i].equals("-vsync")) {
@@ -705,6 +494,11 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("forceAlpha "+forceAlpha);
System.err.println("undecorated "+undecorated);
System.err.println("atop "+alwaysOnTop);
+ System.err.println("abottom "+alwaysOnBottom);
+ System.err.println("resizable "+resizable);
+ System.err.println("sticky "+sticky);
+ System.err.println("max_vert "+max_vert);
+ System.err.println("max_horz "+max_horz);
System.err.println("fullscreen "+fullscreen);
System.err.println("mouseVisible "+mouseVisible);
System.err.println("mouseConfined "+mouseConfined);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
index f43635e81..39d13f6a3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
@@ -43,9 +43,7 @@ import com.jogamp.common.os.Platform;
import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
-import com.jogamp.newt.Window;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
@@ -175,18 +173,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
}
}
- private void setTitle(final Frame frame, final NewtCanvasAWT glc, final Window win, final GLCapabilitiesImmutable caps) {
- final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
- {
- final java.awt.Rectangle b = glc.getBounds();
- frame.setTitle("NewtCanvasAWT["+capsA+"], swapI "+swapInterval+", win: ["+b.x+"/"+b.y+" "+b.width+"x"+b.height+"], pix: "+glc.getNativeWindow().getSurfaceWidth()+"x"+glc.getNativeWindow().getSurfaceHeight());
- }
- final float[] sDPI = win.getPixelsPerMM(new float[2]);
- sDPI[0] *= 25.4f;
- sDPI[1] *= 25.4f;
- win.setTitle("GLWindow["+capsA+"], swapI "+swapInterval+", win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]);
- }
-
// public enum ResizeBy { GLWindow, Component, Frame };
protected void runTestGL(final GLCapabilitiesImmutable caps, final ResizeBy resizeBy, final FrameLayout frameLayout) throws InterruptedException, InvocationTargetException {
System.err.println("requested: vsync "+swapInterval+", "+caps);
@@ -265,12 +251,12 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
frame.addComponentListener(new ComponentListener() {
@Override
public void componentResized(final ComponentEvent e) {
- setTitle(frame, newtCanvasAWT, glWindow, caps);
+ NewtAWTReparentingKeyAdapter.setTitle(frame, newtCanvasAWT, glWindow);
}
@Override
public void componentMoved(final ComponentEvent e) {
- setTitle(frame, newtCanvasAWT, glWindow, caps);
+ NewtAWTReparentingKeyAdapter.setTitle(frame, newtCanvasAWT, glWindow);
}
@Override
@@ -301,32 +287,9 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
}
});
- glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter));
- glWindow.addKeyListener(new com.jogamp.newt.event.KeyAdapter() {
- @Override
- public void keyPressed(final KeyEvent e) {
- if( e.isAutoRepeat() ) {
- return;
- }
- if(e.getKeyChar()=='x') {
- final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]);
- final float[] reqSurfacePixelScale;
- if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
- reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
- } else {
- reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- }
- System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
- glWindow.setSurfaceScale(reqSurfacePixelScale);
- final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
- final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
- System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
- reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
- valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
- hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
- setTitle(frame, newtCanvasAWT, glWindow, caps);
- }
- } } );
+ final NewtAWTReparentingKeyAdapter newtDemoListener = new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter);
+ glWindow.addKeyListener(newtDemoListener);
+ glWindow.addMouseListener(newtDemoListener);
if( useAnimator ) {
animator.add(glWindow);
@@ -361,7 +324,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
- setTitle(frame, newtCanvasAWT, glWindow, caps);
+ NewtAWTReparentingKeyAdapter.setTitle(frame, newtCanvasAWT, glWindow);
if( null != rwsize ) {
Thread.sleep(500); // 500ms delay
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java
index eec6af1c0..d109c56cf 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java
@@ -37,17 +37,14 @@ import com.jogamp.newt.Display.PointerIcon;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.MouseAdapter;
-import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.NEWTDemoListener;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.Gamma;
import com.jogamp.opengl.util.PNGPixelRect;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -72,6 +69,7 @@ public class TestGearsES2SimpleNEWT extends UITestCase {
static final int swapInterval = 1;
static long duration = 500; // ms
+ static boolean opaque = true;
private void setTitle(final Window win, final GLCapabilitiesImmutable caps) {
final float[] sDPI = win.getPixelsPerMM(new float[2]);
@@ -183,156 +181,9 @@ public class TestGearsES2SimpleNEWT extends UITestCase {
idx++;
}
- glWindow.addKeyListener(new KeyAdapter() {
- int pointerIconIdx = 0;
- float gamma = 1f;
- float brightness = 0f;
- float contrast = 1f;
-
- @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.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- 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.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if( e.getKeySymbol()== KeyEvent.VK_G ) {
- new Thread() {
- public void run() {
- final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f );
- System.err.println("[set gamma]: "+gamma+" -> "+newGamma);
- if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) {
- gamma = newGamma;
- }
- } }.start();
- } else if(e.getKeyChar()=='a') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set alwaysontop pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
- System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='d') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- // while( null != glWindow.getExclusiveContextThread() ) ;
- System.err.println("[set undecorated pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
- glWindow.setUndecorated(!glWindow.isUndecorated());
- System.err.println("[set undecorated post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='s') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set position pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
- glWindow.setPosition(100, 100);
- System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='c') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set pointer-icon pre]");
- final PointerIcon currentPI = glWindow.getPointerIcon();
- final PointerIcon newPI;
- if( pointerIconIdx >= pointerIcons.length ) {
- newPI=null;
- pointerIconIdx=0;
- } else {
- newPI=pointerIcons[pointerIconIdx++];
- }
- glWindow.setPointerIcon( newPI );
- System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='i') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible());
- glWindow.setPointerVisible(!glWindow.isPointerVisible());
- System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='j') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
- glWindow.confinePointer(!glWindow.isPointerConfined());
- System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
- if(!glWindow.isPointerConfined()) {
- demo.setConfinedFixedCenter(false);
- }
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='J') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
- glWindow.confinePointer(!glWindow.isPointerConfined());
- System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
- demo.setConfinedFixedCenter(glWindow.isPointerConfined());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='w') {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse pos pre]");
- glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2);
- System.err.println("[set mouse pos post]");
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeyChar()=='x') {
- final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]);
- final float[] reqSurfacePixelScale;
- if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
- reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
- } else {
- reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- }
- System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
- glWindow.setSurfaceScale(reqSurfacePixelScale);
- final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
- final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
- System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
- reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
- valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
- hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
- setTitle(glWindow, caps);
- }
- }
- });
- glWindow.addMouseListener(new MouseAdapter() {
- public void mouseClicked(final MouseEvent e) {
- if(e.getClickCount() == 2 && e.getPointerCount() == 1) {
- glWindow.setFullscreen(!glWindow.isFullscreen());
- System.err.println("setFullscreen: "+glWindow.isFullscreen());
- }
- }
- });
+ final NEWTDemoListener newtDemoListener = new NEWTDemoListener(glWindow, pointerIcons);
+ glWindow.addKeyListener(newtDemoListener);
+ glWindow.addMouseListener(newtDemoListener);
animator.add(glWindow);
animator.start();
@@ -368,11 +219,20 @@ public class TestGearsES2SimpleNEWT extends UITestCase {
public void test01_GL2ES2() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
+ caps.setBackgroundOpaque(opaque);
runTestGL(caps, false);
}
public static void main(final String args[]) throws IOException {
duration = 1000000; // ~16 min by default per main launch
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-translucent")) {
+ opaque = false;
+ }
+ }
org.junit.runner.JUnitCore.main(TestGearsES2SimpleNEWT.class.getName());
}
}
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
index 0bdd51407..ae873eaf0 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -28,207 +28,96 @@
package com.jogamp.opengl.test.junit.newt.parenting;
import java.awt.Frame;
-import java.net.URLConnection;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
import com.jogamp.nativewindow.util.InsetsImmutable;
-
-import com.jogamp.common.util.IOUtil;
-import com.jogamp.newt.Display;
-import com.jogamp.newt.Display.PointerIcon;
+import com.jogamp.newt.Window;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.NEWTDemoListener;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-import com.jogamp.opengl.util.PNGPixelRect;
-public class NewtAWTReparentingKeyAdapter extends KeyAdapter {
+public class NewtAWTReparentingKeyAdapter extends NEWTDemoListener {
final Frame frame;
final NewtCanvasAWT newtCanvasAWT;
- final GLWindow glWindow;
- final QuitAdapter quitAdapter;
- PointerIcon[] pointerIcons = null;
- int pointerIconIdx = 0;
public NewtAWTReparentingKeyAdapter(final Frame frame, final NewtCanvasAWT newtCanvasAWT, final GLWindow glWindow, final QuitAdapter quitAdapter) {
+ super(glWindow, quitAdapter, null);
this.frame = frame;
this.newtCanvasAWT = newtCanvasAWT;
- this.glWindow = glWindow;
- this.quitAdapter = quitAdapter;
}
- public void keyReleased(final KeyEvent e) {
- if( !e.isPrintableKey() || e.isAutoRepeat() ) {
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() || e.isConsumed() ) {
return;
}
- if( e.getKeySymbol() == KeyEvent.VK_L ) {
- final com.jogamp.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null);
- final com.jogamp.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
- System.err.println("NewtCanvasAWT position: "+p0+", "+p1);
- } else if( e.getKeySymbol() == KeyEvent.VK_D ) {
- glWindow.setUndecorated(!glWindow.isUndecorated());
- } else if( e.getKeySymbol() == KeyEvent.VK_S ) {
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to 100/100");
- glWindow.setPosition(100, 100);
- } else {
- System.err.println("XXX glWin to 0/0");
- glWindow.setPosition(0, 0);
- }
- } else if( e.getKeySymbol() == KeyEvent.VK_F ) {
- if( null != quitAdapter ) {
- quitAdapter.enable(false);
- }
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setFullscreen(!glWindow.isFullscreen());
- System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
- glWindow.setExclusiveContextThread(t);
- if( null != quitAdapter ) {
- quitAdapter.clear();
- quitAdapter.enable(true);
- }
- } }.start();
- } else if( e.getKeySymbol() == KeyEvent.VK_P ) {
- new Thread() {
- public void run() {
- if(glWindow.getAnimator().isPaused()) {
- glWindow.getAnimator().resume();
- } else {
- glWindow.getAnimator().pause();
- }
- }
- }.run();
- } else if( e.getKeySymbol() == KeyEvent.VK_A ) {
- new Thread() {
- public void run() {
- glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
- }
- }.run();
- } else if( e.getKeySymbol() == KeyEvent.VK_R ) {
- if( null != quitAdapter ) {
- quitAdapter.enable(false);
- }
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- if(glWindow.getParent()==null) {
- System.err.println("XXX glWin to HOME");
- glWindow.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */);
- } else {
- if( null != frame ) {
- final InsetsImmutable nInsets = glWindow.getInsets();
- final java.awt.Insets aInsets = frame.getInsets();
- int dx, dy;
- if( nInsets.getTotalHeight()==0 ) {
- dx = aInsets.left;
- dy = aInsets.top;
+ if( 0 == e.getModifiers() ) { // all modifiers go to super class ..
+ final int keySymbol = e.getKeySymbol();
+ switch (keySymbol) {
+ case KeyEvent.VK_L:
+ e.setConsumed(true);
+ final com.jogamp.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null);
+ final com.jogamp.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
+ printlnState("[location]", "AWT "+p0+", NEWT "+p1);
+ break;
+ case KeyEvent.VK_R:
+ e.setConsumed(true);
+ quitAdapterOff();
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ if(glWindow.getParent()==null) {
+ printlnState("[reparent pre - glWin to HOME]");
+ glWindow.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */);
+ } else {
+ if( null != frame ) {
+ final InsetsImmutable nInsets = glWindow.getInsets();
+ final java.awt.Insets aInsets = frame.getInsets();
+ int dx, dy;
+ if( nInsets.getTotalHeight()==0 ) {
+ dx = aInsets.left;
+ dy = aInsets.top;
+ } else {
+ dx = nInsets.getLeftWidth();
+ dy = nInsets.getTopHeight();
+ }
+ final int topLevelX = frame.getX()+frame.getWidth()+dx;
+ final int topLevelY = frame.getY()+dy;
+ printlnState("[reparent pre - glWin to TOP.1]", topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets);
+ glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */);
} else {
- dx = nInsets.getLeftWidth();
- dy = nInsets.getTopHeight();
+ printlnState("[reparent pre - glWin to TOP.0]");
+ glWindow.reparentWindow(null, -1, -1, 0 /* hints */);
}
- final int topLevelX = frame.getX()+frame.getWidth()+dx;
- final int topLevelY = frame.getY()+dy;
- System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets);
- glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */);
- } else {
- System.err.println("XXX glWin to TOP.0");
- glWindow.reparentWindow(null, -1, -1, 0 /* hints */);
- }
- }
- glWindow.requestFocus();
- glWindow.setExclusiveContextThread(t);
- if( null != quitAdapter ) {
- quitAdapter.clear();
- quitAdapter.enable(true);
- }
- } }.start();
- } else if(e.getKeySymbol() == KeyEvent.VK_C ) {
- if( null == pointerIcons ) {
- {
- pointerIcons = new PointerIcon[3];
- final Display disp = glWindow.getScreen().getDisplay();
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 8, 8);
- System.err.println("Create PointerIcon #01: "+_pointerIcon);
- } catch (final Exception ex) {
- ex.printStackTrace();
- }
- pointerIcons[0] = _pointerIcon;
- }
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } );
- try {
- _pointerIcon = disp.createPointerIcon(res, 0, 0);
- System.err.println("Create PointerIcon #02: "+_pointerIcon);
- } catch (final Exception ex) {
- ex.printStackTrace();
}
- pointerIcons[1] = _pointerIcon;
- }
- {
- PointerIcon _pointerIcon = null;
- final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } );
- try {
- final URLConnection urlConn = res.resolve(0);
- final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
- System.err.println("Create PointerIcon #03: "+image);
- _pointerIcon = disp.createPointerIcon(image, 32, 0);
- System.err.println("Create PointerIcon #03: "+_pointerIcon);
- } catch (final Exception ex) {
- ex.printStackTrace();
- }
- pointerIcons[2] = _pointerIcon;
- }
- }
- }
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set pointer-icon pre]");
- final PointerIcon currentPI = glWindow.getPointerIcon();
- final PointerIcon newPI;
- if( pointerIconIdx >= pointerIcons.length ) {
- newPI=null;
- pointerIconIdx=0;
- } else {
- newPI=pointerIcons[pointerIconIdx++];
- }
- glWindow.setPointerIcon( newPI );
- System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if( e.getKeySymbol() == KeyEvent.VK_I ) {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible());
- glWindow.setPointerVisible(!glWindow.isPointerVisible());
- System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeySymbol() == KeyEvent.VK_J ) {
- new Thread() {
- public void run() {
- final Thread t = glWindow.setExclusiveContextThread(null);
- System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
- glWindow.confinePointer(!glWindow.isPointerConfined());
- System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
- glWindow.setExclusiveContextThread(t);
- } }.start();
- } else if(e.getKeySymbol() == KeyEvent.VK_W ) {
- new Thread() {
- public void run() {
- System.err.println("[set mouse pos pre]");
- glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2);
- System.err.println("[set mouse pos post]");
- } }.start();
+ printlnState("[reparent post]");
+ glWindow.requestFocus();
+ glWindow.setExclusiveContextThread(t);
+ quitAdapterOn();
+ } }.start();
+ break;
+ }
+ }
+ super.keyPressed(e);
+ }
+
+ @Override
+ public void setTitle() {
+ setTitle(frame, newtCanvasAWT, glWindow);
+ }
+ public static void setTitle(final Frame frame, final NewtCanvasAWT glc, final Window win) {
+ final CapabilitiesImmutable chosenCaps = win.getChosenCapabilities();
+ final CapabilitiesImmutable reqCaps = win.getRequestedCapabilities();
+ final CapabilitiesImmutable caps = null != chosenCaps ? chosenCaps : reqCaps;
+ final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
+ {
+ final java.awt.Rectangle b = glc.getBounds();
+ frame.setTitle("NewtCanvasAWT["+capsA+"], win: ["+b.x+"/"+b.y+" "+b.width+"x"+b.height+"], pix: "+glc.getNativeWindow().getSurfaceWidth()+"x"+glc.getNativeWindow().getSurfaceHeight());
}
+ final float[] sDPI = win.getPixelsPerMM(new float[2]);
+ sDPI[0] *= 25.4f;
+ sDPI[1] *= 25.4f;
+ win.setTitle("GLWindow["+capsA+"], win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
new file mode 100644
index 000000000..33479569e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
@@ -0,0 +1,468 @@
+/**
+ * Copyright 2015 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.util;
+
+import java.net.URLConnection;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.ScalableSurface;
+import com.jogamp.newt.Display;
+import com.jogamp.newt.Display.PointerIcon;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.Gamma;
+import com.jogamp.opengl.util.PNGPixelRect;
+
+import jogamp.newt.driver.PNGIcon;
+
+public class NEWTDemoListener extends MouseAdapter implements KeyListener {
+ protected final GLWindow glWindow;
+ protected final QuitAdapter quitAdapter;
+ final PointerIcon[] pointerIcons;
+ int pointerIconIdx = 0;
+ float gamma = 1f;
+ float brightness = 0f;
+ float contrast = 1f;
+ boolean confinedFixedCenter = false;
+
+ public NEWTDemoListener(final GLWindow glWin, final QuitAdapter quitAdapter, final PointerIcon[] pointerIcons) {
+ this.glWindow = glWin;
+ this.quitAdapter = quitAdapter;
+ if( null != pointerIcons ) {
+ this.pointerIcons = pointerIcons;
+ } else {
+ this.pointerIcons = createPointerIcons(glWindow);
+ }
+ }
+ public NEWTDemoListener(final GLWindow glWin, final PointerIcon[] pointerIcons) {
+ this(glWin, null, pointerIcons);
+ }
+ public NEWTDemoListener(final GLWindow glWin) {
+ this(glWin, null, null);
+ }
+
+ protected void printlnState(final String prelude) {
+ System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString());
+ }
+ protected void printlnState(final String prelude, final String post) {
+ System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString()+", "+post);
+ }
+ protected void quitAdapterOff() {
+ if( null != quitAdapter ) {
+ quitAdapter.enable(false);
+ }
+ }
+ protected void quitAdapterOn() {
+ if( null != quitAdapter ) {
+ quitAdapter.clear();
+ quitAdapter.enable(true);
+ }
+ }
+
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() || e.isConsumed() ) {
+ return;
+ }
+ final int keySymbol = e.getKeySymbol();
+ switch(keySymbol) {
+ case KeyEvent.VK_SPACE:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ if(glWindow.getAnimator().isPaused()) {
+ glWindow.getAnimator().resume();
+ } else {
+ glWindow.getAnimator().pause();
+ }
+ }
+ }.run();
+ break;
+ case KeyEvent.VK_A:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set alwaysontop pre]");
+ glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
+ printlnState("[set alwaysontop post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_B:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set alwaysonbottom pre]");
+ glWindow.setAlwaysOnBottom(!glWindow.isAlwaysOnBottom());
+ printlnState("[set alwaysonbottom post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_C:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ if( null != pointerIcons ) {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set pointer-icon pre]");
+ final PointerIcon currentPI = glWindow.getPointerIcon();
+ final PointerIcon newPI;
+ if( pointerIconIdx >= pointerIcons.length ) {
+ newPI=null;
+ pointerIconIdx=0;
+ } else {
+ newPI=pointerIcons[pointerIconIdx++];
+ }
+ glWindow.setPointerIcon( newPI );
+ printlnState("[set pointer-icon post]", currentPI+" -> "+glWindow.getPointerIcon());
+ glWindow.setExclusiveContextThread(t);
+ }
+ } }.start();
+ break;
+ case KeyEvent.VK_D:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ // while( null != glWindow.getExclusiveContextThread() ) ;
+ printlnState("[set undecorated pre]");
+ glWindow.setUndecorated(!glWindow.isUndecorated());
+ printlnState("[set undecorated post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_F:
+ e.setConsumed(true);
+ quitAdapterOff();
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set fullscreen pre]");
+ if( glWindow.isFullscreen() ) {
+ glWindow.setFullscreen( false );
+ } else {
+ if( e.isAltDown() ) {
+ glWindow.setFullscreen( null );
+ } else {
+ glWindow.setFullscreen( true );
+ }
+ }
+ printlnState("[set fullscreen post]");
+ glWindow.setExclusiveContextThread(t);
+ quitAdapterOn();
+ } }.start();
+ break;
+ case KeyEvent.VK_G:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f );
+ System.err.println("[set gamma]: "+gamma+" -> "+newGamma);
+ if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) {
+ gamma = newGamma;
+ }
+ } }.start();
+ break;
+ case KeyEvent.VK_I:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set pointer-visible pre]");
+ glWindow.setPointerVisible(!glWindow.isPointerVisible());
+ printlnState("[set pointer-visible post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_J:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set pointer-confined pre]", "warp-center: "+e.isShiftDown());
+ final boolean confine = !glWindow.isPointerConfined();
+ glWindow.confinePointer(confine);
+ printlnState("[set pointer-confined post]", "warp-center: "+e.isShiftDown());
+ if( e.isShiftDown() ) {
+ setConfinedFixedCenter(confine);
+ } else if( !confine ) {
+ setConfinedFixedCenter(false);
+ }
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_M:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ // none: max-v
+ // alt: max-h
+ // shift: max-hv
+ // ctrl: max-off
+ final boolean horz, vert;
+ if( e.isControlDown() ) {
+ horz = false;
+ vert = false;
+ } else if( e.isShiftDown() ) {
+ final boolean anyMax = glWindow.isMaximizedHorz() || glWindow.isMaximizedVert();
+ horz = !anyMax;
+ vert = !anyMax;
+ } else if( !e.isAltDown() ) {
+ horz = glWindow.isMaximizedHorz();
+ vert = !glWindow.isMaximizedVert();
+ } else if( e.isAltDown() ) {
+ horz = !glWindow.isMaximizedHorz();
+ vert = glWindow.isMaximizedVert();
+ } else {
+ vert = glWindow.isMaximizedVert();
+ horz = glWindow.isMaximizedHorz();
+ }
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set maximize pre]", "max[vert "+vert+", horz "+horz+"]");
+ glWindow.setMaximized(horz, vert);
+ printlnState("[set maximize post]", "max[vert "+vert+", horz "+horz+"]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_P:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set position pre]");
+ glWindow.setPosition(100, 100);
+ printlnState("[set position post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_R:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set resizable pre]");
+ glWindow.setResizable(!glWindow.isResizable());
+ printlnState("[set resizable post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_S:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set sticky pre]");
+ glWindow.setSticky(!glWindow.isSticky());
+ printlnState("[set sticky post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_V:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final boolean wasVisible = glWindow.isVisible();
+ {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set visible pre]");
+ glWindow.setVisible(!wasVisible);
+ printlnState("[set visible post]");
+ glWindow.setExclusiveContextThread(t);
+ }
+ if( wasVisible ) {
+ try {
+ Thread.sleep(5000);
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ }
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[reset visible pre]");
+ glWindow.setVisible(true);
+ printlnState("[reset visible post]");
+ glWindow.setExclusiveContextThread(t);
+ }
+ } }.start();
+ break;
+ case KeyEvent.VK_W:
+ e.setConsumed(true);
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ printlnState("[set pointer-pos pre]");
+ glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2);
+ printlnState("[set pointer-pos post]");
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ break;
+ case KeyEvent.VK_X:
+ e.setConsumed(true);
+ final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]);
+ final float[] reqSurfacePixelScale;
+ if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
+ reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
+ } else {
+ reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
+ }
+ System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
+ glWindow.setSurfaceScale(reqSurfacePixelScale);
+ final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
+ final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
+ System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
+ reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
+ valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
+ setTitle();
+ }
+ }
+ @Override
+ public void keyReleased(final KeyEvent e) { }
+
+ public void setConfinedFixedCenter(final boolean v) {
+ confinedFixedCenter = v;
+ }
+ @Override
+ public void mouseMoved(final MouseEvent e) {
+ if( e.isConfined() ) {
+ mouseCenterWarp(e);
+ }
+ }
+ @Override
+ public void mouseDragged(final MouseEvent e) {
+ if( e.isConfined() ) {
+ mouseCenterWarp(e);
+ }
+ }
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ if(e.getClickCount() == 2 && e.getPointerCount() == 1) {
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ System.err.println("setFullscreen: "+glWindow.isFullscreen());
+ }
+ }
+ private void mouseCenterWarp(final MouseEvent e) {
+ if(e.isConfined() && confinedFixedCenter ) {
+ final int x=glWindow.getSurfaceWidth()/2;
+ final int y=glWindow.getSurfaceHeight()/2;
+ glWindow.warpPointer(x, y);
+ }
+ }
+
+ public void setTitle() {
+ setTitle(glWindow);
+ }
+ public static void setTitle(final GLWindow win) {
+ final CapabilitiesImmutable chosenCaps = win.getChosenCapabilities();
+ final CapabilitiesImmutable reqCaps = win.getRequestedCapabilities();
+ final CapabilitiesImmutable caps = null != chosenCaps ? chosenCaps : reqCaps;
+ final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
+ final float[] sDPI = win.getPixelsPerMM(new float[2]);
+ sDPI[0] *= 25.4f;
+ sDPI[1] *= 25.4f;
+ win.setTitle("GLWindow["+capsA+"], win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]);
+ }
+
+ public static PointerIcon[] createPointerIcons(final GLWindow glWindow) {
+ final PointerIcon[] pointerIcons = { null, null, null, null, null };
+ {
+ final Display disp = glWindow.getScreen().getDisplay();
+ disp.createNative();
+ int idx = 0;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 8, 8);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-red-alpha-64x64.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-blue-alpha-64x64.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ if( PNGIcon.isAvailable() ) {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } );
+ try {
+ final URLConnection urlConn = res.resolve(0);
+ final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, image.toString());
+ _pointerIcon = disp.createPointerIcon(image, 32, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ }
+ return pointerIcons;
+ }
+
+} \ No newline at end of file