aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-01 16:47:30 +0100
committerSven Gothel <[email protected]>2014-03-01 16:47:30 +0100
commit183e1bc1868699b99eb9f9c8bf18d646d1120a48 (patch)
treee1ea001486615e7cc41e467a48f8fb3681444ac1 /src
parent7a1dbd0d87a15f582f568a20adbbe42505bdca33 (diff)
Bug 801: VBAA Render-Mode Based on SampleCount (not a user-based texWidth) ; Proper FontSize -> PixelSize
VBAA Render-Mode Based on SampleCount (not a user-based texWidth) - All Region based APIs now use 'sampleCount' instead of 'texWidth' - VBORegion2PES2 calculates perspective FBO width/height considering the sampleCount Proper FontSize -> PixelSize - Font: Add getPixelSize(fontSize, dpi) - Text* Demos/Classes: Use proper fontSize -> PixelSize
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java10
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java1
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java96
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java42
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontFactory.java21
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java127
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java2
-rw-r--r--src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java2
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java36
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java175
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java90
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java42
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java33
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java161
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java74
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java5
29 files changed, 708 insertions, 372 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 6d0e5e538..014b1641a 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -95,16 +95,16 @@ public abstract class GLRegion extends Region {
* of the region.
* @param matrix current {@link PMVMatrix}.
* @param renderer the {@link RegionRenderer} to be used
- * @param texWidth desired texture width for multipass-rendering.
- * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched.
+ * @param sampleCount desired multisampling sample count for msaa-rendering.
+ * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
*/
- public final void draw(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] texWidth) {
+ public final void draw(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] sampleCount) {
if(isDirty()) {
update(gl, renderer);
setDirty(false);
}
- drawImpl(gl, renderer, texWidth);
+ drawImpl(gl, renderer, sampleCount);
}
- protected abstract void drawImpl(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] texWidth);
+ protected abstract void drawImpl(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] sampleCount);
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index a9e258f36..92fa084cd 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -36,7 +36,6 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderState;
import com.jogamp.opengl.util.PMVMatrix;
-import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
/**
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
index 0d1e87ad1..dd668c927 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -55,22 +55,22 @@ public class TextRegionUtil {
}
/**
- * Add the string in 3D space w.r.t. the font and fontSize at the end of the {@link GLRegion}.
+ * Add the string in 3D space w.r.t. the font and pixelSize at the end of the {@link GLRegion}.
* @param region the {@link GLRegion} sink
* @param vertexFactory vertex impl factory {@link Factory}
* @param font the target {@link Font}
- * @param fontSize
+ * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
* @param str string text
*/
public static void addStringToRegion(final GLRegion region, final Factory<? extends Vertex> vertexFactory,
- final Font font, final float fontSize, final CharSequence str) {
+ final Font font, final float pixelSize, final CharSequence str) {
final int charCount = str.length();
// region.setFlipped(true);
final Font.Metrics metrics = font.getMetrics();
- final float lineHeight = font.getLineHeight(fontSize);
+ final float lineHeight = font.getLineHeight(pixelSize);
- final float scale = metrics.getScale(fontSize);
+ final float scale = metrics.getScale(pixelSize);
final AffineTransform transform = new AffineTransform(vertexFactory);
final AffineTransform t = new AffineTransform(vertexFactory);
@@ -83,7 +83,7 @@ public class TextRegionUtil {
y -= lineHeight;
advanceTotal = 0;
} else if (character == ' ') {
- advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, fontSize);
+ advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize);
} else {
if(Region.DEBUG_INSTANCE) {
System.err.println("XXXXXXXXXXXXXXx char: "+character+", scale: "+scale+"; translate: "+advanceTotal+", "+y);
@@ -99,66 +99,92 @@ public class TextRegionUtil {
}
region.addOutlineShape(glyphShape, t);
- advanceTotal += glyph.getAdvance(fontSize, true);
+ advanceTotal += glyph.getAdvance(pixelSize, true);
}
}
}
/**
- * Render the string in 3D space w.r.t. the font and fontSize
+ * Render the string in 3D space w.r.t. the font and pixelSize
* using a cached {@link GLRegion} for reuse.
* <p>
* Cached {@link GLRegion}s will be destroyed w/ {@link #clear(GL2ES2)} or to free memory.
* </p>
* @param gl the current GL state
* @param font {@link Font} to be used
- * @param fontSize font size
+ * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
* @param str text to be rendered
- * @param texSize desired texture width for multipass-rendering.
- * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched.
+ * @param sampleCount desired multisampling sample count for msaa-rendering.
+ * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @throws Exception if TextRenderer not initialized
*/
public void drawString3D(final GL2ES2 gl,
- final Font font, final float fontSize, final CharSequence str,
- final int[/*1*/] texSize) {
+ final Font font, final float pixelSize, final CharSequence str,
+ final int[/*1*/] sampleCount) {
if( !renderer.isInitialized() ) {
throw new GLException("TextRendererImpl01: not initialized!");
}
- final RenderState rs = renderer.getRenderState();
final int special = 0;
- GLRegion region = getCachedRegion(font, str, fontSize, special);
+ GLRegion region = getCachedRegion(font, str, pixelSize, special);
if(null == region) {
region = GLRegion.create(renderer.getRenderModes());
- addStringToRegion(region, rs.getVertexFactory(), font, fontSize, str);
- addCachedRegion(gl, font, str, fontSize, special, region);
+ addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str);
+ addCachedRegion(gl, font, str, pixelSize, special, region);
}
- region.draw(gl, renderer, texSize);
+ region.draw(gl, renderer, sampleCount);
}
/**
- * Render the string in 3D space w.r.t. the font and fontSize
+ * Render the string in 3D space w.r.t. the font and pixelSize
* using a temporary {@link GLRegion}, which will be destroyed afterwards.
+ * <p>
+ * In case of a multisampling region renderer, i.e. {@link Region#VBAA_RENDERING_BIT}, recreating the {@link GLRegion}
+ * is a huge performance impact.
+ * In such case better use {@link #drawString3D(GLRegion, RegionRenderer, GL2ES2, Font, float, CharSequence, int[])}
+ * instead.
+ * </p>
* @param gl the current GL state
* @param font {@link Font} to be used
- * @param fontSize font size
+ * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
* @param str text to be rendered
- * @param texWidth desired texture width for multipass-rendering.
- * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched.
+ * @param sampleCount desired multisampling sample count for msaa-rendering.
+ * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @throws Exception if TextRenderer not initialized
*/
public static void drawString3D(final RegionRenderer renderer, final GL2ES2 gl,
- final Font font, final float fontSize, final CharSequence str,
- final int[/*1*/] texSize) {
+ final Font font, final float pixelSize, final CharSequence str,
+ final int[/*1*/] sampleCount) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
- final RenderState rs = renderer.getRenderState();
final GLRegion region = GLRegion.create(renderer.getRenderModes());
- addStringToRegion(region, rs.getVertexFactory(), font, fontSize, str);
- region.draw(gl, renderer, texSize);
+ addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str);
+ region.draw(gl, renderer, sampleCount);
region.destroy(gl, renderer);
}
+ /**
+ * Render the string in 3D space w.r.t. the font and pixelSize
+ * using the given {@link GLRegion}, which will {@link GLRegion#clear(GL2ES2, RegionRenderer) cleared} beforehand.
+ * @param gl the current GL state
+ * @param font {@link Font} to be used
+ * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
+ * @param str text to be rendered
+ * @param sampleCount desired multisampling sample count for msaa-rendering.
+ * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
+ * @throws Exception if TextRenderer not initialized
+ */
+ public static void drawString3D(final GLRegion region, final RegionRenderer renderer, final GL2ES2 gl,
+ final Font font, final float pixelSize, final CharSequence str,
+ final int[/*1*/] sampleCount) {
+ if(!renderer.isInitialized()){
+ throw new GLException("TextRendererImpl01: not initialized!");
+ }
+ region.clear(gl, renderer);
+ addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str);
+ region.draw(gl, renderer, sampleCount);
+ }
+
/**
* Clear all cached {@link GLRegions}.
*/
@@ -213,13 +239,13 @@ public class TextRegionUtil {
}
}
- protected final GLRegion getCachedRegion(Font font, CharSequence str, float fontSize, int special) {
- return stringCacheMap.get(getKey(font, str, fontSize, special));
+ protected final GLRegion getCachedRegion(Font font, CharSequence str, float pixelSize, int special) {
+ return stringCacheMap.get(getKey(font, str, pixelSize, special));
}
- protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, float fontSize, int special, GLRegion glyphString) {
+ protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, float pixelSize, int special, GLRegion glyphString) {
if ( 0 != getCacheLimit() ) {
- final String key = getKey(font, str, fontSize, special);
+ final String key = getKey(font, str, pixelSize, special);
final GLRegion oldRegion = stringCacheMap.put(key, glyphString);
if ( null == oldRegion ) {
// new entry ..
@@ -229,8 +255,8 @@ public class TextRegionUtil {
}
}
- protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, int special) {
- final String key = getKey(font, str, fontSize, special);
+ protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int pixelSize, int special) {
+ final String key = getKey(font, str, pixelSize, special);
final GLRegion region = stringCacheMap.remove(key);
if(null != region) {
region.destroy(gl, renderer);
@@ -248,10 +274,10 @@ public class TextRegionUtil {
}
}
- protected final String getKey(Font font, CharSequence str, float fontSize, int special) {
+ protected final String getKey(Font font, CharSequence str, float pixelSize, int special) {
final StringBuilder sb = new StringBuilder();
return font.getName(sb, Font.NAME_UNIQUNAME)
- .append(".").append(str.hashCode()).append(".").append(Float.floatToIntBits(fontSize)).append(special).toString();
+ .append(".").append(str.hashCode()).append(".").append(Float.floatToIntBits(pixelSize)).append(special).toString();
}
/** Default cache limit, see {@link #setCacheLimit(int)} */
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 9758e4d41..2f21fd214 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -32,14 +32,28 @@ import com.jogamp.opengl.math.geom.AABBox;
/**
* Interface wrapper for font implementation.
- *
+ * <p>
* TrueType Font Specification:
- * http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html
- * http://www.microsoft.com/typography/SpecificationsOverview.mspx
- * http://www.microsoft.com/typography/otspec/
- *
+ * <ul>
+ * <li>http://www.freetype.org/freetype2/documentation.html</li>
+ * <li>http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html</li>
+ * <li>http://www.microsoft.com/typography/SpecificationsOverview.mspx</li>
+ * <li>http://www.microsoft.com/typography/otspec/</li>
+ * </ul>
+ * </p>
+ * <p>
* TrueType Font Table Introduction:
- * http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08
+ * <ul>
+ * <li>http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Misc.:
+ * <ul>
+ * <li>Treatis on Font <code>Rasterization https://freddie.witherden.org/pages/font-rasterisation/</code></li>
+ * <li>Glyph Hell <code>http://walon.org/pub/ttf/ttf_glyphs.htm</code></li>
+ * </ul>
+ * </p>
*/
public interface Font {
@@ -109,6 +123,22 @@ public interface Font {
public StringBuilder getAllNames(StringBuilder string, String separator);
+ /**
+ * <pre>
+ Font Scale Formula:
+ inch: 25.4 mm
+ pointSize: [point] = [1/72 inch]
+
+ [1] Scale := pointSize * resolution / ( 72 points per inch * units_per_em )
+ [2] PixelSize := pointSize * resolution / ( 72 points per inch )
+ [3] Scale := PixelSize / units_per_em
+ * </pre>
+ * @param fontSize in point-per-inch
+ * @param resolution display resolution in dots-per-inch
+ * @return pixel-per-inch, pixelSize scale factor for font operations.
+ */
+ public float getPixelSize(float fontSize /* points per inch */, float resolution);
+
public float getAdvanceWidth(int glyphID, float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
index d39bda004..948600a4a 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
@@ -29,10 +29,13 @@ package com.jogamp.graph.font;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
import java.net.URLConnection;
+import com.jogamp.common.util.IOUtil;
import com.jogamp.common.util.PropertyAccess;
import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.common.util.cache.TempJarCache;
import jogamp.graph.font.FontConstructor;
import jogamp.graph.font.JavaFontLoader;
@@ -92,6 +95,24 @@ public class FontFactory {
return fontConstr.create(conn);
}
+ public static final Font get(final Class<?> context, final String fname, final boolean useTempJarCache) throws IOException {
+ URLConnection conn = null;
+ if( useTempJarCache ) {
+ try {
+ final URI uri = TempJarCache.getResource(fname);
+ conn = null != uri ? uri.toURL().openConnection() : null;
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ } else {
+ conn = IOUtil.getResource(context, fname);
+ }
+ if(null != conn) {
+ return FontFactory.get ( conn ) ;
+ }
+ return null;
+ }
+
public static boolean isPrintableChar( char c ) {
if( Character.isWhitespace(c) ) {
return true;
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
index df3be2e06..11309290d 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
@@ -39,6 +39,7 @@ import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.graph.curve.opengl.shader.UniformNames;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
@@ -50,6 +51,8 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderState;
public class VBORegion2PES2 extends GLRegion {
+ private static final boolean DEBUG_FBO_1 = false;
+ private static final boolean DEBUG_FBO_2 = false;
private GLArrayDataServer verticeTxtAttr;
private GLArrayDataServer texCoordTxtAttr;
private GLArrayDataServer indicesTxtBuffer;
@@ -62,11 +65,13 @@ public class VBORegion2PES2 extends GLRegion {
private final PMVMatrix fboPMVMatrix;
GLUniformData mgl_fboPMVMatrix;
- private int tex_width_c = 0;
- private int tex_height_c = 0;
+ private int fboWidth = 0;
+ private int fboHeight = 0;
GLUniformData mgl_ActiveTexture;
GLUniformData mgl_TextureSize; // if GLSL < 1.30
+ final int[] maxTexSize = new int[] { -1 } ;
+
public VBORegion2PES2(final int renderModes, final int textureUnit) {
super(renderModes);
final int initialElementCount = 256;
@@ -132,7 +137,7 @@ public class VBORegion2PES2 extends GLRegion {
st.ownAttribute(verticeTxtAttr, true);
st.ownAttribute(texCoordTxtAttr, true);
- if(DEBUG_INSTANCE) {
+ if(Region.DEBUG_INSTANCE) {
System.err.println("VBORegion2PES2 Create: " + this);
}
}
@@ -161,27 +166,85 @@ public class VBORegion2PES2 extends GLRegion {
// push data 2 GPU ..
indicesFbo.seal(gl, true);
indicesFbo.enableBuffer(gl, false);
+
+ // trigger renderRegion2FBO !
+ fboHeight = 0;
+ fboWidth = 0;
// the buffers were disabled, since due to real/fbo switching and other vbo usage
}
- final int[] maxTexSize = new int[] { -1 } ;
-
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] texWidth) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
final int width = renderer.getWidth();
final int height = renderer.getHeight();
- if(width <=0 || height <= 0 || null==texWidth || texWidth[0] <= 0){
+ if(width <=0 || height <= 0 || null==sampleCount || sampleCount[0] <= 0){
renderRegion(gl);
} else {
if(0 > maxTexSize[0]) {
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0);
}
final RenderState rs = renderer.getRenderState();
- if(texWidth[0] != tex_width_c) {
- if(texWidth[0] > maxTexSize[0]) {
- texWidth[0] = maxTexSize[0]; // clip to max - write-back user value!
+ final float winWidth, winHeight;
+ int targetFboWidth, targetFboHeight;
+ {
+ // Calculate perspective pixel width/height for FBO,
+ // considering the sampleCount.
+ final int[] view = new int[] { 0, 0, width, height };
+ final float objZ = 0f;
+
+ final float[] winPosSzMin = new float[3];
+ final float[] winPosSzMax = new float[3];
+ final PMVMatrix pmv = renderer.getMatrix();
+ pmv.gluProject(box.getMinX(), box.getMinY(), objZ, view, 0, winPosSzMin, 0);
+ pmv.gluProject(box.getMaxX(), box.getMaxY(), objZ, view, 0, winPosSzMax, 0);
+ winWidth = Math.abs(winPosSzMax[0] - winPosSzMin[0]);
+ winHeight = Math.abs(winPosSzMax[1] - winPosSzMin[1]);
+ targetFboWidth = Math.round(winWidth*sampleCount[0]);
+ targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ if( DEBUG_FBO_2 ) {
+ System.err.printf("XXX.MinMax1 min [%.1f, %.1f -> %.3f, %.3f, %.3f]"+
+ ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> [%f x %f]%n",
+ box.getMinX(), box.getMinY(), winPosSzMin[0], winPosSzMin[1], winPosSzMin[2],
+ box.getMaxX(), box.getMaxY(), winPosSzMax[0], winPosSzMax[1], winPosSzMax[2],
+ view[2], view[3], winWidth, winHeight);
+ System.err.printf("XXX.MinMax1 [%f x %f] * %d = %d x %d%n", winWidth, winHeight, sampleCount[0], targetFboWidth, targetFboHeight);
+ }
+ }
+ final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
+ final int deltaFboHeight = Math.abs(targetFboHeight-fboHeight);
+ final int maxDeltaFbo, maxLengthFbo;
+ if( deltaFboWidth >= deltaFboHeight ) {
+ maxDeltaFbo = deltaFboWidth;
+ maxLengthFbo = fboWidth > 0 ? fboWidth : 1;
+ } else {
+ maxDeltaFbo = deltaFboHeight;
+ maxLengthFbo = fboHeight > 0 ? fboHeight : 1;
+ }
+ final float pctFboDelta = (float)maxDeltaFbo / (float)maxLengthFbo;
+ if( DEBUG_FBO_2 ) {
+ System.err.printf("XXX.maxDelta: %d / %d = %.3f%n", maxDeltaFbo, maxLengthFbo, pctFboDelta);
+ }
+ if( pctFboDelta > 0.1f ) { // more than 10% !
+ if( DEBUG_FBO_1 ) {
+ System.err.printf("XXX.maxDelta: %d / %d = %.3f%n", maxDeltaFbo, maxLengthFbo, pctFboDelta);
+ System.err.printf("XXX.Scale %d * [%f x %f]: %dx%d%n",
+ sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
+ }
+ final int maxLength = Math.max(targetFboWidth, targetFboHeight);
+ if( maxLength > maxTexSize[0] ) {
+ if( targetFboWidth > targetFboHeight ) {
+ sampleCount[0] = (int)Math.floor(maxTexSize[0] / winWidth);
+ } else {
+ sampleCount[0] = (int)Math.floor(maxTexSize[0] / winHeight);
+ }
+ targetFboWidth = Math.round(winWidth*sampleCount[0]);
+ targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ if( DEBUG_FBO_1 ) {
+ System.err.printf("XXX.Rescale (MAX): %d * [%f x %f]: %dx%d%n",
+ sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
+ }
}
- renderRegion2FBO(gl, rs, texWidth);
+ renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
renderFBO(gl, rs, width, height);
@@ -194,6 +257,8 @@ public class VBORegion2PES2 extends GLRegion {
gl.glViewport(0, 0, width, hight);
st.uniform(gl, mgl_ActiveTexture);
gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue());
+ setTexSize(gl, st);
+
fbo.use(gl, texA);
verticeFboAttr.enableBuffer(gl, true);
texCoordFboAttr.enableBuffer(gl, true);
@@ -209,36 +274,39 @@ public class VBORegion2PES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int[/*1*/] texWidth) {
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight) {
final ShaderState st = rs.getShaderState();
- if(0>=texWidth[0]) {
- throw new IllegalArgumentException("texWidth must be greater than 0: "+texWidth[0]);
- }
-
- tex_width_c = texWidth[0];
- tex_height_c = (int) ( ( ( tex_width_c * box.getHeight() ) / box.getWidth() ) + 0.5f );
-
- // System.out.println("FBO Size: "+texWidth[0]+" -> "+tex_width_c+"x"+tex_height_c);
- // System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5));
-
- if(null != fbo && fbo.getWidth() != tex_width_c && fbo.getHeight() != tex_height_c ) {
- fbo.reset(gl, tex_width_c, tex_height_c);
+ if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
+ throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
}
if(null == fbo) {
+ fboWidth = targetFboWidth;
+ fboHeight = targetFboHeight;
fbo = new FBObject();
- fbo.reset(gl, tex_width_c, tex_height_c);
+ fbo.reset(gl, fboWidth, fboHeight);
// FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth
texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
// texA = fbo.attachTexture2D(gl, 0, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ if( DEBUG_FBO_1 ) {
+ System.err.printf("XXX.createFBO: %dx%d%n%s%n", fboWidth, fboHeight, fbo.toString());
+ }
+ } else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight ) {
+ fbo.reset(gl, targetFboWidth, targetFboHeight);
+ fbo.bind(gl);
+ if( DEBUG_FBO_1 ) {
+ System.err.printf("XXX.resetFBO: %dx%d -> %dx%d%n%s%n", fboWidth, fboHeight, targetFboWidth, targetFboHeight, fbo );
+ }
+ fboWidth = targetFboWidth;
+ fboHeight = targetFboHeight;
} else {
fbo.bind(gl);
}
//render texture
- gl.glViewport(0, 0, tex_width_c, tex_height_c);
+ gl.glViewport(0, 0, fboWidth, fboHeight);
st.uniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -247,15 +315,16 @@ public class VBORegion2PES2 extends GLRegion {
fbo.unbind(gl);
st.uniform(gl, rs.getPMVMatrix()); // switch back to real PMV matrix
-
+ }
+ private void setTexSize(final GL2ES2 gl, final ShaderState st) {
// if( !gl.isGL3() ) {
// GLSL < 1.30
if(null == mgl_TextureSize) {
mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 2, Buffers.newDirectFloatBuffer(2));
}
final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
- texSize.put(0, fbo.getWidth());
- texSize.put(1, fbo.getHeight());
+ texSize.put(0, fboWidth);
+ texSize.put(1, fboHeight);
st.uniform(gl, mgl_TextureSize);
//}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index f4c40b0e5..bdf824b6a 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -103,7 +103,7 @@ public class VBORegionSPES2 extends GLRegion {
}
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] texWidth) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
verticeAttr.enableBuffer(gl, true);
texCoordAttr.enableBuffer(gl, true);
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
index e1e44c92c..c7efe143b 100644
--- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
@@ -38,9 +38,7 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.font.FontFactory;
-import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 8dd9ce4d7..ae9c43ec5 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -222,6 +222,11 @@ class TypecastFont implements Font {
}
@Override
+ public final float getPixelSize(float fontSize /* points per inch */, float resolution) {
+ return fontSize * resolution / ( 72 /* points per inch */ );
+ }
+
+ @Override
public float getLineHeight(float pixelSize) {
final Metrics metrics = getMetrics();
final float lineGap = metrics.getLineGap(pixelSize) ; // negative value!
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;