summaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-19 08:45:55 +0100
committerSven Gothel <[email protected]>2023-03-19 08:45:55 +0100
commit860c550033c46299460ae751e91ecc491abfe549 (patch)
tree2f43d750e78d5155a6d8bf0f1a2b7c3761c91677 /src/demos/com/jogamp/opengl
parent2ece7d9a2c9c176b5834f31e157548bca733bdb9 (diff)
GraphUI UISceneDemo01: Res independent Shape, in Scene attached to GLWindow showing simple linear Shape movement w/ listener attached
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java33
1 files changed, 14 insertions, 19 deletions
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 8a39bd36d..a2b8f5061 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -136,7 +136,6 @@ public class UISceneDemo01 {
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
final Shape shape = makeShape(font, renderModes);
- if( false ) {
shape.onMove(new Shape.Listener() {
@Override
public void run(final Shape shape) {
@@ -162,7 +161,6 @@ public class UISceneDemo01 {
testProject(scene, shape, glWinX, glWinY);
}
} );
- }
scene.addShape(shape);
final AABBox shapeBox = shape.getBounds(glp);
@@ -212,34 +210,31 @@ public class UISceneDemo01 {
System.err.println("m1 scene "+surfaceSize[0]+" x "+surfaceSize[1]);
System.err.println("m1 scene "+sceneBox);
System.err.println("m1.0 "+shape);
- // shape.moveTo(-shapeBox.getWidth()/2f, -shapeBox.getHeight()/2f, 0f);
- shape.scale(sceneBox.getWidth(), sceneBox.getWidth(), 1f);
+ shape.scale(sceneBox.getWidth(), sceneBox.getWidth(), 1f); // scale shape to sceneBox
System.err.println("m1.1 "+shape);
- shape.scale(0.4f, 0.4f, 1f);
+ shape.scale(0.4f, 0.4f, 1f); // scale shape even smaller
System.err.println("m1.2 "+shape);
try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
final float min = sceneBox.getMinX();
- final float max = sceneBox.getMaxX(); // - shapeBox.getWidth(); // * shape.getScaleX();
- // shape.moveTo(min, -shapeBox.getHeight()/2f, 0f);
- shape.moveTo(min, 0f, 0f);
- if( false ) {
- try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
- final float step = (max-min)/200f;
+ final float max = sceneBox.getMaxX() - shapeBox.getWidth()*shape.getScaleX();
+ shape.moveTo(min, 0f, 0f); // move shape to min start position
+
+ final float step = (max-min)/1000f;
System.err.println("m2 ["+min+" .. "+max+"], step "+step);
for(float x=min; x < max; x+=step) {
shape.move(step, 0f, 0f);
- // System.err.println(shape);
final int[] glWinPos = new int[2];
- final boolean ok = shape.objToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), shape.getBounds().getCenter(), new PMVMatrix(), glWinPos);
- // System.err.printf("m3: objToWinCoord: ok "+ok+", winCoords %d / %d%n", glWinPos[0], glWinPos[1]);
- // demo.testProject(glWinPos[0], glWinPos[1]);
- // window.warpPointer(glWinPos[0], window.getHeight() - glWinPos[1] - 1);
+ if( shape.objToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), shape.getBounds().getCenter(), new PMVMatrix(), glWinPos) ) {
+ window.warpPointer(glWinPos[0], window.getHeight() - glWinPos[1] - 1);
+ }
System.err.println("mm x "+x+", ["+min+" .. "+max+"], step "+step);
- try { Thread.sleep(10); } catch (final InterruptedException e1) { }
+ try { Thread.sleep(5); } catch (final InterruptedException e1) { }
}
- }
- System.err.println("X");
+ try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
+ System.err.println("The End ..");
+ animator.stop();
+ window.destroy();
}
static void testProject(final Scene scene, final Shape shape, final int glWinX, final int glWinY) {