aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-02-13 07:01:54 +0100
committerSven Gothel <[email protected]>2023-02-13 07:01:54 +0100
commit6d2009d33495a01ae3b59a4be6004c1a5e7007ad (patch)
tree1294462baa6b0ef3a2389e7fe6f4d878a0e8d4c1 /src/test/com/jogamp/opengl
parent93c51380f34c3eb203f46df52fed49a8a967510e (diff)
Graph Type Rendering: Drop pixelSize and use font em-size [0..1] throughout system.
- All pixelSize metrics methods are dropped in Font* - TypecastGlyph.Advance dropped, i.e. dropping prescales glyph advance based on pixelSize - TextRegionUtil produces OutlineShape in font em-size [0..1] added to GLRegion - Adjusted demos
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java45
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java29
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java107
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListener01.java (renamed from src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java)86
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java5
16 files changed, 196 insertions, 207 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
index 8a2284b67..be654d345 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
@@ -91,8 +91,8 @@ public class TestFontsNEWT00 extends UITestCase {
final float s0_em = font.getAdvanceWidth(glyphID);
final float s1_em = glyph.getAdvance();
- final float s0_px = font.getAdvanceWidth(glyphID, pixelSize);
- final float s1_px = glyph.getAdvance(pixelSize);
+ final float s0_px = s0_em * pixelSize;
+ final float s1_px = s1_em * pixelSize;
System.err.println(" Char '"+c+"', id "+glyphID+", font-px "+pixelSize+", unitsPerEM "+unitsPerEM+":");
System.err.println(" "+glyph);
@@ -102,7 +102,7 @@ public class TestFontsNEWT00 extends UITestCase {
System.err.println(" px "+s0_px+", "+s1_px);
System.err.println(" AABBox");
System.err.println(" funits "+glyph.getBBoxFU());
- System.err.println(" px "+glyph.getBBox(new AABBox(), pixelSize, new float[3]));
+ System.err.println(" em "+glyph.getBBox(new AABBox(), new float[3]));
Assert.assertEquals(s0, s1);
@@ -118,7 +118,6 @@ public class TestFontsNEWT00 extends UITestCase {
final int glyphid_left = font.getGlyphID(left);
final int glyphid_right = font.getGlyphID(right);
final Font.Glyph glyph_left = font.getGlyph(left);
- final Font.Glyph glyph_right = font.getGlyph(right);
final int k_val = glyph_left.getKerningFU(glyphid_right);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
index c5fe0b903..5db5c09ea 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
@@ -287,7 +287,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
final float fontSizeMin, fontSizeMax;
private long t0;
float fontSizeAnim, fontSizeDelta;
- float dpiH;
+ float dpiV, ppmmV;
TextRendererGLEL(final RenderState rs, final int renderModes, final int sampleCount) {
super(renderModes, new int[] { sampleCount });
@@ -340,7 +340,8 @@ public class TestTextRendererNEWT00 extends UITestCase {
final Window win = (Window)drawable.getUpstreamWidget();
final float[] pixelsPerMM = win.getPixelsPerMM(new float[2]);
final float[] dotsPerInch = FontScale.ppmmToPPI(pixelsPerMM, new float[2]);
- dpiH = dotsPerInch[1];
+ dpiV = dotsPerInch[1];
+ ppmmV = pixelsPerMM[1];
System.err.println(getFontInfo());
System.err.println("fontSize "+fontSizeFixed+", dotsPerMM "+pixelsPerMM[0]+"x"+pixelsPerMM[1]+", dpi "+dotsPerInch[0]+"x"+dotsPerInch[1]+", pixelSize "+FontScale.toPixels(fontSizeFixed, dotsPerInch[1] /* dpi display */));
}
@@ -358,7 +359,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
final String modeS = Region.getRenderModeString(renderModes);
final String bname = String.format((Locale)null, "%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
drawable.getChosenGLCapabilities().getNumSamples(),
- TestTextRendererNEWT00.fontSizeFixed, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, vbaaSampleCount[0]);
+ fontSizeFixed, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, vbaaSampleCount[0]);
final String filename = dir + bname +".png";
if(screenshot.readPixels(drawable.getGL(), false)) {
screenshot.write(new File(filename));
@@ -366,11 +367,12 @@ public class TestTextRendererNEWT00 extends UITestCase {
}
String getFontInfo() {
- final float unitsPerEM = font.getMetrics().getUnitsPerEM();
- return String.format("Font %s%n %s%nunitsPerEM %f (upem)",
- font.getFullFamilyName(),
- font.getName(Font.NAME_UNIQUNAME),
- unitsPerEM);
+ final float pixelSize = FontScale.toPixels(fontSizeFixed, dpiV);
+ final float mmSize = pixelSize / ppmmV;
+ final int unitsPerEM = font.getMetrics().getUnitsPerEM();
+ return String.format("Resolution dpiV %.2f, %.2f px/mm%nFont %s, unitsPerEM %d, size %.2f pt %.2f px %2f mm%n",
+ dpiV, ppmmV,
+ font.getFullFamilyName(),unitsPerEM, fontSizeFixed, pixelSize, mmSize);
}
@Override
@@ -395,8 +397,8 @@ public class TestTextRendererNEWT00 extends UITestCase {
fontSizeDelta *= -1f;
}
- final float pixelSize = FontScale.toPixels(fontSizeFixed, dpiH);
- final float pixelSizeAnim = FontScale.toPixels(fontSizeAnim, dpiH);
+ final float pixelSize = FontScale.toPixels(fontSizeFixed, dpiV);
+ final float pixelSizeAnim = FontScale.toPixels(fontSizeAnim, dpiV);
final String modeS = Region.getRenderModeString(renderModes);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
index 6211409f7..8826275b1 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -61,6 +61,8 @@ public class TestTextRendererNEWT01 extends UITestCase {
static final boolean DEBUG = false;
static final boolean TRACE = false;
static long duration = 100; // ms
+ static int win_width = 1024;
+ static int win_height = 640;
static int atoi(final String a) {
try {
@@ -73,6 +75,12 @@ public class TestTextRendererNEWT01 extends UITestCase {
if(args[i].equals("-time")) {
i++;
duration = atoi(args[i]);
+ } else if(args[i].equals("-width")) {
+ i++;
+ win_width = atoi(args[i]);
+ } else if(args[i].equals("-height")) {
+ i++;
+ win_height = atoi(args[i]);
}
}
final String tstname = TestTextRendererNEWT01.class.getName();
@@ -118,7 +126,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
caps.setAlphaBits(4);
System.err.println("Requested: "+caps);
- final GLWindow window = createWindow("text-vbaa1-msaa0", caps, 1024, 640);
+ final GLWindow window = createWindow("text-vbaa1-msaa0", caps, win_width, win_height);
window.display();
System.err.println("Chosen: "+window.getChosenGLCapabilities());
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
index cdd2bc750..5cabe546d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -52,6 +52,7 @@ import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.font.FontScale;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.test.junit.util.MiscUtils;
@@ -70,9 +71,11 @@ public class TestTextRendererNEWT10 extends UITestCase {
static boolean forceGL3 = false;
static boolean mainRun = false;
static boolean useMSAA = true;
+ static int win_width = 1024;
+ static int win_height = 640;
static Font font;
- static float fontSize = 24;
+ static float fontSize = 24; // in pixel
static String customStr = null;
@BeforeClass
@@ -95,6 +98,12 @@ public class TestTextRendererNEWT10 extends UITestCase {
if(args[i].equals("-time")) {
i++;
duration = atoi(args[i]);
+ } else if(args[i].equals("-width")) {
+ i++;
+ win_width = atoi(args[i]);
+ } else if(args[i].equals("-height")) {
+ i++;
+ win_height = atoi(args[i]);
} else if(args[i].equals("-noMSAA")) {
useMSAA = false;
} else if(args[i].equals("-es2")) {
@@ -157,7 +166,7 @@ public class TestTextRendererNEWT10 extends UITestCase {
System.err.println("Requested: "+caps);
System.err.println("Requested: "+Region.getRenderModeString(renderModes));
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, 800, 400, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, win_width, win_height, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -186,7 +195,17 @@ public class TestTextRendererNEWT10 extends UITestCase {
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
if( null == customStr ) {
- renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000, sampleCountIO);
+ {
+ final float[] pixelsPerMM = winctx.window.getPixelsPerMM(new float[2]);
+ final float[] dpi = FontScale.ppmmToPPI(pixelsPerMM, new float[2]);
+ final float mmSize = fontSize / pixelsPerMM[1];
+ final int unitsPerEM = font.getMetrics().getUnitsPerEM();
+ String txt = String.format("Resolution dpiV %.2f, %.2f px/mm", dpi[1], pixelsPerMM[1]);
+ renderString(drawable, gl, renderer, textRenderUtil, txt, 0, 0, -1000, sampleCountIO);
+ txt = String.format("Font %s, unitsPerEM %d, size %.2f px %2f mm", font.getFullFamilyName(), unitsPerEM, fontSize, mmSize);
+ renderString(drawable, gl, renderer, textRenderUtil, txt, 0, -1, -1000, sampleCountIO);
+ }
+ renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, -1, -1000, sampleCountIO);
renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000, sampleCountIO);
renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000, sampleCountIO);
renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000,sampleCountIO);
@@ -200,8 +219,9 @@ public class TestTextRendererNEWT10 extends UITestCase {
} else {
renderString(drawable, gl, renderer, textRenderUtil, customStr, 0, 0, -1000, sampleCountIO);
}
- drawable.swapBuffers();
+ gl.glFinish();
printScreen(renderModes, drawable, gl, false, sampleCount);
+ drawable.swapBuffers();
sleep();
@@ -218,23 +238,20 @@ public class TestTextRendererNEWT10 extends UITestCase {
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
final int height = drawable.getSurfaceHeight();
- int dx = 0;
- int dy = height;
+ float dx = 0;
+ float dy = height;
if(0>row) {
row = lastRow + 1;
}
- final AABBox textBox = font.getMetricBounds(text, fontSize);
- dx += font.getAdvanceWidth('X', fontSize) * column;
- dy -= (int)textBox.getHeight() * ( row + 1 );
+ final AABBox textBox = font.getMetricBounds(text); // em-size
+ dx += fontSize * font.getAdvanceWidth('X') * column;
+ dy -= fontSize * textBox.getHeight() * ( row + 1 );
final PMVMatrix pmv = renderer.getMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- {
- final float sxy = fontSize / font.getMetrics().getUnitsPerEM();
- pmv.glScalef(sxy, sxy, 1.0f);
- }
+ pmv.glScalef(fontSize, fontSize, 1.0f);
textRenderUtil.drawString3D(gl, renderer, font, text, null, sampleCount);
lastRow = row;
@@ -249,7 +266,7 @@ public class TestTextRendererNEWT10 extends UITestCase {
final String modeS = Region.getRenderModeString(renderModes);
final String bname = String.format((Locale)null, "%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
drawable.getChosenGLCapabilities().getNumSamples(),
- TestTextRendererNEWT10.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
+ fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
final String filename = dir + bname +".png";
if(screenshot.readPixels(gl, false)) {
screenshot.write(new File(filename));
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
index 2c7967dd1..445d233d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
@@ -188,14 +188,14 @@ public class TestTextRendererNEWTBugXXXX extends UITestCase {
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final Font font, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
final int height = drawable.getSurfaceHeight();
- int dx = 0;
- int dy = height;
+ float dx = 0;
+ float dy = height;
if(0>row) {
row = lastRow + 1;
}
- final AABBox textBox = font.getMetricBounds(text, fontSize);
- dx += font.getAdvanceWidth('X', fontSize) * column;
- dy -= (int)textBox.getHeight() * ( row + 1 );
+ final AABBox textBox = font.getMetricBounds(text);
+ dx += fontSize * font.getAdvanceWidth('X') * column;
+ dy -= fontSize * textBox.getHeight() * ( row + 1 );
final PMVMatrix pmv = renderer.getMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
index 866a522ac..6bc120cde 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -249,10 +249,11 @@ public abstract class TextRendererGLELBase implements GLEventListener {
final int height = drawable.getSurfaceHeight();
dy = height-ty;
}
+ final float sxy = pixelScale * pixelSize;
final int newLineCount = TextRegionUtil.getCharCount(text, '\n');
- final float lineHeight = font.getLineHeight(pixelSize);
- dx += pixelScale * font.getAdvanceWidth('X', pixelSize) * column;
- dy -= pixelScale * lineHeight * ( row + 1 );
+ final float lineHeight = font.getLineHeight();
+ dx += sxy * font.getAdvanceWidth('X') * column;
+ dy -= sxy * lineHeight * ( row + 1 );
final PMVMatrix pmvMatrix = rs.getMatrix();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
@@ -262,7 +263,6 @@ public abstract class TextRendererGLELBase implements GLEventListener {
pmvMatrix.glLoadIdentity();
}
pmvMatrix.glTranslatef(dx, dy, tz);
- final float sxy = ( pixelScale * pixelSize ) / font.getMetrics().getUnitsPerEM();
if( flipVerticalInGLOrientation && drawable.isGLOriented() ) {
pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f);
} else {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
index 401450fdb..ade84b3a3 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
@@ -139,10 +139,10 @@ public class GPUTextNewtDemo {
final float[] sDPI = FontScale.perMMToPerInch( window.getPixelsPerMM(new float[2]) );
final float font_ptpi = 12f;
final float font_ppi = FontScale.toPixels(font_ptpi, sDPI[1]);
- final AABBox fontNameBox = font.getMetricBounds(GPUTextRendererListenerBase01.textX1, font_ppi);
+ final AABBox fontNameBox = font.getMetricBounds(GPUTextRendererListenerBase01.textX1);
System.err.println("GPU Text Newt Demo: "+font.fullString());
System.err.println("GPU Text Newt Demo: screen-dpi: "+sDPI[0]+"x"+sDPI[1]+", font "+font_ptpi+" pt, "+font_ppi+" pixel");
- System.err.println("GPU Text Newt Demo: textX2: "+fontNameBox+" pixel");
+ System.err.println("GPU Text Newt Demo: textX2: "+fontNameBox+" em, "+fontNameBox.scale(font_ppi, new float[3])+" px");
// window.setSurfaceSize((int)(fontNameBox.getWidth()*1.1f), (int)(fontNameBox.getHeight()*2f));
}
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 5ae940da7..abf7151d0 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
@@ -192,9 +192,10 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
headtext = textXLast;
}
if(resize && null != headtext) {
- headbox = font.getMetricBounds(headtext, FontScale.toPixels(fontSizeHead, dpiV));
+ headbox = font.getMetricBounds(headtext);
if( headtext != text_help ) {
- upsizeWindowSurface(upstream_window, true, (int)(headbox.getWidth()*1.1f), (int)(headbox.getHeight()*2f));
+ final float pxSz = FontScale.toPixels(fontSizeHead, dpiV);
+ upsizeWindowSurface(upstream_window, true, (int)(headbox.getWidth()*pxSz*1.1f), (int)(headbox.getHeight()*pxSz*2f));
}
}
}
@@ -230,7 +231,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
} else {
System.err.println("Using vertical default DPI of "+dpiV+", "+ppmmV+" pixel/mm");
}
- fontNameBox = font.getMetricBounds(fontName, FontScale.toPixels(fontSizeFName, dpiV));
+ fontNameBox = font.getMetricBounds(fontName);
setHeadBox(headType, true);
}
@@ -322,7 +323,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
// bottom, half line up
pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0);
{
- final float sxy = ( nearPlaneS * pixelSizeFPS ) / font.getMetrics().getUnitsPerEM();
+ final float sxy = nearPlaneS * pixelSizeFPS;
pmv.glScalef(sxy, sxy, 1.0f);
}
// No cache, keep region alive!
@@ -330,21 +331,21 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
textRegionUtil.tempT2);
}
- float dx = width-fontNameBox.getWidth()-font.getAdvanceWidth(Glyph.ID_SPACE, pixelSizeFName);
- float dy = height-fontNameBox.getHeight();
+ float dx = width - ( fontNameBox.getWidth() - font.getAdvanceWidth(Glyph.ID_SPACE) ) * pixelSizeFName;
+ float dy = height - fontNameBox.getHeight() * pixelSizeFName;
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
{
- final float sxy = ( nearPlaneS * pixelSizeFName ) / font.getMetrics().getUnitsPerEM();
+ final float sxy = nearPlaneS * pixelSizeFName;
pmv.glScalef(sxy, sxy, 1.0f);
}
// System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
textRegionUtil.drawString3D(gl, renderer, font, fontName, null, getSampleCount());
dx = 10f;
- dy += -fontNameBox.getHeight() - 10f;
+ dy += -fontNameBox.getHeight() * pixelSizeFName - 10f;
if(null != headtext) {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
@@ -352,14 +353,14 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
// System.err.printf("Head: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
{
- final float sxy = ( nearPlaneS * pixelSizeHead ) / font.getMetrics().getUnitsPerEM();
+ final float sxy = nearPlaneS * pixelSizeHead;
pmv.glScalef(sxy, sxy, 1.0f);
}
// pmv.glTranslatef(x0, y1, z0);
textRegionUtil.drawString3D(gl, renderer, font, headtext, null, getSampleCount());
}
- dy += -headbox.getHeight() - font.getLineHeight(pixelSizeCenter);
+ dy += ( -headbox.getHeight() - font.getLineHeight() ) * pixelSizeCenter;
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
@@ -368,7 +369,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
pmv.glTranslatef(getXTran(), getYTran(), getZTran());
pmv.glRotatef(getAngle(), 0, 1, 0);
{
- final float sxy = ( nearPlaneS * pixelSizeCenter ) / font.getMetrics().getUnitsPerEM();
+ final float sxy = nearPlaneS * pixelSizeCenter;
pmv.glScalef(sxy, sxy, 1.0f);
}
rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f);
@@ -406,7 +407,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
public void fontHeadIncr(final int v) {
fontSizeHead = Math.abs((fontSizeHead + v) % fontSizeModulo) ;
if(null != headtext) {
- headbox = font.getMetricBounds(headtext, FontScale.toPixels(fontSizeHead, dpiV));
+ headbox = font.getMetricBounds(headtext);
}
}
@@ -418,7 +419,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
fontSet = set;
font = _font;
fontName = font.getFullFamilyName();
- fontNameBox = font.getMetricBounds(fontName, FontScale.toPixels(fontSizeFName, dpiV));
+ fontNameBox = font.getMetricBounds(fontName);
return true;
}
} catch (final IOException ex) {
@@ -434,7 +435,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
fontSet = set;
font = _font;
fontName = font.getFullFamilyName()+" (head "+fontSizeHead+"pt)";
- fontNameBox = font.getMetricBounds(fontName, FontScale.toPixels(fontSizeFName, dpiV));
+ fontNameBox = font.getMetricBounds(fontName);
return true;
}
} catch (final IOException ex) {
@@ -448,7 +449,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
void dumpMatrix(final boolean bbox) {
System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeCenter);
if(bbox) {
- System.err.println("bbox: "+font.getMetricBounds(text2, nearPlaneS * FontScale.toPixels(fontSizeCenter, dpiV)));
+ System.err.println("bbox em: "+font.getMetricBounds(text2));
+ System.err.println("bbox px: "+font.getMetricBounds(text2).scale(nearPlaneS * FontScale.toPixels(fontSizeCenter, dpiV), new float[3]));
}
}
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 e92f18995..1a74264cd 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
@@ -80,9 +80,9 @@ public class GPUUISceneGLListener0A implements GLEventListener {
private final float buttonXSizePVP = 0.105f;
private final float fontSizePt = 10f;
/** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */
- private final float fontSizeFixedPVP = 0.046f;
+ private final float fontSizeFixedPVP = 0.03f;
/** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */
- private final float fontSizeFpsPVP = 0.038f;
+ private final float fontSizeFpsPVP = 0.03f;
private float dpiH = 96;
/**
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
index f7e6e3de9..eb86aba81 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
@@ -71,7 +71,7 @@ public class Label extends UIShape {
}
public float getLineHeight() {
- return font.getLineHeight(pixelSize);
+ return pixelSize * font.getLineHeight();
}
public void setPixelSize(final float pixelSize) {
@@ -102,13 +102,11 @@ public class Label extends UIShape {
@Override
protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) {
- final AffineTransform t_sxy = new AffineTransform(); // FIXME ?
- final float sxy = pixelSize / font.getMetrics().getUnitsPerEM();
- t_sxy.setToScale(sxy, sxy);
+ final AffineTransform t_sxy = new AffineTransform();
+ t_sxy.setToScale(pixelSize, pixelSize);
TextRegionUtil.processString(shapeVisitor, t_sxy, font, text, tempT1, tempT2);
final float[] ctr = box.getCenter();
setRotationOrigin( ctr[0], ctr[1], ctr[2]);
- // scale(sxy, sxy, 1f);
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java
index 6641ce8b4..c43714b31 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java
@@ -77,25 +77,21 @@ public class Label0 {
private final TextRegionUtil.ShapeVisitor shapeVisitor = new TextRegionUtil.ShapeVisitor() {
@Override
public void visit(final OutlineShape shape, final AffineTransform t) {
- final AffineTransform t1 = t.preConcatenate(tLeft);
- region.addOutlineShape(shape, t1, rgbaColor);
- box.resize(shape.getBounds(), t1, tmpV3);
+ region.addOutlineShape(shape, t, rgbaColor);
+ box.resize(shape.getBounds(), t, tmpV3);
}
};
private Region region;
- private AffineTransform tLeft;
public final AABBox addShapeToRegion(final float pixelSize, final Region region, final AffineTransform tLeft) {
box.reset();
this.region = region;
- this.tLeft = tLeft;
- final AffineTransform t_sxy = new AffineTransform(); // FIXME ?
- final float sxy = pixelSize / font.getMetrics().getUnitsPerEM();
- t_sxy.setToScale(sxy, sxy);
+ final AffineTransform t_sxy = new AffineTransform(tLeft);
+ final AffineTransform tmp = new AffineTransform();
+ t_sxy.scale(pixelSize, pixelSize, tmp);
TextRegionUtil.processString(shapeVisitor, t_sxy, font, text, tempT1, tempT2);
this.region = null;
- this.tLeft = null;
return box;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
index 39eab26e2..db1ec239a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
@@ -94,28 +94,31 @@ public class LabelButton extends RoundButton {
final float lPixelSize0 = 10f;
final float lw = width * ( 1f - spacingX ) ;
final float lh = height * ( 1f - spacingY ) ;
- final AABBox lbox0 = label.font.getMetricBounds(label.text, lPixelSize0);
- final float lsx = lw / lbox0.getWidth();
- final float lsy = lh / lbox0.getHeight();
- final float lPixelSize1 = lsx < lsy ? lPixelSize0 * lsx : lPixelSize0 * lsy;
+ final AABBox lbox0_em = label.font.getMetricBounds(label.text);
+ final float lsx = lw / lbox0_em.getWidth();
+ final float lsy = lh / lbox0_em.getHeight();
+ final float lPixelSize1 = lsx < lsy ? lsx : lsy;
if( DRAW_DEBUG_BOX ) {
- System.err.println("RIButton: spacing "+spacingX+", "+spacingY);
- System.err.println("RIButton: bbox "+box);
- System.err.println("RIButton: lbox "+lbox0+", "+label.text);
- System.err.println("RIButton: net-text "+lw+" x "+lh);
- System.err.println("RIButton: lsx "+lsx+", lsy "+lsy+": pixelSize "+lPixelSize0+" -> "+lPixelSize1);
+ final AABBox lbox0_px = new AABBox(lbox0_em).scale2(lPixelSize0, new float[3]);
+ System.err.println("RIButton: dim "+width+" x "+height+", spacing "+spacingX+", "+spacingY);
+ System.err.println("RIButton: net-text "+lw+" x "+lh+" px");
+ System.err.println("RIButton: shape "+box+" px");
+ System.err.println("RIButton: text "+lbox0_em+" em, "+label.text);
+ System.err.println("RIButton: text "+lbox0_px+" px, "+label.text);
+ System.err.println("RIButton: lscale "+lsx+" x "+lsy+": pixelSize "+lPixelSize0+" -> "+lPixelSize1);
}
- // Setting pixelSize based on actual text-box size
- final AABBox lbox1 = label.font.getPointsBounds(null, label.text, lPixelSize1);
+ // Setting left-corner transform using text-box in font em-size [0..1]
+ final AABBox lbox1_s = label.font.getPointsBounds(null, label.text).scale2(lPixelSize1, new float[3]);
// Center text .. (share same center w/ button)
- final float[] lctr = lbox1.getCenter();
+ final float[] lctr = lbox1_s.getCenter();
final float[] ctr = box.getCenter();
final float[] ltx = new float[] { ctr[0] - lctr[0], ctr[1] - lctr[1], 0f };
final AABBox lbox2 = label.addShapeToRegion(lPixelSize1, region, tempT1.setToTranslation(ltx[0], ltx[1]));
if( DRAW_DEBUG_BOX ) {
- System.err.printf("RIButton.0: lbox1 %s%n", lbox1);
+ System.err.printf("RIButton.0: tleft %f / %f, %f / %f%n", ltx[0], ltx[1], ltx[0] * lPixelSize1, ltx[1] * lPixelSize1);
+ System.err.printf("RIButton.0: lbox1 %s scaled%n", lbox1_s);
System.err.printf("RIButton.0: lbox2 %s%n", lbox2);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java
deleted file mode 100644
index 12f9793dc..000000000
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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.graph.demos.ui;
-
-import java.io.IOException;
-
-import com.jogamp.opengl.GL;
-import com.jogamp.opengl.GL2ES2;
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
-
-import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.font.Font;
-import com.jogamp.graph.font.FontFactory;
-import com.jogamp.graph.geom.SVertex;
-import com.jogamp.opengl.test.junit.graph.demos.MSAATool;
-import com.jogamp.opengl.util.PMVMatrix;
-
-public class UIGLListener01 extends UIListenerBase01 {
-
- public UIGLListener01 (final int renderModes, final RenderState rs, final boolean debug, final boolean trace) {
- super(renderModes, RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), debug, trace);
- setMatrix(-20, 00, 0f, -50);
- try {
- final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault();
- button = new LabelButton(SVertex.factory(), 0, font, "Click me!", 4f, 3f);
- button.translate(2,1,0);
- /** Button defaults !
- button.setLabelColor(1.0f,1.0f,1.0f);
- button.setButtonColor(0.6f,0.6f,0.6f);
- button.setCorner(1.0f);
- button.setSpacing(2.0f);
- */
- System.err.println(button);
- } catch (final IOException ex) {
- System.err.println("Caught: "+ex.getMessage());
- ex.printStackTrace();
- }
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- super.init(drawable);
-
- final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.setSwapInterval(1);
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glEnable(GL.GL_POLYGON_OFFSET_FILL);
-
- MSAATool.dump(drawable);
- }
-
- @Override
- public void display(final GLAutoDrawable drawable) {
- final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- final int[] sampleCount = { 4 };
- final float[] translate = button.getTranslate();
-
- final RegionRenderer regionRenderer = getRegionRenderer();
- final PMVMatrix pmv = regionRenderer.getMatrix();
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- pmv.glTranslatef(getXTran(), getYTran(), getZoom());
- pmv.glRotatef(getAngle(), 0, 1, 0);
- pmv.glTranslatef(translate[0], translate[1], 0);
- button.drawShape(gl, regionRenderer, sampleCount);
- }
-
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- final GL2ES2 gl = drawable.getGL().getGL2ES2();
- button.destroy(gl, getRegionRenderer());
- super.dispose(drawable);
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListener01.java
index ab5bfb926..f18491a2a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListener01.java
@@ -41,15 +41,21 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLPipelineFactory;
import com.jogamp.opengl.GLRunnable;
-
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.test.junit.graph.demos.MSAATool;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.PMVMatrix;
/**
*
@@ -61,7 +67,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
* - v: toggle v-sync
* - s: screenshot
*/
-public abstract class UIListenerBase01 implements GLEventListener {
+public class UIListener01 implements GLEventListener {
private final GLReadBufferUtil screenshot;
private final int renderModes;
private final RegionRenderer rRenderer;
@@ -84,12 +90,29 @@ public abstract class UIListenerBase01 implements GLEventListener {
boolean ignoreInput = false;
- public UIListenerBase01(final int renderModes, final RegionRenderer rRenderer, final boolean debug, final boolean trace) {
+ public UIListener01(final int renderModes, final RenderState rs, final boolean debug, final boolean trace) {
this.renderModes = renderModes;
- this.rRenderer = rRenderer;
+ this.rRenderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
this.debug = debug;
this.trace = trace;
this.screenshot = new GLReadBufferUtil(false, false);
+
+ setMatrix(-4, -2, 0f, -10);
+ try {
+ final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ button = new LabelButton(SVertex.factory(), 0, font, "Click me!", 4f, 2f);
+ button.translate(2,1,0);
+ /** Button defaults !
+ button.setLabelColor(1.0f,1.0f,1.0f);
+ button.setButtonColor(0.6f,0.6f,0.6f);
+ button.setCorner(1.0f);
+ button.setSpacing(2.0f);
+ */
+ System.err.println(button);
+ } catch (final IOException ex) {
+ System.err.println("Caught: "+ex.getMessage());
+ ex.printStackTrace();
+ }
}
public final RegionRenderer getRegionRenderer() { return rRenderer; }
@@ -106,6 +129,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
this.zoom = zoom;
}
+ @Override
public void init(final GLAutoDrawable drawable) {
autoDrawable = drawable;
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -117,8 +141,14 @@ public abstract class UIListenerBase01 implements GLEventListener {
}
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
getRegionRenderer().init(gl, renderModes);
+
+ gl.setSwapInterval(1);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glEnable(GL.GL_POLYGON_OFFSET_FILL);
+ MSAATool.dump(drawable);
}
+ @Override
public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -127,9 +157,32 @@ public abstract class UIListenerBase01 implements GLEventListener {
dumpMatrix();
}
+ @Override
+ public void display(final GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ final int[] sampleCount = { 4 };
+ final float[] translate = button.getTranslate();
+
+ final RegionRenderer regionRenderer = getRegionRenderer();
+ final PMVMatrix pmv = regionRenderer.getMatrix();
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmv.glLoadIdentity();
+ pmv.glTranslatef(getXTran(), getYTran(), getZoom());
+ pmv.glRotatef(getAngle(), 0, 1, 0);
+ pmv.glTranslatef(translate[0], translate[1], 0);
+ button.drawShape(gl, regionRenderer, sampleCount);
+ }
+
+ @Override
public void dispose(final GLAutoDrawable drawable) {
- autoDrawable = null;
final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ button.destroy(gl, getRegionRenderer());
+
+ autoDrawable = null;
screenshot.dispose(gl);
rRenderer.destroy(gl);
}
@@ -200,36 +253,44 @@ public abstract class UIListenerBase01 implements GLEventListener {
public class MouseAction implements MouseListener{
+ @Override
public void mouseClicked(final MouseEvent e) {
}
+ @Override
public void mouseEntered(final MouseEvent e) {
}
+ @Override
public void mouseExited(final MouseEvent e) {
}
+ @Override
public void mousePressed(final MouseEvent e) {
button.setLabelColor(0.8f,0.8f,0.8f);
button.setColor(0.1f, 0.1f, 0.1f, 1.0f);
}
+ @Override
public void mouseReleased(final MouseEvent e) {
button.setLabelColor(1.0f,1.0f,1.0f);
button.setColor(0.6f,0.6f,0.6f, 1.0f);
}
+ @Override
public void mouseMoved(final MouseEvent e) {
// TODO Auto-generated method stub
}
+ @Override
public void mouseDragged(final MouseEvent e) {
// TODO Auto-generated method stub
}
+ @Override
public void mouseWheelMoved(final MouseEvent e) {
// TODO Auto-generated method stub
@@ -238,28 +299,29 @@ public abstract class UIListenerBase01 implements GLEventListener {
}
public class KeyAction implements KeyListener {
+ @Override
public void keyPressed(final KeyEvent arg0) {
if(ignoreInput) {
return;
}
if(arg0.getKeyCode() == KeyEvent.VK_1){
- zoom(10);
+ zoom(2);
}
else if(arg0.getKeyCode() == KeyEvent.VK_2){
- zoom(-10);
+ zoom(-2);
}
else if(arg0.getKeyCode() == KeyEvent.VK_UP){
- move(0, -1);
+ move(0, 1);
}
else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){
- move(0, 1);
+ move(0, -1);
}
else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){
- move(1, 0);
+ move(-1, 0);
}
else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){
- move(-1, 0);
+ move(1, 0);
}
else if(arg0.getKeyCode() == KeyEvent.VK_4){
button.setSpacing(button.getSpacingX()-0.01f, button.getSpacingY()-0.005f);
@@ -316,6 +378,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
rotate(-1);
if(null != autoDrawable) {
autoDrawable.invoke(false, new GLRunnable() {
+ @Override
public boolean run(final GLAutoDrawable drawable) {
try {
final String type = Region.getRenderModeString(renderModes);
@@ -332,6 +395,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
}
}
}
+ @Override
public void keyReleased(final KeyEvent arg0) {}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
index 88dc1615f..d211a9b80 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
@@ -30,7 +30,7 @@ package com.jogamp.opengl.test.junit.graph.demos.ui;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
-
+import com.jogamp.common.util.InterruptSource;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.event.KeyAdapter;
@@ -64,7 +64,7 @@ public class UINewtDemo01 {
window.setSize(800, 400);
window.setTitle("GPU UI Newt Demo 01");
final RenderState rs = RenderState.createRenderState(SVertex.factory());
- final UIGLListener01 uiGLListener = new UIGLListener01 (0, rs, DEBUG, TRACE);
+ final UIListener01 uiGLListener = new UIListener01 (0, rs, DEBUG, TRACE);
uiGLListener.attachInputListenerTo(window);
window.addGLEventListener(uiGLListener);
window.setVisible(true);
@@ -74,13 +74,19 @@ public class UINewtDemo01 {
animator.add(window);
window.addKeyListener(new KeyAdapter() {
+ @Override
public void keyPressed(final KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_F4) {
- window.destroy();
+ new InterruptSource.Thread() {
+ @Override
+ public void run() {
+ window.destroy();
+ } }.start();
}
}
});
window.addWindowListener(new WindowAdapter() {
+ @Override
public void windowDestroyed(final WindowEvent e) {
animator.stop();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
index 716712d22..4976c78e8 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
@@ -48,7 +48,7 @@ import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.geom.AABBox;
public abstract class UIShape {
- public static final boolean DRAW_DEBUG_BOX = false;
+ public static final boolean DRAW_DEBUG_BOX = true;
protected static final int DIRTY_SHAPE = 1 << 0 ;
protected static final int DIRTY_STATE = 1 << 1 ;
@@ -280,7 +280,7 @@ public abstract class UIShape {
region.clear(gl);
}
addShapeToRegion(gl, renderer);
- if( DRAW_DEBUG_BOX ) {
+ if( false && DRAW_DEBUG_BOX ) {
region.clear(gl);
final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
shape.setSharpness(shapesSharpness);
@@ -436,6 +436,7 @@ public abstract class UIShape {
this.objPos = objPos;
}
+ @Override
public String toString() {
return "EventDetails[winPos ["+glWinX+", "+glWinY+"], objPos ["+objPos[0]+", "+objPos[1]+", "+objPos[2]+"], "+shape+"]";
}