diff options
Diffstat (limited to 'src/test/com')
20 files changed, 481 insertions, 293 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java index a1cd54de2..de5fe8eb2 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java @@ -97,13 +97,13 @@ public class TestRegionRendererNEWT01 extends UITestCase { RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01"); window.addGLEventListener(listener); - listener.setTech(-20, 00, 0f, -300, 400); + listener.setTech(-20, 0, -300, 0f, 2); window.display(); - listener.setTech(-20, 00, 0f, -150, 800); + listener.setTech(-20, 0, -150, 0f, 3); window.display(); - listener.setTech(-20, 00, 0f, -50, 1000); + listener.setTech(-20, 0, -50, 0f, 4); window.display(); destroyWindow(window); @@ -131,13 +131,13 @@ public class TestRegionRendererNEWT01 extends UITestCase { RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02"); window.addGLEventListener(listener); - listener.setTech(-20, 00, 0f, -300, 400); + listener.setTech(-20, 0, -300, 0f, 2); window.display(); - listener.setTech(-20, 00, 0f, -150, 800); + listener.setTech(-20, 0, -150, 0f, 3); window.display(); - listener.setTech(-20, 00, 0f, -50, 1000); + listener.setTech(-20, 0, -50, 0f, 4); window.display(); destroyWindow(window); @@ -162,13 +162,13 @@ public class TestRegionRendererNEWT01 extends UITestCase { RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01"); window.addGLEventListener(listener); - listener.setTech(-20, 00, 0f, -300, 400); + listener.setTech(-20, 00, -300, 0f, 2); window.display(); - listener.setTech(-20, 00, 0f, -150, 800); + listener.setTech(-20, 00, -150, 0f, 3); window.display(); - listener.setTech(-20, 00, 0f, -50, 1000); + listener.setTech(-20, 00, -50, 0f, 4); window.display(); destroyWindow(window); @@ -198,13 +198,13 @@ public class TestRegionRendererNEWT01 extends UITestCase { RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02"); window.addGLEventListener(listener); - listener.setTech(-20, 00, 0f, -300, 400); + listener.setTech(-20, 00, -300, 0f, 2); window.display(); - listener.setTech(-20, 00, 0f, -150, 800); + listener.setTech(-20, 00, -150, 0f, 3); window.display(); - listener.setTech(-20, 00, 0f, -50, 1000); + listener.setTech(-20, 00, -50, 0f, 4); window.display(); destroyWindow(window); @@ -225,20 +225,20 @@ public class TestRegionRendererNEWT01 extends UITestCase { GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400); RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 1140, false, false); + GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 4, false, false); demo02Listener.attachInputListenerTo(window); window.addGLEventListener(demo02Listener); RegionGLListener listener = new RegionGLListener(demo02Listener, window.getTitle(), "GPURegionNewtDemo02"); window.addGLEventListener(listener); - listener.setTech(-20, 00, 0f, -300, 400); + listener.setTech(-20, 00, -300, 0f, 2); window.display(); - listener.setTech(-20, 00, 0f, -150, 800); + listener.setTech(-20, 00, -150, 0f, 3); window.display(); - listener.setTech(-20, 00, 0f, -50, 1000); + listener.setTech(-20, 00, -50, 0f, 4); window.display(); destroyWindow(window); @@ -255,8 +255,8 @@ public class TestRegionRendererNEWT01 extends UITestCase { this.name = name; } - public void setTech(float xt, float yt, float angle, int zoom, int fboSize){ - impl.setMatrix(xt, yt, angle, zoom, fboSize); + public void setTech(float xt, float yt, int zt, float angle, int sampleCount){ + impl.setMatrix(xt, yt, zt, angle, sampleCount); } public void init(GLAutoDrawable drawable) { 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 2278447b9..0377739fe 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -29,8 +29,6 @@ package com.jogamp.opengl.test.junit.graph; import java.io.File; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; @@ -48,9 +46,14 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.GLRegion; 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.MonitorDevice; +import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -63,17 +66,18 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class TestTextRendererNEWT00 extends UITestCase { static final boolean DEBUG = false; static final boolean TRACE = false; - static long duration = 100; // ms - static boolean waitStartEnd = false; - static int msaaSamples = 4; - static int swapInterval = 0; - - static final int[] texSize = new int[] { 0 }; - + static long Duration = 2000; // ms + static boolean WaitStartEnd = false; + static boolean TextAnim = false; + static int MSAASamples = 4; + static int VBAASamples = 4; + static int SwapInterval = 0; + + static String fontFileName = null; static int fontSet = 0; static int fontFamily = 0; static int fontStylebits = 0; - static float fontSizeFixed = 18f; + static float fontSizeFixed = 14f; static int atoi(String a) { try { @@ -85,7 +89,10 @@ public class TestTextRendererNEWT00 extends UITestCase { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { i++; - duration = atoi(args[i]); + Duration = atoi(args[i]); + } else if(args[i].equals("-fontFile")) { + i++; + fontFileName = args[i]; } else if(args[i].equals("-fontSet")) { i++; fontSet = atoi(args[i]); @@ -100,25 +107,33 @@ public class TestTextRendererNEWT00 extends UITestCase { fontSizeFixed = atoi(args[i]); } else if(args[i].equals("-msaa")) { i++; - msaaSamples = atoi(args[i]); + MSAASamples = atoi(args[i]); + VBAASamples = 0; + } else if(args[i].equals("-vbaa")) { + i++; + VBAASamples = atoi(args[i]); + MSAASamples = 0; + } else if(args[i].equals("-textAnim")) { + TextAnim = true; } else if(args[i].equals("-vsync")) { i++; - swapInterval = MiscUtils.atoi(args[i], swapInterval); + SwapInterval = MiscUtils.atoi(args[i], SwapInterval); } else if(args[i].equals("-wait")) { - waitStartEnd = true; + WaitStartEnd = true; } } - System.err.println("Font [set "+fontSet+", family "+fontFamily+", style "+fontStylebits+", size "+fontSizeFixed+"]"); - System.err.println("msaaSamples "+msaaSamples); - System.err.println("swapInterval "+swapInterval); + System.err.println("Font [set "+fontSet+", family "+fontFamily+", style "+fontStylebits+", size "+fontSizeFixed+"], fontFileName "+fontFileName); + System.err.println("msaaSamples "+MSAASamples); + System.err.println("vbaaSamples "+VBAASamples); + System.err.println("swapInterval "+SwapInterval); String tstname = TestTextRendererNEWT00.class.getName(); org.junit.runner.JUnitCore.main(tstname); } static void sleep() { try { - System.err.println("** new frame ** (sleep: "+duration+"ms)"); - Thread.sleep(duration); + System.err.println("** new frame ** (sleep: "+Duration+"ms)"); + Thread.sleep(Duration); } catch (InterruptedException ie) {} } @@ -143,6 +158,18 @@ public class TestTextRendererNEWT00 extends UITestCase { @Test public void testTextRendererMSAA01() throws InterruptedException { + if( MSAASamples > 0 ) { + testTextRendererImpl(MSAASamples, 0); + } + } + @Test + public void testTextRendererVBAA01() throws InterruptedException { + if( VBAASamples > 0 ) { + testTextRendererImpl(0, VBAASamples); + } + } + + public void testTextRendererImpl(final int msaaSamples, final int vbaaSampleCount) throws InterruptedException { GLProfile glp = GLProfile.get(GLProfile.GL2ES2); GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(4); @@ -150,21 +177,26 @@ public class TestTextRendererNEWT00 extends UITestCase { caps.setSampleBuffers(true); caps.setNumSamples(msaaSamples); } - System.err.println("Requested: "+caps); + System.err.println("Requested: "+caps+", vbaaSamples "+vbaaSampleCount); - GLWindow window = createWindow("text-vbaa0-msaa1", caps, 1024, 640); + GLWindow window = createWindow("text-vbaa"+vbaaSampleCount+"-msaa"+msaaSamples, caps, 1024, 640); window.display(); System.err.println("Chosen: "+window.getChosenGLCapabilities()); - if( waitStartEnd ) { + if( WaitStartEnd ) { UITestCase.waitForKey("Start"); } final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - final TextRendererGLEL textGLListener = new TextRendererGLEL(rs); + final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, vbaaSampleCount>0 ? Region.VBAA_RENDERING_BIT:0, vbaaSampleCount); System.err.println(textGLListener.getFontInfo()); window.addGLEventListener(textGLListener); + Animator anim = new Animator(); + anim.add(window); + anim.start(); + anim.setUpdateFPSFrames(60, null); + sleep(); window.invoke(true, new GLRunnable() { @Override public boolean run(GLAutoDrawable drawable) { @@ -177,13 +209,8 @@ public class TestTextRendererNEWT00 extends UITestCase { return true; } }); - Animator anim = new Animator(); - anim.add(window); - anim.start(); - anim.setUpdateFPSFrames(60, null); - sleep(); anim.stop(); - if( waitStartEnd ) { + if( WaitStartEnd ) { UITestCase.waitForKey("Stop"); } destroyWindow(window); @@ -202,14 +229,28 @@ public class TestTextRendererNEWT00 extends UITestCase { private final class TextRendererGLEL extends TextRendererGLELBase { private final GLReadBufferUtil screenshot; - private long t0; - final Font font = getFont(fontSet, fontFamily, fontStylebits); + private final GLRegion regionFPS, regionFPSAnim; + final Font font; final float fontSizeMin, fontSizeMax; + private long t0; float fontSizeAnim, fontSizeDelta; - - TextRendererGLEL(final RenderState rs) { - super(rs, true /* exclusivePMV */, 0); // Region.VBAA_RENDERING_BIT); - texSizeScale = 2; + float dpiH; + + TextRendererGLEL(final RenderState rs, final int renderModes, final int sampleCount) { + super(rs, true /* exclusivePMV */, renderModes, new int[] { sampleCount }); // Region.VBAA_RENDERING_BIT); + regionFPS = GLRegion.create(renderModes); + regionFPSAnim = GLRegion.create(renderModes); + if( null != fontFileName ) { + Font _font = null; + try { + _font = FontFactory.get(getClass(), fontFileName, false); + } catch (IOException e) { + e.printStackTrace(); + } + font = _font; + } else { + font = getFont(fontSet, fontFamily, fontStylebits); + } staticRGBAColor[0] = 0.0f; staticRGBAColor[1] = 0.0f; @@ -227,21 +268,31 @@ public class TestTextRendererNEWT00 extends UITestCase { @Override public void init(GLAutoDrawable drawable) { super.init(drawable); - drawable.getGL().setSwapInterval(swapInterval); + drawable.getGL().setSwapInterval(SwapInterval); t0 = Platform.currentTimeMillis(); + + final Window win = (Window)drawable.getUpstreamWidget(); + final MonitorDevice monitor = win.getMainMonitor(); + final float[] pixelsPerMM = new float[2]; + monitor.getPixelsPerMM(pixelsPerMM); + final float[] dotsPerInch = new float[] { pixelsPerMM[0]*25.4f, pixelsPerMM[1]*25.4f }; + dpiH = dotsPerInch[1]; + System.err.println(getFontInfo()); + System.err.println("fontSize "+fontSizeFixed+", dotsPerMM "+pixelsPerMM[0]+"x"+pixelsPerMM[1]+", dpi "+dotsPerInch[0]+"x"+dotsPerInch[1]+", pixelSize "+font.getPixelSize(fontSizeFixed, dotsPerInch[1] /* dpi display */)); } public void dispose(GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); screenshot.dispose(gl); + regionFPS.destroy(gl, renderer); + regionFPSAnim.destroy(gl, renderer); super.dispose(drawable); } public void printScreen(GLAutoDrawable drawable, String dir, String objName, boolean exportAlpha) throws GLException, IOException { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - pw.printf("%s-msaa%02d-fontsz%02.1f-%03dx%03d-T%04d", objName, msaaSamples, TestTextRendererNEWT00.fontSizeFixed, drawable.getWidth(), drawable.getHeight(), texSize[0]); - - final String filename = dir + sw +".png"; + final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-T%04d", objName, + drawable.getChosenGLCapabilities().getNumSamples(), + TestTextRendererNEWT00.fontSizeFixed, drawable.getWidth(), drawable.getHeight(), vbaaSampleCount[0]); + final String filename = dir + bname +".png"; if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } @@ -250,7 +301,7 @@ public class TestTextRendererNEWT00 extends UITestCase { String getFontInfo() { final float unitsPerEM_Inv = font.getMetrics().getScale(1f); final float unitsPerEM = 1f / unitsPerEM_Inv; - return String.format("Font %s%n %s%nunitsPerEM %f", + return String.format("Font %s%n %s%nunitsPerEM %f (upem)", font.getFullFamilyName(null).toString(), font.getName(Font.NAME_UNIQUNAME), unitsPerEM); @@ -278,27 +329,33 @@ public class TestTextRendererNEWT00 extends UITestCase { fontSizeDelta *= -1f; } - final float fontSize = fontSizeFixed; + final float pixelSize = font.getPixelSize(fontSizeFixed, dpiH); + final float pixelSizeAnim = font.getPixelSize(fontSizeAnim, dpiH); - final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f", - lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSize); - final String text1A = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f", - lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeAnim); + final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, vba-samples %d", + lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeFixed, + drawable.getChosenGLCapabilities().getNumSamples(), vbaaSampleCount[0]); + final String text1A = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, vba-samples %d", + lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeAnim, + drawable.getChosenGLCapabilities().getNumSamples(), vbaaSampleCount[0]); if( false ) { - // renderString(drawable, font, fontSize, textX2, 0, 0, 0, 0, -1000, false); - renderString(drawable, font, fontSize, "0", 0, 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, getFontInfo(), 0, 0, 0, 0, -1000f, true); + renderString(drawable, font, pixelSize, textX2, 0, 0, 0, -1000f, true); + renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000f, false); // no-cache } else { - renderString(drawable, font, fontSize, getFontInfo(), 0, 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "012345678901234567890123456789", 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "Hello World", 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "4567890123456", 4, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "I like JogAmp", 4, 0, 0, -1000, true); - renderString(drawable, font, fontSize, "Hello World", 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, textX2, 0, 0, 0, -1000, true); - renderString(drawable, font, fontSize, text1, 0, 0, 0, -1000, false); // no-cache - renderString(drawable, font, fontSizeAnim, text1A, 0, 0, 0, -1000, false); // no-cache + renderString(drawable, font, pixelSize, getFontInfo(), 0, 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "Hello World", 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "4567890123456", 4, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "I like JogAmp", 4, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, "Hello World", 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, textX2, 0, 0, 0, -1000, true); + renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000, regionFPS); // no-cache + if( TextAnim ) { + renderString(drawable, font, pixelSizeAnim, text1A, 0, 0, 0, -1000, regionFPSAnim); // no-cache + } } } }; 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 619fe23c5..a0bebeae6 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -46,7 +46,6 @@ import com.jogamp.common.os.Platform; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.curve.opengl.TextRenderUtil; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.geom.SVertex; import com.jogamp.newt.opengl.GLWindow; @@ -127,29 +126,29 @@ public class TestTextRendererNEWT01 extends UITestCase { window.addGLEventListener(textGLListener); if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) { - textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2); + textGLListener.setTech(-400, -30, 0f, -1000, 2); window.display(); sleep(); - textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3); + textGLListener.setTech(-400, -30, 0f, -380, 3); window.display(); sleep(); - textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4); + textGLListener.setTech(-400, -20, 0f, -80, 4); window.display(); sleep(); } if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) { - textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2); + textGLListener.setTech(-400, -30, 0f, -1000, 2); window.display(); sleep(); - textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3); + textGLListener.setTech(-400, -30, 0f, -380, 3); window.display(); sleep(); - textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4); + textGLListener.setTech(-400, -20, 0f, -80, 4); window.display(); sleep(); } @@ -180,11 +179,11 @@ public class TestTextRendererNEWT01 extends UITestCase { window.display(); sleep(); - textGLListener.setTech(-400, -30, 0, -380, 0); + textGLListener.setTech(-400, -30, 0, -380, 0); window.display(); sleep(); - textGLListener.setTech(-400, -20, 0, -80, 0); + textGLListener.setTech(-400, -20, 0, -80, 0); window.display(); sleep(); } @@ -194,11 +193,11 @@ public class TestTextRendererNEWT01 extends UITestCase { window.display(); sleep(); - textGLListener.setTech(-400, -30, 0, -380, 0); + textGLListener.setTech(-400, -30, 0, -380, 0); window.display(); sleep(); - textGLListener.setTech(-400, -20, 0, -80, 0); + textGLListener.setTech(-400, -20, 0, -80, 0); window.display(); sleep(); } @@ -210,15 +209,15 @@ public class TestTextRendererNEWT01 extends UITestCase { String winTitle; public TextGLListener(RenderState rs, int type, boolean debug, boolean trace) { - super(rs, type, debug, trace); + super(rs, type, 4, debug, trace); } public void attachInputListenerTo(GLWindow window) { super.attachInputListenerTo(window); winTitle = window.getTitle(); } - public void setTech(float xt, float yt, float angle, int zoom, int fboSize){ - setMatrix(xt, yt, angle, zoom, fboSize); + public void setTech(float xt, float yt, float angle, int zoom, int sampleCount){ + setMatrix(xt, yt, zoom, angle, sampleCount); } public void init(GLAutoDrawable drawable) { 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 e6840e43d..d002de5e9 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -34,6 +34,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; @@ -47,7 +48,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; public abstract class TextRendererGLELBase implements GLEventListener { public final int usrRenderModes; - protected final int[] texSize = new int[] { 0 }; + protected final int[] vbaaSampleCount; protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f }; /** @@ -66,7 +67,6 @@ public abstract class TextRendererGLELBase implements GLEventListener { /** scale pixel, default is 1f */ protected float pixelScale = 1.0f; - protected int texSizeScale = 2; boolean flipVerticalInGLOrientation = false; @@ -85,11 +85,25 @@ public abstract class TextRendererGLELBase implements GLEventListener { return null; } - public TextRendererGLELBase(final int renderModes) { + /** + * + * @param renderModes + * @param sampleCount desired multisampling sample count for msaa-rendering. + */ + public TextRendererGLELBase(final int renderModes, int[] sampleCount) { this.usrRenderModes = renderModes; + this.vbaaSampleCount = sampleCount; } - public TextRendererGLELBase(final RenderState rs, final boolean exclusivePMVMatrix, final int renderModes) { - this(renderModes); + + /** + * + * @param rs + * @param exclusivePMVMatrix + * @param renderModes + * @param sampleCount desired multisampling sample count for msaa-rendering. + */ + public TextRendererGLELBase(final RenderState rs, final boolean exclusivePMVMatrix, final int renderModes, int[] sampleCount) { + this(renderModes, sampleCount); this.rs = rs; this.exclusivePMVMatrix = exclusivePMVMatrix; } @@ -106,9 +120,6 @@ public abstract class TextRendererGLELBase implements GLEventListener { } this.renderer = RegionRenderer.create(rs, usrRenderModes); this.textRenderUtil = new TextRegionUtil(renderer); - if( 0 == usrRenderModes ) { - texSizeScale = 0; - } final GL2ES2 gl = drawable.getGL().getGL2ES2(); renderer.init(gl); renderer.setAlpha(gl, staticRGBAColor[3]); @@ -131,7 +142,6 @@ public abstract class TextRendererGLELBase implements GLEventListener { renderer.reshapeNotify(gl, width, height); } st.useProgram(gl, false); - texSize[0] = width * texSizeScale; } } @@ -148,17 +158,63 @@ public abstract class TextRendererGLELBase implements GLEventListener { int lastRow = -1; + /** + * + * @param drawable + * @param font + * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size. + * @param text + * @param column + * @param tx + * @param ty + * @param tz + * @param cacheRegion + */ public void renderString(GLAutoDrawable drawable, - Font font, float fontSize, String text, + Font font, float pixelSize, String text, int column, float tx, float ty, float tz, boolean cacheRegion) { final int row = lastRow + 1; - renderString(drawable, font, fontSize, text, column, row, tx, ty, tz, cacheRegion); + renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion, null); + } + + public void renderString(GLAutoDrawable drawable, + Font font, float pixelSize, String text, + int column, float tx, float ty, float tz, GLRegion region) { + final int row = lastRow + 1; + renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, false, region); } + /** + * + * @param drawable + * @param font + * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size. + * @param text + * @param column + * @param row + * @param tx + * @param ty + * @param tz + * @param cacheRegion + */ public void renderString(GLAutoDrawable drawable, - Font font, float fontSize, String text, + Font font, float pixelSize, String text, int column, int row, float tx, float ty, float tz, boolean cacheRegion) { + renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion, null); + } + + public void renderString(GLAutoDrawable drawable, + Font font, float pixelSize, String text, + int column, int row, + float tx, float ty, float tz, GLRegion region) { + renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, false, region); + } + + private void renderStringImpl(GLAutoDrawable drawable, + Font font, float pixelSize, String text, + int column, int row, + float tx, float ty, float tz, boolean cacheRegion, GLRegion region) { if( null != renderer ) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -172,8 +228,8 @@ public abstract class TextRendererGLELBase implements GLEventListener { dy = height-ty; } final int newLineCount = text.length() - text.replace("\n", "").length(); - final float lineHeight = font.getLineHeight(fontSize); - dx += pixelScale * font.getAdvanceWidth('X', fontSize) * column; + final float lineHeight = font.getLineHeight(pixelSize); + dx += pixelScale * font.getAdvanceWidth('X', pixelSize) * column; dy -= pixelScale * lineHeight * ( row + 1 ); final ShaderState st = rs.getShaderState(); @@ -195,9 +251,11 @@ public abstract class TextRendererGLELBase implements GLEventListener { } renderer.updateMatrix(gl); if( cacheRegion ) { - textRenderUtil.drawString3D(gl, font, fontSize, text, texSize); + textRenderUtil.drawString3D(gl, font, pixelSize, text, vbaaSampleCount); + } else if( null != region ) { + TextRegionUtil.drawString3D(region, renderer, gl, font, pixelSize, text, vbaaSampleCount); } else { - TextRegionUtil.drawString3D(renderer, gl, font, fontSize, text, texSize); + TextRegionUtil.drawString3D(renderer, gl, font, pixelSize, text, vbaaSampleCount); } st.useProgram(gl, false); gl.glDisable(GL2ES2.GL_BLEND); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java index 84c816b7a..6dd86e10c 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java @@ -47,9 +47,9 @@ import com.jogamp.graph.curve.opengl.RegionRenderer; public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { OutlineShape outlineShape = null; - public GPURegionGLListener01 (RenderState rs, int renderModes, int fbosize, boolean debug, boolean trace) { + public GPURegionGLListener01 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { super(rs, renderModes, debug, trace); - setMatrix(-20, 00, 0f, -50, fbosize); + setMatrix(-20, 00, -50, 0f, sampleCount); } private void createTestOutline(){ @@ -117,11 +117,11 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { final RegionRenderer regionRenderer = getRenderer(); regionRenderer.resetModelview(null); - regionRenderer.translate(null, getXTran(), getYTran(), getZoom()); + regionRenderer.translate(null, getXTran(), getYTran(), getZTran()); regionRenderer.rotate(gl, getAngle(), 0, 1, 0); if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - region.draw(gl, regionRenderer, getTexSize()); + region.draw(gl, regionRenderer, getSampleCount()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java index 83b37ac0b..d0afc8ad0 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java @@ -47,9 +47,9 @@ import com.jogamp.graph.curve.opengl.RegionRenderer; public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { List<OutlineShape> outlineShapes = new ArrayList<OutlineShape>(); - public GPURegionGLListener02 (RenderState rs, int renderModes, int fbosize, boolean debug, boolean trace) { + public GPURegionGLListener02 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { super(rs, renderModes, debug, trace); - setMatrix(-20, 00, 0f, -50, fbosize); + setMatrix(-20, 00, -50, 0f, sampleCount); } private void createTestOutline(){ @@ -119,12 +119,12 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { final RegionRenderer regionRenderer = getRenderer(); regionRenderer.resetModelview(null); - regionRenderer.translate(null, getXTran(), getYTran(), getZoom()); + regionRenderer.translate(null, getXTran(), getYTran(), getZTran()); regionRenderer.rotate(gl, getAngle(), 0, 1, 0); if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - region.draw(gl, regionRenderer, getTexSize()); + region.draw(gl, regionRenderer, getSampleCount()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java index d4f07a163..c6c4b62ce 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.graph.demos; -import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -46,14 +45,14 @@ import com.jogamp.opengl.util.glsl.ShaderState; /** Demonstrate the rendering of multiple outlines into one region/OutlineShape * These Outlines are not necessary connected or contained. * The output of this demo shows two identical shapes but the left one - * has some vertices with off-curve flag set to true, and the right allt he vertices - * are on the curve. Demos the Res. Independent Nurbs based Curve rendering + * has some vertices with off-curve flag set to true, and the right allt he vertices + * are on the curve. Demos the Res. Independent Nurbs based Curve rendering * */ public class GPURegionNewtDemo01 { static final boolean DEBUG = false; static final boolean TRACE = false; - + public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); @@ -61,25 +60,23 @@ public class GPURegionNewtDemo01 { caps.setSampleBuffers(true); caps.setNumSamples(4); // 2 samples is not enough .. System.out.println("Requested: " + caps); - + final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); window.setTitle("GPU Curve Region Newt Demo 01 - vbaa0 msaa1"); - + RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, Region.VARIABLE_CURVE_WEIGHT_BIT, 0, DEBUG, TRACE); - regionGLListener.attachInputListenerTo(window); + regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); - - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); //FPSAnimator animator = new FPSAnimator(60); final Animator animator = new Animator(); - animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.add(window); - + window.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if(arg0.getKeyCode() == KeyEvent.VK_F4) { @@ -92,7 +89,7 @@ public class GPURegionNewtDemo01 { animator.stop(); } }); - + animator.start(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java index 068498980..e7bd59aeb 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.graph.demos; -import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -50,31 +49,29 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class GPURegionNewtDemo02 { static final boolean DEBUG = false; static final boolean TRACE = false; - + public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); - caps.setAlphaBits(4); + caps.setAlphaBits(4); System.out.println("Requested: " + caps); - + final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); window.setTitle("GPU Curve Region Newt Demo 02 - vbaa1 msaa0"); - + RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPURegionGLListener02 regionGLListener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT|Region.VARIABLE_CURVE_WEIGHT_BIT, 1140, DEBUG, TRACE); - regionGLListener.attachInputListenerTo(window); + GPURegionGLListener02 regionGLListener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT|Region.VARIABLE_CURVE_WEIGHT_BIT, 4, DEBUG, TRACE); + regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); - - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); //FPSAnimator animator = new FPSAnimator(60); final Animator animator = new Animator(); - animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.add(window); - + window.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if(arg0.getKeyCode() == KeyEvent.VK_F4) { @@ -87,7 +84,7 @@ public class GPURegionNewtDemo02 { animator.stop(); } }); - + animator.start(); - } + } } 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 7041f9f91..8520b6dfd 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 @@ -42,7 +42,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLRunnable; - import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -80,8 +79,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { private float xTran = -10; private float yTran = 10; private float ang = 0f; - private float zoom = -70f; - private final int[] texSize = new int[] { 400 }; + private float zTran = -70f; + private final int[] sampleCount = new int[] { 4 }; protected volatile float weight = 1.0f; boolean ignoreInput = false; @@ -96,21 +95,22 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { public final RegionRenderer getRenderer() { return renderer; } public final int getRenderModes() { return renderModes; } - public final float getZoom() { return zoom; } + public final float getZTran() { return zTran; } public final float getXTran() { return xTran; } public final float getYTran() { return yTran; } public final float getAngle() { return ang; } - public final int[] getTexSize() { return texSize; } + public final int[] getSampleCount() { return sampleCount; } public final float[] getPosition() { return position; } - public void setMatrix(float xtrans, float ytrans, float angle, int zoom, int fbosize) { + public void setMatrix(float xtrans, float ytrans, int zTran, float angle, int sampleCount) { this.xTran = xtrans; this.yTran = ytrans; + this.zTran = zTran; this.ang = angle; - this.zoom = zoom; - this.texSize[0] = fbosize; + this.sampleCount[0] = sampleCount; } + @Override public void init(GLAutoDrawable drawable) { autoDrawable = drawable; GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -127,6 +127,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { getRenderer().init(gl); } + @Override public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) { GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -134,9 +135,10 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 7000.0f); dumpMatrix(); - System.err.println("Reshape: "+renderer.getRenderState()); + // System.err.println("Reshape: "+renderer.getRenderState()); } + @Override public void dispose(GLAutoDrawable drawable) { autoDrawable = null; GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -148,7 +150,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } public void zoom(int v){ - zoom += v; + zTran += v; dumpMatrix(); } @@ -171,7 +173,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } void dumpMatrix() { - System.err.println("Matrix: " + xTran + "/" + yTran + " x"+zoom + " @"+ang); + System.err.println("Matrix: " + xTran + " / " + yTran + " / "+zTran + " @ "+ang); } /** Attach the input listener to the window */ @@ -192,7 +194,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { public void printScreen(GLAutoDrawable drawable, String dir, String tech, String objName, boolean exportAlpha) throws GLException, IOException { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); - pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize[0], objName); + pw.printf("-%03dx%03d-Z%04d-S%02d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zTran), sampleCount[0], objName); final String filename = dir + tech + sw +".png"; if(screenshot.readPixels(drawable.getGL(), false)) { @@ -210,6 +212,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } public class KeyAction implements KeyListener { + @Override public void keyPressed(KeyEvent arg0) { if(ignoreInput) { return; @@ -228,18 +231,18 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { 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_6){ - texSize[0] -= 10; - System.err.println("Tex Size: " + texSize[0]); + sampleCount[0] -= 1; + System.err.println("Sample Count: " + sampleCount[0]); } else if(arg0.getKeyCode() == KeyEvent.VK_7){ - texSize[0] += 10; - System.err.println("Tex Size: " + texSize[0]); + sampleCount[0] += 1; + System.err.println("Sample Count: " + sampleCount[0]); } else if(arg0.getKeyCode() == KeyEvent.VK_0){ rotate(1); @@ -256,6 +259,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { else if(arg0.getKeyCode() == KeyEvent.VK_V) { if(null != autoDrawable) { autoDrawable.invoke(false, new GLRunnable() { + @Override public boolean run(GLAutoDrawable drawable) { GL gl = drawable.getGL(); int i = gl.getSwapInterval(); @@ -278,6 +282,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { rotate(-1); if(null != autoDrawable) { autoDrawable.invoke(false, new GLRunnable() { + @Override public boolean run(GLAutoDrawable drawable) { try { final String type = Region.isVBAA(renderModes) ? "vbaa0-msaa1" : "vbaa1-msaa0" + ( Region.isNonUniformWeight(renderModes) ? "-vc" : "-uc" ) ; @@ -294,6 +299,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } } } + @Override public void keyReleased(KeyEvent arg0) {} } } 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 05914b5bf..04920b579 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 @@ -40,12 +40,11 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { public GPUTextGLListener0A() { - this( RenderState.createRenderState(new ShaderState(), SVertex.factory()), 0, 0, false, false ) ; + this( RenderState.createRenderState(new ShaderState(), SVertex.factory()), 0, 4, false, false ) ; } - public GPUTextGLListener0A(RenderState rs, int numpass, int fbosize, boolean debug, boolean trace) { - super(rs, numpass, debug, trace); - setMatrix(-400, -30, 0f, -500, fbosize); + public GPUTextGLListener0A(RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { + super(rs, renderModes, sampleCount, debug, trace); } public void init(GLAutoDrawable drawable) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java index c58d10254..3253b3bc2 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java @@ -28,11 +28,9 @@ package com.jogamp.opengl.test.junit.graph.demos; -import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.geom.SVertex; import com.jogamp.newt.event.KeyAdapter; @@ -46,7 +44,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class GPUTextNewtDemo01 { static final boolean DEBUG = false; static final boolean TRACE = false; - + public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); @@ -54,21 +52,20 @@ public class GPUTextNewtDemo01 { caps.setSampleBuffers(true); caps.setNumSamples(4); // 2 samples is not enough .. System.out.println("Requested: "+caps); - - final GLWindow window = GLWindow.create(caps); + + final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); window.setTitle("GPU Text Newt Demo 01 - vbaa0 msaa1"); - + final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, 0, 0, DEBUG, TRACE); window.addGLEventListener(textGLListener); - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); - + final Animator animator = new Animator(); - animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.add(window); - + window.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if(arg0.getKeyCode() == KeyEvent.VK_F4) { @@ -81,9 +78,9 @@ public class GPUTextNewtDemo01 { animator.stop(); } }); - + window.setVisible(true); // FPSAnimator animator = new FPSAnimator(10); animator.start(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java index 59d235537..7b8839d29 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java @@ -27,7 +27,6 @@ */ package com.jogamp.opengl.test.junit.graph.demos; -import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -45,42 +44,40 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class GPUTextNewtDemo02 { /** * FIXME: - * + * * If DEBUG is enabled: - * - * Caused by: javax.media.opengl.GLException: Thread[main-Display-X11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glFramebufferRenderbuffer(<int> 0x8D40, <int> 0x1902, <int> 0x8D41, <int> 0x1): GL_INVALID_ENUM ( 1280 0x500), + * + * Caused by: javax.media.opengl.GLException: Thread[main-Display-X11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glFramebufferRenderbuffer(<int> 0x8D40, <int> 0x1902, <int> 0x8D41, <int> 0x1): GL_INVALID_ENUM ( 1280 0x500), * at javax.media.opengl.DebugGL4bc.checkGLGetError(DebugGL4bc.java:33961) * at javax.media.opengl.DebugGL4bc.glFramebufferRenderbuffer(DebugGL4bc.java:33077) * at jogamp.graph.curve.opengl.VBORegion2PGL3.initFBOTexture(VBORegion2PGL3.java:295) */ static final boolean DEBUG = false; static final boolean TRACE = false; - + public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); - + GLCapabilities caps = new GLCapabilities(glp); - caps.setAlphaBits(4); + caps.setAlphaBits(4); System.out.println("Requested: "+caps); - + final GLWindow window = GLWindow.create(caps); - + window.setPosition(10, 10); - window.setSize(800, 400); + window.setSize(800, 400); window.setTitle("GPU Text Newt Demo 02 - vbaa1 msaa0"); - + RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.VBAA_RENDERING_BIT, window.getWidth()*3, DEBUG, TRACE); + GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.VBAA_RENDERING_BIT, 4, DEBUG, TRACE); // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32); window.addGLEventListener(textGLListener); - - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); // FPSAnimator animator = new FPSAnimator(60); final Animator animator = new Animator(); - animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.add(window); - + window.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if(arg0.getKeyCode() == KeyEvent.VK_F4) { @@ -93,7 +90,7 @@ public class GPUTextNewtDemo02 { animator.stop(); } }); - + animator.start(); - } + } } 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 d50a089cd..3126517d3 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 @@ -35,15 +35,18 @@ import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLException; -import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.opengl.util.PMVMatrix; /** * @@ -62,14 +65,18 @@ import com.jogamp.opengl.math.geom.AABBox; * - i: live input text input (CR ends it, backspace supported) */ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerBase01 { - public final TextRegionUtil textRenderUtil; + public final TextRegionUtil textRegionUtil; + final GLRegion regionFPS; int fontSet = FontFactory.UBUNTU; Font font; int headType = 0; - boolean drawFPS = false; - final int fontSizeFixed = 6; - int fontSize = 40; + boolean drawFPS = true; + final float fontSizeFName = 8f; + final float fontSizeFPS = 12f; + float fontSizeHead = 12f; + float fontSizeBottom = 16f; + float dpiH = 96; final int fontSizeModulo = 100; String fontName; AABBox fontNameBox; @@ -82,6 +89,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB "JOGAMP graph demo using Resolution Independent NURBS\n"+ "JOGAMP JOGL - OpenGL ES2 profile\n"+ "Press 1/2 to zoom in/out the below text\n"+ + "Press 3/4 to incr/decs font size (alt: head, w/o bottom)\n"+ "Press 6/7 to edit texture size if using VBAA\n"+ "Press 0/9 to rotate the below string\n"+ "Press v to toggle vsync\n"+ @@ -96,25 +104,25 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB "Morbi quis bibendum nibh. Donec lectus orci, sagittis in consequat nec, volutpat nec nisi.\n"+ "Donec ut dolor et nulla tristique varius. In nulla magna, fermentum id tempus quis, semper \n"+ "in lorem. Maecenas in ipsum ac justo scelerisque sollicitudin. Quisque sit amet neque lorem,\n" + - "-------Press H to change text---------\n"; + "-------Press H to change text---------"; StringBuilder userString = new StringBuilder(); boolean userInput = false; - public GPUTextRendererListenerBase01(RenderState rs, int renderModes, boolean debug, boolean trace) { + public GPUTextRendererListenerBase01(RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { super(RegionRenderer.create(rs, renderModes), renderModes, debug, trace); - this.textRenderUtil = new TextRegionUtil(this.getRenderer()); + this.textRegionUtil = new TextRegionUtil(this.getRenderer()); + this.regionFPS = GLRegion.create(renderModes); try { this.font = FontFactory.get(fontSet).getDefault(); dumpFontNames(); this.fontName = font.toString(); - this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*2); - switchHeadBox(); } catch (IOException ioe) { System.err.println("Catched: "+ioe.getMessage()); ioe.printStackTrace(); } + setMatrix(0, 0, 0, 0f, sampleCount); } void dumpFontNames() { @@ -141,10 +149,31 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB headtext = text1; } if(null != headtext) { - headbox = font.getStringBounds(headtext, fontSizeFixed*3); + headbox = font.getStringBounds(headtext, font.getPixelSize(fontSizeHead, dpiH)); } } + @Override + public void init(GLAutoDrawable drawable) { + super.init(drawable); + final Object upObj = drawable.getUpstreamWidget(); + if( upObj instanceof Window ) { + final float[] pixelsPerMM = new float[2]; + ((Window)upObj).getMainMonitor().getPixelsPerMM(pixelsPerMM); + dpiH = pixelsPerMM[1]*25.4f; + } + fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH)); + switchHeadBox(); + + } + + @Override + public void dispose(GLAutoDrawable drawable) { + regionFPS.destroy(drawable.getGL().getGL2ES2(), getRenderer()); + super.dispose(drawable); + } + + @Override public void display(GLAutoDrawable drawable) { final int width = drawable.getWidth(); final int height = drawable.getHeight(); @@ -156,52 +185,98 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final RegionRenderer renderer = getRenderer(); renderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f); renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - final GLAnimatorControl animator = drawable.getAnimator(); - final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFPSFrames()>10; - if(_drawFPS) { - final float fps = animator.getTotalFPS(); - final String fpsS = String.valueOf(fps); - final int fpsSp = fpsS.indexOf('.'); + final float pixelSizeFName = font.getPixelSize(fontSizeFName, dpiH); + final float pixelSizeHead = font.getPixelSize(fontSizeHead, dpiH); + final float pixelSizeBottom = font.getPixelSize(fontSizeBottom, dpiH); + + if( drawFPS ) { + final float pixelSizeFPS = font.getPixelSize(fontSizeFPS, dpiH); + final float lfps, tfps, td; + final GLAnimatorControl animator = drawable.getAnimator(); + if( null != animator ) { + lfps = animator.getLastFPS(); + tfps = animator.getTotalFPS(); + td = animator.getTotalFPSDuration()/1000f; + } else { + lfps = 0f; + tfps = 0f; + td = 0f; + } + final String text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize [head %.1f, bottom %.1f], sampleCount %d, td %4.1f", + lfps, tfps, gl.getSwapInterval(), fontSizeHead, fontSizeBottom, getSampleCount()[0], td); renderer.resetModelview(null); - renderer.translate(gl, fontSizeFixed, fontSizeFixed, -6000); - TextRegionUtil.drawString3D(renderer, gl, font, fontSizeFixed*3, fpsS.substring(0, fpsSp+2)+" fps", getTexSize()); // no cache! + renderer.translate(gl, 0, pixelSizeFPS/2, -6000); // bottom, half line up + + // No cache, keep region alive! + TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, pixelSizeFPS, text, getSampleCount()); } - int dx = width-(int)fontNameBox.getWidth()-2 ; - int dy = height - 10; + float dx = width-fontNameBox.getWidth()-2f; + float dy = height - 10f; renderer.resetModelview(null); renderer.translate(gl, dx, dy, -6000); - textRenderUtil.drawString3D(gl, font, fontSizeFixed*2, fontName, getTexSize()); + textRegionUtil.drawString3D(gl, font, pixelSizeFName, fontName, getSampleCount()); - dx = 10; - dy += -(int)fontNameBox.getHeight() - 10; + dx = 10f; + dy += -fontNameBox.getHeight() - 10f; if(null != headtext) { renderer.resetModelview(null); renderer.translate(gl, dx, dy, -6000); - textRenderUtil.drawString3D(gl, font, fontSizeFixed*3, headtext, getTexSize()); + textRegionUtil.drawString3D(gl, font, pixelSizeHead, headtext, getSampleCount()); } - renderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f); + dy += -headbox.getHeight() - font.getLineHeight(pixelSizeBottom); + final float zNear = 0.1f, zFar = 7000f; + renderer.reshapePerspective(null, 45.0f, width, height, zNear, zFar); renderer.resetModelview(null); - renderer.translate(null, getXTran(), getYTran(), getZoom()); + + final float[] objPos = new float[3]; + { + // Dynamic layout between two projection matrices: + // Calculate object-position for perspective projection-matrix, + // to place the perspective bottom text below head. + final PMVMatrix pmv = renderer.getMatrix(); + final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; + final float zDistance = 500f; + final float winZ = (1f/zNear-1f/zDistance)/(1f/zNear-1f/zFar); + pmv.gluUnProject(dx, dy, winZ, view, 0, objPos, 0); + /** + System.err.printf("XXX %.1f/%.1f/%.1f --> [%.3f, %.3f, %.3f] + %.3f, %.3f %.3f -> %.3f, %.3f, %.3f%n", + dx, dy, winZ, objPos[0], objPos[1], objPos[2], + getXTran(), getYTran(), getZTran(), + objPos[0]+getXTran(), objPos[1]+getYTran(), objPos[2]+getZTran()); + */ + } + + // renderer.translate(null, objPos[0], objPos[1], objPos[2]); + renderer.translate(null, objPos[0]+getXTran(), objPos[1]+getYTran(), objPos[2]+getZTran()); + // renderer.translate(null, getXTran(), getYTran(), getZTran()); renderer.rotate(gl, getAngle(), 0, 1, 0); renderer.setColorStatic(gl, 1.0f, 0.0f, 0.0f); if(!userInput) { - textRenderUtil.drawString3D(gl, font, fontSize, text2, getTexSize()); + textRegionUtil.drawString3D(gl, font, pixelSizeBottom, text2, getSampleCount()); } else { - textRenderUtil.drawString3D(gl, font, fontSize, userString.toString(), getTexSize()); + textRegionUtil.drawString3D(gl, font, pixelSizeBottom, userString.toString(), getSampleCount()); } + } - public void fontIncr(int v) { - fontSize = Math.abs((fontSize + v) % fontSizeModulo) ; + public void fontBottomIncr(int v) { + fontSizeBottom = Math.abs((fontSizeBottom + v) % fontSizeModulo) ; dumpMatrix(true); } + public void fontHeadIncr(int v) { + fontSizeHead = Math.abs((fontSizeHead + v) % fontSizeModulo) ; + if(null != headtext) { + headbox = font.getStringBounds(headtext, font.getPixelSize(fontSizeHead, dpiH)); + } + } + public boolean nextFontSet() { try { int set = ( fontSet == FontFactory.UBUNTU ) ? FontFactory.JAVA : FontFactory.UBUNTU ; @@ -210,7 +285,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB fontSet = set; font = _font; fontName = font.getFullFamilyName(null).toString(); - fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3); + fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH)); dumpFontNames(); return true; } @@ -227,7 +302,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB fontSet = set; font = _font; fontName = font.getFullFamilyName(null).toString(); - fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3); + fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH)); dumpFontNames(); return true; } @@ -240,9 +315,9 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB public boolean isUserInputMode() { return userInput; } void dumpMatrix(boolean bbox) { - System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZoom() + " @"+getAngle() +" fontSize "+fontSize); + System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeBottom); if(bbox) { - System.err.println("bbox: "+font.getStringBounds(text2, fontSize)); + System.err.println("bbox: "+font.getStringBounds(text2, font.getPixelSize(fontSizeBottom, dpiH))); } } @@ -271,17 +346,28 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB printScreen(drawable, dir, tech, fn.replace(' ', '_'), exportAlpha); } + float fontHeadScale = 1f; + public class KeyAction implements KeyListener { + @Override public void keyPressed(KeyEvent e) { if(userInput) { return; } final short s = e.getKeySymbol(); if(s == KeyEvent.VK_3) { - fontIncr(10); + if( e.isAltDown() ) { + fontHeadIncr(1); + } else { + fontBottomIncr(1); + } } else if(s == KeyEvent.VK_4) { - fontIncr(-10); + if( e.isAltDown() ) { + fontHeadIncr(-1); + } else { + fontBottomIncr(-1); + } } else if(s == KeyEvent.VK_H) { switchHeadBox(); @@ -298,6 +384,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } } + @Override public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; 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 0c4d5fbbf..5de2e95a7 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 @@ -31,7 +31,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { private boolean trace = false; private final int renderModes; - private final int[] texSize = new int[1]; + private final int[] sampleCount = new int[1]; private final int renderModes2; private final int[] texSize2 = new int[1]; private RegionRenderer regionRenderer; @@ -77,7 +77,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { public GPUUISceneGLListener0A(RenderState rs, int renderModes, boolean debug, boolean trace) { this.rs = rs; this.renderModes = renderModes; - this.texSize[0] = Region.isVBAA(renderModes) ? 400 : 0; + this.sampleCount[0] = Region.isVBAA(renderModes) ? 4 : 0; this.renderModes2 = 0; this.texSize2[0] = 0; @@ -237,7 +237,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { initTexts(); initButtons(width, height); - sceneUIController.setRenderer(regionRenderer, rs, renderModes, texSize); + sceneUIController.setRenderer(regionRenderer, renderModes, sampleCount); sceneUIController.addShape(buttons[0]); sceneUIController.addShape(buttons[1]); sceneUIController.addShape(buttons[2]); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java index 8c64e1463..ea83c8e78 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java @@ -198,7 +198,7 @@ public abstract class RIButton extends UIShape { private boolean toggle =false; private boolean toggleable = false; - public void render(GL2ES2 gl, RegionRenderer renderer, int renderModes, int[/*1*/] texSize, boolean selection) { + public void render(GL2ES2 gl, RegionRenderer renderer, int renderModes, int[/*1*/] sampleCount, boolean selection) { if(null == buttonRegion) { buttonRegion = new UIRegion(this); labelRegion = new UIRegion(getLabel()); @@ -214,7 +214,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]); } - buttonRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, texSize); + buttonRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, sampleCount); gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL); float[] lColor = labelColor; @@ -224,7 +224,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]); } - labelRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, texSize); + labelRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, sampleCount); } public void setPressed(boolean b) { super.setPressed(b); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java index 08fd97ec4..7b62b72f9 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java @@ -12,50 +12,46 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLRunnable; import com.jogamp.common.nio.Buffers; -import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.opengl.GLWindow; public class SceneUIController implements GLEventListener{ - private ArrayList<UIShape> shapes = new ArrayList<UIShape>(); + private final ArrayList<UIShape> shapes = new ArrayList<UIShape>(); private int count = 0; - private int renderModes; - private int[] texSize; + private int renderModes; + private int[] sampleCount; private RegionRenderer renderer = null; - private RenderState rs = null; - private float[] translate = new float[3]; - private float[] scale = new float[3]; - private float[] rotation = new float[3]; + private final float[] translate = new float[3]; + private final float[] scale = new float[3]; + private final float[] rotation = new float[3]; + + private final float[] sceneClearColor = new float[]{0,0,0,1}; - private float[] sceneClearColor = new float[]{0,0,0,1}; - private int activeId = -1; - + private SBCMouseListener sbcMouseListener = null; - + private GLAutoDrawable cDrawable = null; public SceneUIController() { } - - public void setRenderer(RegionRenderer renderer, RenderState rs, int renderModes, int[] texSize) { + + public SceneUIController(RegionRenderer renderer, int renderModes, int[] sampleCount) { this.renderer = renderer; - this.rs = rs; this.renderModes = renderModes; - this.texSize = texSize; + this.sampleCount = sampleCount; } - - public SceneUIController(RegionRenderer renderer, RenderState rs, int renderModes, int[] texSize) { + + public void setRenderer(RegionRenderer renderer, int renderModes, int[] sampleCount) { this.renderer = renderer; - this.rs = rs; this.renderModes = renderModes; - this.texSize = texSize; + this.sampleCount = sampleCount; } - + public void attachInputListenerTo(GLWindow window) { if(null == sbcMouseListener) { sbcMouseListener = new SBCMouseListener(); @@ -68,7 +64,7 @@ public class SceneUIController implements GLEventListener{ window.removeMouseListener(sbcMouseListener); } } - + public ArrayList<UIShape> getShapes() { return shapes; } @@ -83,7 +79,7 @@ public class SceneUIController implements GLEventListener{ count--; } } - + public void init(GLAutoDrawable drawable) { System.err.println("SceneUIController: init"); cDrawable = drawable; @@ -94,9 +90,9 @@ public class SceneUIController implements GLEventListener{ final int height = drawable.getHeight(); GL2ES2 gl = drawable.getGL().getGL2ES2(); - render(gl, width, height, renderModes, texSize, false); + render(gl, width, height, renderModes, sampleCount, false); } - + public void dispose(GLAutoDrawable drawable) { System.err.println("SceneUIController: dispose"); cDrawable = null; @@ -107,7 +103,7 @@ public class SceneUIController implements GLEventListener{ int height) { System.err.println("SceneUIController: reshape"); GL2ES2 gl = drawable.getGL().getGL2ES2(); - renderer.reshapePerspective(gl, 45.0f, width, height, 5f, 70.0f); + renderer.reshapePerspective(gl, 45.0f, width, height, 5f, 70.0f); } public UIShape getShape(GLAutoDrawable drawable,int x, int y) { @@ -120,13 +116,13 @@ public class SceneUIController implements GLEventListener{ return null; return shapes.get(index); } - + public UIShape getActiveUI() { if(activeId == -1) return null; return shapes.get(activeId); } - + public void release() { activeId = -1; } @@ -152,9 +148,9 @@ public class SceneUIController implements GLEventListener{ return index; } - private void render(GL2ES2 gl, int width, int height, int renderModes, int[/*1*/] texSize, boolean select) { + private void render(GL2ES2 gl, int width, int height, int renderModes, int[/*1*/] sampleCount, boolean select) { renderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f); - + for(int index=0; index < count;index++){ if(select) { float color= index+1; @@ -168,8 +164,8 @@ public class SceneUIController implements GLEventListener{ renderer.rotate(gl, rotation[0], 1, 0, 0); renderer.rotate(gl, rotation[1], 0, 1, 0); renderer.rotate(gl, rotation[2], 0, 0, 1); - - shapes.get(index).render(gl, renderer, renderModes, texSize, select); + + shapes.get(index).render(gl, renderer, renderModes, sampleCount, select); renderer.rotate(gl, -rotation[0], 1, 0, 0); renderer.rotate(gl, -rotation[1], 0, 1, 0); renderer.rotate(gl, -rotation[2], 0, 0, 1); @@ -203,11 +199,11 @@ public class SceneUIController implements GLEventListener{ this.sceneClearColor[2] = b; this.sceneClearColor[3] = a; } - + private class SBCMouseListener implements MouseListener { int mouseX = -1; int mouseY = -1; - + public void mouseClicked(MouseEvent e) { UIShape uiShape = getActiveUI(); if(uiShape != null){ @@ -221,7 +217,7 @@ public class SceneUIController implements GLEventListener{ } mouseX = e.getX(); mouseY = e.getY(); - + GLRunnable runnable = new GLRunnable() { public boolean run(GLAutoDrawable drawable) { UIShape s = getShape(drawable, mouseX, mouseY); @@ -235,16 +231,16 @@ public class SceneUIController implements GLEventListener{ } }; cDrawable.invoke(true, runnable); - + UIShape uiShape = getActiveUI(); - + if(uiShape != null) { uiShape.setPressed(true); uiShape.onPressed(); } } - public void mouseReleased(MouseEvent e) { + public void mouseReleased(MouseEvent e) { UIShape uiShape = getActiveUI(); if(uiShape != null){ uiShape.setPressed(false); @@ -257,6 +253,6 @@ public class SceneUIController implements GLEventListener{ public void mouseExited(MouseEvent e) { } public void mouseDragged(MouseEvent e) { } public void mouseWheelMoved(MouseEvent e) { } - + } }
\ No newline at end of file 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 06a6f1e20..031d43e79 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 @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.graph.demos.ui; -import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -45,14 +44,14 @@ import com.jogamp.opengl.util.glsl.ShaderState; /** Demonstrate the rendering of multiple outlines into one region/OutlineShape * These Outlines are not necessary connected or contained. * The output of this demo shows two identical shapes but the left one - * has some vertices with off-curve flag set to true, and the right allt he vertices - * are on the curve. Demos the Res. Independent Nurbs based Curve rendering + * has some vertices with off-curve flag set to true, and the right allt he vertices + * are on the curve. Demos the Res. Independent Nurbs based Curve rendering * */ public class UINewtDemo01 { static final boolean DEBUG = false; static final boolean TRACE = false; - + public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); @@ -60,23 +59,21 @@ public class UINewtDemo01 { caps.setSampleBuffers(true); caps.setNumSamples(4); System.out.println("Requested: " + caps); - + final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); window.setTitle("GPU UI Newt Demo 01"); RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); UIGLListener01 uiGLListener = new UIGLListener01 (rs, DEBUG, TRACE); - uiGLListener.attachInputListenerTo(window); + uiGLListener.attachInputListenerTo(window); window.addGLEventListener(uiGLListener); - - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); final Animator animator = new Animator(); - animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.add(window); - + window.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if(arg0.getKeyCode() == KeyEvent.VK_F4) { @@ -89,7 +86,7 @@ public class UINewtDemo01 { animator.stop(); } }); - + animator.start(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java index 92e4fe001..c8e2acef3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java @@ -58,8 +58,7 @@ public abstract class GLReadBuffer00Base extends UITestCase { public TextRendererGLEL() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO - super(Region.VBAA_RENDERING_BIT); - texSizeScale = 2; + super(Region.VBAA_RENDERING_BIT, new int[] { 4 }); staticRGBAColor[0] = 1.0f; staticRGBAColor[1] = 1.0f; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 38cc96af4..d2f2edec6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -156,6 +156,8 @@ public class MovieCube implements GLEventListener { resetGLState = true; } + final int[] textSampleCount = { 4 }; + private final class InfoTextRendererGLELBase extends TextRendererGLELBase { static final float z_diff = 0.001f; final Font font = getFont(0, 0, 0); @@ -164,8 +166,7 @@ public class MovieCube implements GLEventListener { InfoTextRendererGLELBase() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO - super(Region.VBAA_RENDERING_BIT); - texSizeScale = 2; + super(Region.VBAA_RENDERING_BIT, MovieCube.this.textSampleCount); fontSize = 1; pixelScale = 1.0f / ( fontSize * 20f ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index a00b5da0c..5c8a62b14 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -131,13 +131,14 @@ public class MovieSimple implements GLEventListener { defURI = _defURI; } + final int[] textSampleCount = { 4 }; + private final class InfoTextRendererGLELBase extends TextRendererGLELBase { final Font font = getFont(0, 0, 0); final float fontSize = 18f; InfoTextRendererGLELBase() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO - super(Region.VBAA_RENDERING_BIT); - texSizeScale = 2; + super(Region.VBAA_RENDERING_BIT, textSampleCount); staticRGBAColor[0] = 1.0f; staticRGBAColor[1] = 1.0f; |