aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-03 02:39:41 +0200
committerSven Gothel <[email protected]>2023-09-03 02:39:41 +0200
commite6087583dc06c823f54bb6206af2acb0e2119b4c (patch)
treed8dbaa3226411b0d2a1300c8ae7a32f9ce1d0304 /src/demos/com
parentc059585e246ed707ba490f9d2bae3a8b90e949a7 (diff)
GraphUI Scene: Generalize its interface PMVMatrixSetup and usage of its DefaultPMVMatrixSetup w/o orthogonal alike scale-back but fully parametric
Diffstat (limited to 'src/demos/com')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java43
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java44
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java21
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java16
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java25
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java33
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java24
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java19
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java41
9 files changed, 76 insertions, 190 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java
index 494c8396a..8d8a995d9 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java
@@ -36,7 +36,6 @@ import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
-import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.layout.BoxLayout;
import com.jogamp.graph.ui.layout.Margin;
import com.jogamp.graph.ui.layout.Padding;
@@ -52,13 +51,10 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.util.CommandlineOptions;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.PMVMatrix;
/**
* Res independent {@link Shape}s in a {@link Group} using a {@link BoxLayout}, contained within a Scene attached to GLWindow.
@@ -70,38 +66,6 @@ import com.jogamp.opengl.util.PMVMatrix;
public class UILayoutBox01 {
static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
- /**
- * Our PMVMatrixSetup:
- * - gluPerspective like Scene's default
- * - no normal scale to 1, keep a longer distance to near plane for rotation effects. We scale Shapes
- */
- public static class MyPMVMatrixSetup implements PMVMatrixSetup {
- static float Z_DIST = -1f;
- @Override
- public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float)viewport.width()/(float)viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, Z_DIST); // Scene.DEFAULT_SCENE_DIST);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- }
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- final float orthoDist = -Z_DIST; // Scene.DEFAULT_SCENE_DIST;
- final Vec3f obj00Coord = new Vec3f();
- final Vec3f obj11Coord = new Vec3f();
-
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.x(), viewport.y(), orthoDist, obj00Coord);
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.width(), viewport.height(), orthoDist, obj11Coord);
-
- planeBox.setSize( obj00Coord, obj11Coord );
- }
- };
-
static final boolean reLayout = false;
public static void main(final String[] args) throws IOException {
@@ -110,6 +74,8 @@ public class UILayoutBox01 {
for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
if( options.parse(args, idx) ) {
continue;
+ } else if (args[idx[0]].equals("-no_relayout")) {
+ reLayout = false;
}
}
}
@@ -143,8 +109,8 @@ public class UILayoutBox01 {
});
- final Scene scene = new Scene();
- scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
+ final Scene scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new Scene.DefaultPMVMatrixSetup(-1f));
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setFrustumCullingEnabled(true);
scene.attachInputListenerTo(window);
@@ -182,6 +148,7 @@ public class UILayoutBox01 {
System.err.println("SceneBox "+sceneBox);
final float sxy = 1/8f * sceneBox.getWidth();
+ System.err.println("Scale xy "+sxy);
float nextPos = 0;
final Group groupA0 = new Group(new BoxLayout( new Padding(0.15f, 0.15f) ) );
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java
index 00b41cda5..8fe989344 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java
@@ -36,7 +36,6 @@ import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
-import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.layout.Alignment;
import com.jogamp.graph.ui.layout.Gap;
import com.jogamp.graph.ui.layout.GridLayout;
@@ -50,14 +49,11 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.util.CommandlineOptions;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.Vec4f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.PMVMatrix;
/**
* Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow.
@@ -69,39 +65,7 @@ import com.jogamp.opengl.util.PMVMatrix;
public class UILayoutGrid01 {
static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
- /**
- * Our PMVMatrixSetup:
- * - gluPerspective like Scene's default
- * - no normal scale to 1, keep a longer distance to near plane for rotation effects. We scale Shapes
- */
- public static class MyPMVMatrixSetup implements PMVMatrixSetup {
- static float Z_DIST = -1f;
- @Override
- public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float)viewport.width()/(float)viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, Z_DIST); // Scene.DEFAULT_SCENE_DIST);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- }
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- final float orthoDist = -Z_DIST; // Scene.DEFAULT_SCENE_DIST;
- final Vec3f obj00Coord = new Vec3f();
- final Vec3f obj11Coord = new Vec3f();
-
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.x(), viewport.y(), orthoDist, obj00Coord);
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.width(), viewport.height(), orthoDist, obj11Coord);
-
- planeBox.setSize( obj00Coord, obj11Coord );
- }
- };
-
- static final boolean reLayout = false;
+ static boolean reLayout = true;
static final int reLayoutSleep = 500;
public static void main(final String[] args) throws IOException {
@@ -110,6 +74,8 @@ public class UILayoutGrid01 {
for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
if( options.parse(args, idx) ) {
continue;
+ } else if (args[idx[0]].equals("-no_relayout")) {
+ reLayout = false;
}
}
}
@@ -143,8 +109,8 @@ public class UILayoutGrid01 {
});
- final Scene scene = new Scene();
- scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
+ final Scene scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new Scene.DefaultPMVMatrixSetup(-1f));
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setFrustumCullingEnabled(true);
scene.attachInputListenerTo(window);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
index ddc1b72f6..08e5ba7fd 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
@@ -44,6 +44,8 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.util.CommandlineOptions;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.PMVMatrix;
@@ -76,6 +78,7 @@ public class UISceneDemo00 {
System.err.println("Shape bounds "+shape.getBounds(reqGLP));
final Scene scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.addShape(shape);
@@ -166,4 +169,22 @@ public class UISceneDemo00 {
window.destroy();
}
}
+
+ static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup {
+ @Override
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ super.set(pmv, viewport);
+
+ // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height.
+ final AABBox planeBox0 = new AABBox();
+ setPlaneBox(planeBox0, pmv, viewport);
+ final float sx = planeBox0.getWidth();
+ final float sy = planeBox0.getHeight();
+ final float sxy = sx > sy ? sx : sy;
+ pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmv.glScalef(sxy, sxy, 1f);
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ }
+ };
+
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
index 5aa5869cd..83092d366 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -178,17 +178,10 @@ public class UISceneDemo01 {
}
}
- static class MyPMVMatrixSetup implements PMVMatrixSetup {
+ static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup {
@Override
public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float)viewport.width()/(float)viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, Scene.DEFAULT_SCENE_DIST);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
+ super.set(pmv, viewport);
// Scale (back) to have normalized plane dimensions, 100 for the greater of width and height.
final AABBox planeBox0 = new AABBox();
@@ -200,11 +193,6 @@ public class UISceneDemo01 {
pmv.glScalef(sxy / 100f, sxy / 100f, 1f);
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
}
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
- }
};
static Shape makeShape(final Font font, final int renderModes) {
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
index 37ecac50c..106944449 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
@@ -36,7 +36,6 @@ import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
-import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.shapes.Button;
import com.jogamp.graph.ui.shapes.GLButton;
import com.jogamp.newt.event.MouseEvent;
@@ -47,9 +46,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.util.CommandlineOptions;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.PMVMatrix;
@@ -58,7 +55,7 @@ import com.jogamp.opengl.util.PMVMatrix;
* Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement.
* <p>
* This variation of {@link UISceneDemo00} uses a {@link GLButton} shape with animating and rotating gears
- * and sets up an own {@link Scene.PMVMatrixSetup} with a plane dimension of 100.
+ * using the default {@link Scene.PMVMatrixSetup}.
* </p>
* <p>
* Pass '-keep' to main-function to keep running after animation,
@@ -93,7 +90,6 @@ public class UISceneDemo01b {
final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.addShape(shape);
final Animator animator = new Animator(0 /* w/o AWT */);
@@ -218,23 +214,4 @@ public class UISceneDemo01b {
window.destroy();
}
}
-
- static class MyPMVMatrixSetup implements PMVMatrixSetup {
- @Override
- public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float)viewport.width()/(float)viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, Scene.DEFAULT_SCENE_DIST);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- }
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
- }
- };
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
index 810fcdb87..b288ddb48 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -44,7 +44,6 @@ import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
import com.jogamp.graph.ui.AnimGroup;
-import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.layout.Alignment;
import com.jogamp.graph.ui.layout.Gap;
import com.jogamp.graph.ui.layout.GridLayout;
@@ -70,15 +69,12 @@ import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.demos.graph.FontSetDemos;
import com.jogamp.opengl.demos.util.CommandlineOptions;
import com.jogamp.opengl.demos.util.MiscUtils;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
-import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.Vec4f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
@@ -184,7 +180,6 @@ public class UISceneDemo03 {
final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f }, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- scene.setPMVMatrixSetup( new MyPMVMatrixSetup(Scene.DEFAULT_SCENE_DIST) );
scene.setDebugBorderBox(options.debugBoxThickness);
final AnimGroup animGroup = new AnimGroup(null);
@@ -817,32 +812,4 @@ public class UISceneDemo03 {
}
}
};
-
- /**
- * Our PMVMatrixSetup:
- * - gluPerspective like Scene's default
- * - no normal scale to 1, keep distance to near plane for rotation effects.
- */
- public static class MyPMVMatrixSetup implements PMVMatrixSetup {
- private final float scene_dist;
- public MyPMVMatrixSetup(final float scene_dist) {
- this.scene_dist = scene_dist;
- }
- @Override
- public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float) viewport.width() / (float) viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, scene_dist);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- }
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
- }
- };
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
index 2459cbbf6..00a4854a6 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
import com.jogamp.opengl.demos.util.CommandlineOptions;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
@@ -123,6 +124,7 @@ public class UISceneDemo10 {
// Scene for Shape ...
final Scene scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
shape.onMove(new Shape.Listener() {
@@ -190,8 +192,7 @@ public class UISceneDemo10 {
// - Scale the shape to the sceneBox, i.e. normalizing to screen-size 1x1
scene.waitUntilDisplayed();
- final AABBox sceneBox = scene.getBounds();
- shape.scale(sceneBox.getWidth(), sceneBox.getWidth(), 1f); // scale shape to sceneBox
+ System.err.println("m1.1 Scene "+scene.getBounds());
System.err.println("m1.1 "+shape);
try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
@@ -212,7 +213,7 @@ public class UISceneDemo10 {
@SuppressWarnings("unused")
static Shape makeShape(final Window window, final Font font, final int renderModes) {
- final float sw = 0.10f;
+ final float sw = 0.25f;
final float sh = sw / 2.5f;
if( false ) {
@@ -267,4 +268,21 @@ public class UISceneDemo10 {
return b;
}
}
+ static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup {
+ @Override
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ super.set(pmv, viewport);
+
+ // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height.
+ final AABBox planeBox0 = new AABBox();
+ setPlaneBox(planeBox0, pmv, viewport);
+ final float sx = planeBox0.getWidth();
+ final float sy = planeBox0.getHeight();
+ final float sxy = sx > sy ? sx : sy;
+ pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmv.glScalef(sxy, sxy, 1f);
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ }
+ };
+
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
index 79e8c8271..eb5c4d3e2 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
@@ -48,6 +48,8 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.util.CommandlineOptions;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.PMVMatrix;
@@ -97,6 +99,7 @@ public class UISceneDemo11 {
groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; });
final Scene scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.addShape(groupA0);
scene.setFrustumCullingEnabled(true);
@@ -203,4 +206,20 @@ public class UISceneDemo11 {
window.destroy();
}
}
+ static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup {
+ @Override
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ super.set(pmv, viewport);
+
+ // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height.
+ final AABBox planeBox0 = new AABBox();
+ setPlaneBox(planeBox0, pmv, viewport);
+ final float sx = planeBox0.getWidth();
+ final float sy = planeBox0.getHeight();
+ final float sxy = sx > sy ? sx : sy;
+ pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmv.glScalef(sxy, sxy, 1f);
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ }
+ };
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index 799933ba0..c9aa8078d 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -48,7 +48,6 @@ import com.jogamp.graph.ui.GraphShape;
import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
-import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.layout.Alignment;
import com.jogamp.graph.ui.layout.Gap;
import com.jogamp.graph.ui.layout.GridLayout;
@@ -86,9 +85,7 @@ import com.jogamp.opengl.demos.graph.FontSetDemos;
import com.jogamp.opengl.demos.graph.MSAATool;
import com.jogamp.opengl.demos.util.CommandlineOptions;
import com.jogamp.opengl.demos.util.MiscUtils;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -311,8 +308,8 @@ public class UISceneDemo20 implements GLEventListener {
} catch (final URISyntaxException e1) {
throw new RuntimeException(e1);
}
- scene = new Scene();
- scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
+ scene = new Scene(options.graphAASamples);
+ scene.setPMVMatrixSetup(new Scene.DefaultPMVMatrixSetup(-1f));
scene.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
// scene.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)?
scene.setDebugBorderBox(options.debugBoxThickness);
@@ -1187,38 +1184,4 @@ public class UISceneDemo20 implements GLEventListener {
shapeEvent.shape.getRotation().rotateByEuler( rot.scale( 2f ) );
}
};
-
- /**
- * Our PMVMatrixSetup:
- * - gluPerspective like Scene's default
- * - no normal scale to 1, keep a longer distance to near plane for rotation effects. We scale Shapes
- */
- public static class MyPMVMatrixSetup implements PMVMatrixSetup {
- static float Z_DIST = -1f;
- @Override
- public void set(final PMVMatrix pmv, final Recti viewport) {
- final float ratio = (float)viewport.width()/(float)viewport.height();
- pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmv.glLoadIdentity();
- pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
- pmv.glTranslatef(0f, 0f, Z_DIST);
-
- pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmv.glLoadIdentity();
- }
-
- @Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
- // Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
- final float orthoDist = -Z_DIST; // Scene.DEFAULT_SCENE_DIST;
- final Vec3f obj00Coord = new Vec3f();
- final Vec3f obj11Coord = new Vec3f();
-
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.x(), viewport.y(), orthoDist, obj00Coord);
- Scene.winToPlaneCoord(pmv, viewport, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR, viewport.width(), viewport.height(), orthoDist, obj11Coord);
-
- planeBox.setSize( obj00Coord, obj11Coord );
- }
- };
-
}