summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-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
9 files changed, 227 insertions, 79 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!