From f51933f0ebe9ae030c26c066e59a728ce08b8559 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Feb 2014 06:11:11 +0100 Subject: Bug 801: Graph TextRenderer Cleanup Part-1a (unclean) Remark: This commit is unclean and requires 'Part-1b' due to merging this commit after more than 2 years! Graph: - Use List instead of array allowing more flexible memory managment. - GLRegion -> Region promotion: - Region create(List outlineShapes, int renderModes) - Region create(OutlineShape outlineShape, int renderModes) - Region additions - void addOutlineShape(OutlineShape shape) - void addOutlineShapes(List shapes) - RegionRenderer - draw(..) remove 'position', redundant - - Deprecate 'TextRenderer' and 'GlyphString' Use Region.create(Font.getOutlineShapes(...)) + RegionRenderer instead. - FontInt -> Font promotion (make public) - getOutlineShape and getOutlineShapes - Font.Glyph additions - 'getID(), hashCode()' - 'float getScale(float pixelSize)' - GlyphShape - Add reference to Glyph allowing GlyphString to access the font metrics for translation and scaling - Experimental pre-scale/translation in GlyphString using default font size and it's metrics --- .../test/junit/graph/TestTextRendererNEWT00.java | 3 +- .../test/junit/graph/TestTextRendererNEWT10.java | 3 +- .../junit/graph/demos/GPURegionGLListener01.java | 2 +- .../junit/graph/demos/GPURegionGLListener02.java | 69 ++++++++++++---------- .../graph/demos/GPUTextRendererListenerBase01.java | 10 ++-- .../junit/graph/demos/GPUUISceneGLListener0A.java | 6 +- .../opengl/test/junit/graph/demos/ui/RIButton.java | 4 +- .../test/junit/graph/demos/ui/UIGLListener01.java | 6 +- 8 files changed, 53 insertions(+), 50 deletions(-) (limited to 'src/test/com/jogamp/opengl') 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 a09cc76ac..738d40971 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -63,7 +63,6 @@ public class TestTextRendererNEWT00 extends UITestCase { static final boolean TRACE = false; static long duration = 100; // ms - static final float[] textPosition = new float[] {0,0,0}; static final int[] texSize = new int[] { 0 }; static final int fontSize = 24; static Font font; @@ -172,7 +171,7 @@ public class TestTextRendererNEWT00 extends UITestCase { dy -= (int)textBox.getHeight() * ( row + 1 ); renderer.resetModelview(null); renderer.translate(gl, dx, dy, z0); - renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize); + renderer.drawString3D(gl, font, text, fontSize, texSize); lastRow = row; } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java index dbeae0dfc..c9f28309c 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -55,7 +55,6 @@ public class TestTextRendererNEWT10 extends UITestCase { static final boolean TRACE = false; static long duration = 100; // ms - static final float[] textPosition = new float[] {0,0,0}; static final int[] texSize = new int[] { 0 }; static final int fontSize = 24; static Font font; @@ -160,7 +159,7 @@ public class TestTextRendererNEWT10 extends UITestCase { dy -= (int)textBox.getHeight() * ( row + 1 ); renderer.resetModelview(null); renderer.translate(gl, dx, dy, z0); - renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize); + renderer.drawString3D(gl, font, text, fontSize, texSize); lastRow = row; } 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 46557e8c8..43e5537e9 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 @@ -120,6 +120,6 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - regionRenderer.draw(gl, region, getPosition(), getTexSize()); + regionRenderer.draw(gl, region, getTexSize()); } } 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 525c5e648..3565dbc48 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 @@ -28,6 +28,9 @@ package com.jogamp.opengl.test.junit.graph.demos; +import java.util.ArrayList; +import java.util.List; + import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; @@ -42,7 +45,7 @@ import com.jogamp.graph.curve.opengl.RenderState; * */ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { - OutlineShape[] outlineShapes = new OutlineShape[2]; + List outlineShapes = new ArrayList(); public GPURegionGLListener02 (RenderState rs, int renderModes, int fbosize, boolean debug, boolean trace) { super(rs, renderModes, debug, trace); @@ -51,39 +54,41 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { private void createTestOutline(){ float offset = 0; - outlineShapes[0] = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); - outlineShapes[0].addVertex(0.0f,-10.0f,true); - outlineShapes[0].addVertex(15.0f,-10.0f, true); - outlineShapes[0].addVertex(10.0f,5.0f, false); - outlineShapes[0].addVertex(15.0f,10.0f, true); - outlineShapes[0].addVertex(6.0f,15.0f, false); - outlineShapes[0].addVertex(5.0f,8.0f, false); - outlineShapes[0].addVertex(0.0f,10.0f,true); - outlineShapes[0].closeLastOutline(); - outlineShapes[0].addEmptyOutline(); - outlineShapes[0].addVertex(5.0f,-5.0f,true); - outlineShapes[0].addVertex(10.0f,-5.0f, false); - outlineShapes[0].addVertex(10.0f,0.0f, true); - outlineShapes[0].addVertex(5.0f,0.0f, false); - outlineShapes[0].closeLastOutline(); + OutlineShape shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + outlineShapes.add(shape); + shape.addVertex(0.0f,-10.0f,true); + shape.addVertex(15.0f,-10.0f, true); + shape.addVertex(10.0f,5.0f, false); + shape.addVertex(15.0f,10.0f, true); + shape.addVertex(6.0f,15.0f, false); + shape.addVertex(5.0f,8.0f, false); + shape.addVertex(0.0f,10.0f,true); + shape.closeLastOutline(); + shape.addEmptyOutline(); + shape.addVertex(5.0f,-5.0f,true); + shape.addVertex(10.0f,-5.0f, false); + shape.addVertex(10.0f,0.0f, true); + shape.addVertex(5.0f,0.0f, false); + shape.closeLastOutline(); /** Same shape as above but without any off-curve vertices */ - outlineShapes[1] = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + outlineShapes.add(shape); offset = 30; - outlineShapes[1].addVertex(offset+0.0f,-10.0f, true); - outlineShapes[1].addVertex(offset+17.0f,-10.0f, true); - outlineShapes[1].addVertex(offset+11.0f,5.0f, true); - outlineShapes[1].addVertex(offset+16.0f,10.0f, true); - outlineShapes[1].addVertex(offset+7.0f,15.0f, true); - outlineShapes[1].addVertex(offset+6.0f,8.0f, true); - outlineShapes[1].addVertex(offset+0.0f,10.0f, true); - outlineShapes[1].closeLastOutline(); - outlineShapes[1].addEmptyOutline(); - outlineShapes[1].addVertex(offset+5.0f,0.0f, true); - outlineShapes[1].addVertex(offset+5.0f,-5.0f, true); - outlineShapes[1].addVertex(offset+10.0f,-5.0f, true); - outlineShapes[1].addVertex(offset+10.0f,0.0f, true); - outlineShapes[1].closeLastOutline(); + shape.addVertex(offset+0.0f,-10.0f, true); + shape.addVertex(offset+17.0f,-10.0f, true); + shape.addVertex(offset+11.0f,5.0f, true); + shape.addVertex(offset+16.0f,10.0f, true); + shape.addVertex(offset+7.0f,15.0f, true); + shape.addVertex(offset+6.0f,8.0f, true); + shape.addVertex(offset+0.0f,10.0f, true); + shape.closeLastOutline(); + shape.addEmptyOutline(); + shape.addVertex(offset+5.0f,0.0f, true); + shape.addVertex(offset+5.0f,-5.0f, true); + shape.addVertex(offset+10.0f,-5.0f, true); + shape.addVertex(offset+10.0f,0.0f, true); + shape.closeLastOutline(); region = GLRegion.create(outlineShapes, getRenderModes()); } @@ -118,7 +123,7 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - regionRenderer.draw(gl, region, getPosition(), getTexSize()); + regionRenderer.draw(gl, region, getTexSize()); } } 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 7fb199a5d..9c18b741a 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 @@ -162,7 +162,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final int fpsSp = fpsS.indexOf('.'); textRenderer.resetModelview(null); textRenderer.translate(gl, fontSizeFixed, fontSizeFixed, -6000); - textRenderer.drawString3D(gl, font, fpsS.substring(0, fpsSp+2)+" fps", getPosition(), fontSizeFixed*3, getTexSize()); + textRenderer.drawString3D(gl, font, fpsS.substring(0, fpsSp+2)+" fps", fontSizeFixed*3, getTexSize()); } int dx = width-(int)fontNameBox.getWidth()-2 ; @@ -170,7 +170,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRenderer.resetModelview(null); textRenderer.translate(gl, dx, dy, -6000); - textRenderer.drawString3D(gl, font, fontName, getPosition(), fontSizeFixed*2, getTexSize()); + textRenderer.drawString3D(gl, font, fontName, fontSizeFixed*2, getTexSize()); dx = 10; dy += -(int)fontNameBox.getHeight() - 10; @@ -178,7 +178,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB if(null != headtext) { textRenderer.resetModelview(null); textRenderer.translate(gl, dx, dy, -6000); - textRenderer.drawString3D(gl, font, headtext, getPosition(), fontSizeFixed*3, getTexSize()); + textRenderer.drawString3D(gl, font, headtext, fontSizeFixed*3, getTexSize()); } textRenderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f); @@ -188,9 +188,9 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRenderer.rotate(gl, getAngle(), 0, 1, 0); textRenderer.setColorStatic(gl, 1.0f, 0.0f, 0.0f); if(!userInput) { - textRenderer.drawString3D(gl, font, text2, getPosition(), fontSize, getTexSize()); + textRenderer.drawString3D(gl, font, text2, fontSize, getTexSize()); } else { - textRenderer.drawString3D(gl, font, userString.toString(), getPosition(), fontSize, getTexSize()); + textRenderer.drawString3D(gl, font, userString.toString(), fontSize, getTexSize()); } } 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 eaac2b1bf..b68b24a7a 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 @@ -301,7 +301,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { regionRenderer.scale(gl, 1.5f, 1.5f, 1.0f); regionRenderer.rotate(gl, angText , 0, 1, 0); regionRenderer.setColorStatic(gl, 0.0f, 1.0f, 0.0f); - regionRenderer.draw(gl, jogampRegion.getRegion(gl, rs, 0), new float[]{0,0,0}, null); + regionRenderer.draw(gl, jogampRegion.getRegion(gl, rs, 0), null); if(null == labelRegions[currentText]) { if( null == labels[currentText]) { @@ -322,7 +322,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { regionRenderer.rotate(gl, zoomText, 0, 1, 0); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - regionRenderer.draw(gl, labelRegions[currentText].getRegion(gl, rs, renderModes2), new float[]{0,0,0}, texSize2); + regionRenderer.draw(gl, labelRegions[currentText].getRegion(gl, rs, renderModes2), texSize2); final GLAnimatorControl animator = drawable.getAnimator(); final boolean _drawFPS = showFPS && null != animator; @@ -345,7 +345,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { if(showFPS && null != fpsRegion) { regionRenderer.translate(gl, 0, -60, 0); regionRenderer.scale(null, zoomText, zoomText, 1); - regionRenderer.draw(gl, fpsRegion.getRegion(gl, rs, 0), new float[]{0,0,0}, null); + regionRenderer.draw(gl, fpsRegion.getRegion(gl, rs, 0), null); } } 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 bf403900d..150082200 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 @@ -215,7 +215,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]); } - renderer.draw(gl, buttonRegion.getRegion(gl, rs, renderModes), getPosition(), texSize); + renderer.draw(gl, buttonRegion.getRegion(gl, rs, renderModes), texSize); gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL); float[] lColor = labelColor; @@ -225,7 +225,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]); } - renderer.draw(gl, labelRegion.getRegion(gl, rs, renderModes), getPosition(), texSize); + renderer.draw(gl, labelRegion.getRegion(gl, rs, renderModes), texSize); } public void setPressed(boolean b) { super.setPressed(b); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java index da94f6a7c..0915ea523 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java @@ -109,10 +109,10 @@ public class UIGLListener01 extends UIListenerBase01 { } regionRenderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]); - regionRenderer.draw(gl, regionButton.getRegion(gl, rs, 0), getPosition(), null); -// regionRenderer.translate(gl, button.getPosition()[0], button.getPosition()[1], button.getPosition()[2]); + regionRenderer.translate(gl, button.getPosition()[0], button.getPosition()[1], button.getPosition()[2]); + regionRenderer.draw(gl, regionButton.getRegion(gl, rs, 0), null); regionRenderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]); - regionRenderer.draw(gl, regionLabel.getRegion(gl, rs, 0), getPosition(), null); + regionRenderer.draw(gl, regionLabel.getRegion(gl, rs, 0), null); } public void dispose(GLAutoDrawable drawable) { -- cgit v1.2.3