aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-09-17 03:17:23 +0200
committerSven Gothel <[email protected]>2015-09-17 03:17:23 +0200
commitf2e1e9bb13679716148f45a66e99da0de114f4a1 (patch)
tree0d39a93af89067e7c98e04d7c9534c7a22666574
parent852faf012d8c6a93f65e0ebce87b3f70d8e2b6bf (diff)
Unit Tests: NEWTDemoListener: Less verbose; GraphUI-Demos: Show DPI and Pixel-Scale in GLEventListener.init(...)
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/util/NEWTDemoListener.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java4
8 files changed, 45 insertions, 30 deletions
diff --git a/src/newt/classes/com/jogamp/newt/opengl/util/NEWTDemoListener.java b/src/newt/classes/com/jogamp/newt/opengl/util/NEWTDemoListener.java
index 2444067d2..58484ca57 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/util/NEWTDemoListener.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/util/NEWTDemoListener.java
@@ -31,7 +31,6 @@ import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
-import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.util.IOUtil;
import com.jogamp.nativewindow.CapabilitiesImmutable;
import com.jogamp.nativewindow.ScalableSurface;
@@ -439,7 +438,7 @@ public class NEWTDemoListener extends WindowAdapter implements KeyListener, Mous
pointerIcons.add(_pointerIcon);
System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
} catch (final Exception e) {
- ExceptionUtils.dumpThrowable("", e);
+ System.err.println(e.getMessage());
}
}
{
@@ -450,7 +449,7 @@ public class NEWTDemoListener extends WindowAdapter implements KeyListener, Mous
pointerIcons.add(_pointerIcon);
System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
} catch (final Exception e) {
- ExceptionUtils.dumpThrowable("", e);
+ System.err.println(e.getMessage());
}
}
{
@@ -461,7 +460,7 @@ public class NEWTDemoListener extends WindowAdapter implements KeyListener, Mous
pointerIcons.add(_pointerIcon);
System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
} catch (final Exception e) {
- ExceptionUtils.dumpThrowable("", e);
+ System.err.println(e.getMessage());
}
}
{
@@ -472,7 +471,7 @@ public class NEWTDemoListener extends WindowAdapter implements KeyListener, Mous
pointerIcons.add(_pointerIcon);
System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
} catch (final Exception e) {
- ExceptionUtils.dumpThrowable("", e);
+ System.err.println(e.getMessage());
}
}
if( PNGIcon.isAvailable() ) {
@@ -480,13 +479,15 @@ public class NEWTDemoListener extends WindowAdapter implements KeyListener, Mous
final IOUtil.ClassResources res = new IOUtil.ClassResources(disp.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", pointerIcons.size()+1, image.toString());
- _pointerIcon = disp.createPointerIcon(image, 32, 0);
- pointerIcons.add(_pointerIcon);
- System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
+ if( null != urlConn ) {
+ final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
+ System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size()+1, image.toString());
+ _pointerIcon = disp.createPointerIcon(image, 32, 0);
+ pointerIcons.add(_pointerIcon);
+ System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
+ }
} catch (final Exception e) {
- ExceptionUtils.dumpThrowable("", e);
+ System.err.println(e.getMessage());
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
index b26ed88a8..2d3b0664e 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
@@ -47,6 +47,7 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -121,6 +122,17 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
@Override
public void init(final GLAutoDrawable drawable) {
+ final Object upObj = drawable.getUpstreamWidget();
+ if( upObj instanceof Window ) {
+ final Window window = (Window) upObj;
+ final float[] sDPI = window.getPixelsPerMM(new float[2]);
+ sDPI[0] *= 25.4f;
+ sDPI[1] *= 25.4f;
+ System.err.println("DPI "+sDPI[0]+" x "+sDPI[1]);
+
+ final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]);
+ System.err.println("HiDPI PixelScale: "+hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
+ }
autoDrawable = drawable;
GL2ES2 gl = drawable.getGL().getGL2ES2();
if(debug) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
index f7e779cd3..bf0a907b0 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
@@ -34,7 +34,6 @@ import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.opengl.GLWindow;
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
index c648708d4..945204052 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
@@ -165,9 +165,14 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
super.init(drawable);
final Object upObj = drawable.getUpstreamWidget();
if( upObj instanceof Window ) {
- final float[] pixelsPerMM = new float[2];
- ((Window)upObj).getPixelsPerMM(pixelsPerMM);
- dpiH = pixelsPerMM[1]*25.4f;
+ final Window window = (Window) upObj;
+ final float[] sDPI = window.getPixelsPerMM(new float[2]);
+ sDPI[0] *= 25.4f;
+ sDPI[1] *= 25.4f;
+ dpiH = sDPI[1];
+ System.err.println("Using screen DPI of "+dpiH);
+ } else {
+ System.err.println("Using default DPI of "+dpiH);
}
fontNameBox = font.getMetricBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
switchHeadBox();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index 3f5c5229e..33b7e2787 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -522,6 +522,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
mPlayer.setTextureUnit(texUnitMediaPlayer);
final MediaPlayerButton mPlayerButton = new MediaPlayerButton(renderer.getRenderState().getVertexFactory(), renderModes,
button2XSize, button2YSize, mPlayer);
+ mPlayerButton.setVerbose(true);
mPlayerButton.addDefaultEventListener();
mPlayerButton.translate(xStartRight, yStartTop - diffY*1, 0f);
mPlayerButton.setToggleable(true);
@@ -666,14 +667,17 @@ public class GPUUISceneGLListener0A implements GLEventListener {
if( upObj instanceof Window ) {
final Window upWin = (Window)upObj;
final MonitorDevice mm = upWin.getMainMonitor();
- final float[] monitorPixelsPerMM = mm.getPixelsPerMM(new float[2]);
- final float monitorDpiH = monitorPixelsPerMM[1]*25.4f;
- final float[] surfacePixelsPerMM = upWin.getPixelsPerMM(new float[2]);
- dpiH = surfacePixelsPerMM[1]*25.4f;
+ final float[] monitorDPI = mm.getPixelsPerMM(new float[2]);
+ monitorDPI[0] *= 25.4f;
+ monitorDPI[1] *= 25.4f;
+ final float[] sDPI = upWin.getPixelsPerMM(new float[2]);
+ sDPI[0] *= 25.4f;
+ sDPI[1] *= 25.4f;
+ dpiH = sDPI[1];
System.err.println("Monitor detected: "+mm);
- System.err.println("Monitor dpi: "+monitorDpiH);
+ System.err.println("Monitor dpi: "+monitorDPI[0]+" x "+monitorDPI[1]);
System.err.println("Surface scale: native "+Arrays.toString(upWin.getMaximumSurfaceScale(new float[2]))+", current "+Arrays.toString(upWin.getCurrentSurfaceScale(new float[2])));
- System.err.println("Surface dpi: "+dpiH);
+ System.err.println("Surface dpi "+sDPI[0]+" x "+sDPI[1]);
} else {
System.err.println("Using default DPI of "+dpiH);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
index 8b5b70239..721fe9cb0 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
@@ -180,10 +180,6 @@ public class GPUUISceneNewtCanvasAWTDemo {
frame.setVisible(true);
}
});
- final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]);
- System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
- valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
- hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
index aa6dd00cc..3053ed40a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
@@ -145,10 +145,6 @@ public class GPUUISceneNewtDemo {
});
window.setVisible(true);
- final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]);
- System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
- valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
- hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java
index 83fc6ca95..44e2c6034 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java
@@ -41,7 +41,7 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
* GPU based resolution independent {@link GLMediaPlayer} Button impl
*/
public class MediaPlayerButton extends TextureSeqButton {
- public boolean verbose = false;
+ private boolean verbose = false;
/**
* @param factory
@@ -62,6 +62,8 @@ public class MediaPlayerButton extends TextureSeqButton {
setEnabled(false); // data and shader n/a yet
}
+ public void setVerbose(final boolean v) { verbose = v; }
+
/**
* Add the default {@link GLMediaEventListener} to {@link #getGLMediaPlayer() this class's GLMediaPlayer}.
*/