diff options
Diffstat (limited to 'src/graphui/classes/com')
8 files changed, 55 insertions, 87 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java index 4d2202145..89e77d2fe 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java @@ -34,10 +34,9 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.util.texture.TextureSequence; /** @@ -51,8 +50,6 @@ import com.jogamp.opengl.util.texture.TextureSequence; * @see Scene */ public abstract class GraphShape extends Shape { - protected final Factory<? extends Vertex> vertexFactory; - protected final int renderModes; protected GLRegion region = null; protected float oshapeSharpness = OutlineShape.DEFAULT_SHARPNESS; @@ -66,7 +63,6 @@ public abstract class GraphShape extends Shape { */ public GraphShape(final int renderModes) { super(); - this.vertexFactory = OutlineShape.getDefaultVertexFactory(); this.renderModes = renderModes; } @@ -122,7 +118,7 @@ public abstract class GraphShape extends Shape { } @Override - protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final float[] rgba) { + protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final Vec4f rgba) { if( null != rgba ) { renderer.getRenderState().setColorStatic(rgba); } @@ -157,10 +153,10 @@ public abstract class GraphShape extends Shape { } } - private final float[] dbgColor = {0.3f, 0.3f, 0.3f, 0.5f}; + private final Vec4f dbgColor = new Vec4f(0.3f, 0.3f, 0.3f, 0.5f); protected void addDebugOutline() { - final OutlineShape shape = new OutlineShape(vertexFactory); + final OutlineShape shape = new OutlineShape(); final float x1 = box.getMinX(); final float x2 = box.getMaxX(); final float y1 = box.getMinY(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index d89d91c8c..c45292f1b 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -37,6 +37,7 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.PMVMatrix; @@ -194,7 +195,7 @@ public class Group extends Shape implements Container { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final float[] rgba) { + protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final Vec4f rgba) { final PMVMatrix pmv = renderer.getMatrix(); final Object[] shapesS = shapes.toArray(); Arrays.sort(shapesS, (Comparator)Shape.ZAscendingComparator); @@ -207,6 +208,7 @@ public class Group extends Shape implements Container { shape.setTransform(pmv); if( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( shape.getBounds() ) ) { + // FIXME: Optimize to reuse modulated rgba if( null == rgba ) { shape.drawToSelect(gl, renderer, sampleCount); } else { diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 132521f0a..a8e3196c9 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -48,6 +48,7 @@ import com.jogamp.opengl.math.Quaternion; import com.jogamp.opengl.math.Recti; import com.jogamp.opengl.math.Vec2f; import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.PMVMatrix; @@ -118,13 +119,13 @@ public abstract class Shape { private final Object dirtySync = new Object(); /** Default base-color w/o color channel, will be modulated w/ pressed- and toggle color */ - protected final float[] rgbaColor = {0.75f, 0.75f, 0.75f, 1.0f}; + protected final Vec4f rgbaColor = new Vec4f(0.75f, 0.75f, 0.75f, 1.0f); /** Default pressed color-factor w/o color channel, modulated base-color. 0.75 * 1.2 = 0.9 */ - protected final float[] pressedRGBAModulate = {1.2f, 1.2f, 1.2f, 0.7f}; + protected final Vec4f pressedRGBAModulate = new Vec4f(1.20f, 1.20f, 1.20f, 0.7f); /** Default toggle color-factor w/o color channel, modulated base-color. 0.75 * 1.13 ~ 0.85 */ - protected final float[] toggleOnRGBAModulate = {1.13f, 1.13f, 1.13f, 1.0f}; + protected final Vec4f toggleOnRGBAModulate = new Vec4f(1.13f, 1.13f, 1.13f, 1.0f); /** Default toggle color-factor w/o color channel, modulated base-color. 0.75 * 0.86 ~ 0.65 */ - protected final float[] toggleOffRGBAModulate = {0.86f, 0.86f, 0.86f, 1.0f}; + protected final Vec4f toggleOffRGBAModulate = new Vec4f(0.86f, 0.86f, 0.86f, 1.0f); private int name = -1; @@ -372,7 +373,7 @@ public abstract class Shape { } } - private final float[] rgba_tmp = { 0, 0, 0, 1 }; + private final Vec4f rgba_tmp = new Vec4f(0, 0, 0, 1); /** * Renders the shape. @@ -385,7 +386,7 @@ public abstract class Shape { */ public void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { final boolean isPressed = isPressed(), isToggleOn = isToggleOn(); - final float[] rgba; + final Vec4f rgba; if( hasColorChannel() ) { if( isPressed ) { rgba = pressedRGBAModulate; @@ -401,27 +402,15 @@ public abstract class Shape { } else { rgba = rgba_tmp; if( isPressed ) { - rgba[0] = rgbaColor[0]*pressedRGBAModulate[0]; - rgba[1] = rgbaColor[1]*pressedRGBAModulate[1]; - rgba[2] = rgbaColor[2]*pressedRGBAModulate[2]; - rgba[3] = rgbaColor[3]*pressedRGBAModulate[3]; + rgba.mul(rgbaColor, pressedRGBAModulate); } else if( isToggleable() ) { if( isToggleOn ) { - rgba[0] = rgbaColor[0]*toggleOnRGBAModulate[0]; - rgba[1] = rgbaColor[1]*toggleOnRGBAModulate[1]; - rgba[2] = rgbaColor[2]*toggleOnRGBAModulate[2]; - rgba[3] = rgbaColor[3]*toggleOnRGBAModulate[3]; + rgba.mul(rgbaColor, toggleOnRGBAModulate); } else { - rgba[0] = rgbaColor[0]*toggleOffRGBAModulate[0]; - rgba[1] = rgbaColor[1]*toggleOffRGBAModulate[1]; - rgba[2] = rgbaColor[2]*toggleOffRGBAModulate[2]; - rgba[3] = rgbaColor[3]*toggleOffRGBAModulate[3]; + rgba.mul(rgbaColor, toggleOffRGBAModulate); } } else { - rgba[0] = rgbaColor[0]; - rgba[1] = rgbaColor[1]; - rgba[2] = rgbaColor[2]; - rgba[3] = rgbaColor[3]; + rgba.set(rgbaColor); } } synchronized ( dirtySync ) { @@ -771,7 +760,7 @@ public abstract class Shape { return this.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, objPos); } - public float[] getColor() { + public Vec4f getColor() { return rgbaColor; } @@ -782,10 +771,7 @@ public abstract class Shape { * </p> */ public final Shape setColor(final float r, final float g, final float b, final float a) { - this.rgbaColor[0] = r; - this.rgbaColor[1] = g; - this.rgbaColor[2] = b; - this.rgbaColor[3] = a; + this.rgbaColor.set(r, g, b, a); return this; } @@ -796,10 +782,7 @@ public abstract class Shape { * </p> */ public final Shape setPressedColorMod(final float r, final float g, final float b, final float a) { - this.pressedRGBAModulate[0] = r; - this.pressedRGBAModulate[1] = g; - this.pressedRGBAModulate[2] = b; - this.pressedRGBAModulate[3] = a; + this.pressedRGBAModulate.set(r, g, b, a); return this; } @@ -810,10 +793,7 @@ public abstract class Shape { * </p> */ public final Shape setToggleOnColorMod(final float r, final float g, final float b, final float a) { - this.toggleOnRGBAModulate[0] = r; - this.toggleOnRGBAModulate[1] = g; - this.toggleOnRGBAModulate[2] = b; - this.toggleOnRGBAModulate[3] = a; + this.toggleOnRGBAModulate.set(r, g, b, a); return this; } @@ -824,10 +804,7 @@ public abstract class Shape { * </p> */ public final Shape setToggleOffColorMod(final float r, final float g, final float b, final float a) { - this.toggleOffRGBAModulate[0] = r; - this.toggleOffRGBAModulate[1] = g; - this.toggleOffRGBAModulate[2] = b; - this.toggleOffRGBAModulate[3] = a; + this.toggleOffRGBAModulate.set(r, g, b, a); return this; } @@ -1275,7 +1252,7 @@ public abstract class Shape { protected abstract void validateImpl(final GLProfile glp, final GL2ES2 gl); - protected abstract void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, float[] rgba); + protected abstract void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, Vec4f rgba); protected abstract void clearImpl0(final GL2ES2 gl, final RegionRenderer renderer); diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java index e8b0be863..0f754d32a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -37,6 +37,7 @@ import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; import com.jogamp.opengl.math.Vec2f; import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import jogamp.graph.ui.shapes.Label0; @@ -72,7 +73,7 @@ public class Button extends RoundButton { final String labelText, final float width, final float height) { super(renderModes | Region.COLORCHANNEL_RENDERING_BIT, width, height); - this.label = new Label0(labelFont, labelText, new float[] { 1.33f, 1.33f, 1.33f, 1.0f }); // 0.75 * 1.33 = 1.0 + this.label = new Label0(labelFont, labelText, new Vec4f( 1.33f, 1.33f, 1.33f, 1.0f )); // 0.75 * 1.33 = 1.0 setColor(0.75f, 0.75f, 0.75f, 1.0f); setPressedColorMod(0.9f, 0.9f, 0.9f, 0.7f); setToggleOffColorMod(0.65f, 0.65f, 0.65f, 1.0f); @@ -93,16 +94,7 @@ public class Button extends RoundButton { @Override protected void addShapeToRegion() { - final OutlineShape shape = new OutlineShape(vertexFactory); - if(corner == 0.0f) { - createSharpOutline(shape, twoPassLabelZOffset); - } else { - createCurvedOutline(shape, twoPassLabelZOffset); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); + addRoundShapeToRegion( twoPassLabelZOffset ); // Precompute text-box size .. guessing pixelSize final float lw = box.getWidth() * ( 1f - spacingX ) ; @@ -133,12 +125,6 @@ public class Button extends RoundButton { if( DEBUG_DRAW ) { System.err.printf("Button.X: lbox2 %s%n", lbox2); } - - setRotationPivot( ctr ); - - if( DEBUG_DRAW ) { - System.err.println("XXX.Button: Added Shape: "+shape+", "+box); - } } public float get2PassLabelZOffset() { return twoPassLabelZOffset; } @@ -174,7 +160,7 @@ public class Button extends RoundButton { markShapeDirty(); } - public final float[] getLabelColor() { + public final Vec4f getLabelColor() { return label.getColor(); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java index 3e36422a4..f0c6b1369 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java @@ -59,7 +59,7 @@ public class CrossHair extends GraphShape { @Override protected void addShapeToRegion() { - final OutlineShape shape = new OutlineShape(vertexFactory); + final OutlineShape shape = new OutlineShape(); final float lwh = lineWidth/2f; diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java index 339ecf645..dd6a272cb 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java @@ -59,7 +59,7 @@ public class Rectangle extends GraphShape { @Override protected void addShapeToRegion() { - final OutlineShape shape = new OutlineShape(vertexFactory); + final OutlineShape shape = new OutlineShape(); final float x1 = 0f; final float y1 = 0f; final float x2 = getWidth(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/RoundButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/RoundButton.java index 4ea154c09..672d99c3e 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/RoundButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/RoundButton.java @@ -40,7 +40,7 @@ import com.jogamp.graph.ui.GraphShape; * To render it rectangular, {@link #setCorner(float)} to zero. * </p> */ -public abstract class RoundButton extends GraphShape { +public class RoundButton extends GraphShape { /** {@value} */ public static final float DEFAULT_CORNER = 1f; @@ -48,7 +48,7 @@ public abstract class RoundButton extends GraphShape { protected float height; protected float corner = DEFAULT_CORNER; - protected RoundButton(final int renderModes, final float width, final float height) { + public RoundButton(final int renderModes, final float width, final float height) { super(renderModes); this.width = width; this.height = height; @@ -67,6 +67,28 @@ public abstract class RoundButton extends GraphShape { return this; } + @Override + protected void addShapeToRegion() { + addRoundShapeToRegion(0f); + } + protected OutlineShape addRoundShapeToRegion(final float zOffset) { + final OutlineShape shape = new OutlineShape(); + if(corner == 0.0f) { + createSharpOutline(shape, zOffset); + } else { + createCurvedOutline(shape, zOffset); + } + shape.setIsQuadraticNurbs(); + shape.setSharpness(oshapeSharpness); + region.addOutlineShape(shape, null, rgbaColor); + box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); + if( DEBUG_DRAW ) { + System.err.println("GraphShape.RoundButton: Added Shape: "+shape+", "+box); + } + return shape; + } + protected void createSharpOutline(final OutlineShape shape, final float zOffset) { final float tw = getWidth(); final float th = getHeight(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java index 2f7d85198..87a86e706 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java @@ -62,21 +62,6 @@ public abstract class TexSeqButton extends RoundButton { @Override protected void addShapeToRegion() { - final OutlineShape shape = new OutlineShape(vertexFactory); - if(corner == 0.0f) { - createSharpOutline(shape, 0f); - } else { - createCurvedOutline(shape, 0f); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); - - setRotationPivot( box.getCenter() ); - - if( DEBUG_DRAW ) { - System.err.println("XXX.UIShape.TextureSeqButton: Added Shape: "+shape+", "+box); - } + addRoundShapeToRegion( 0f ); } } |