28package com.jogamp.opengl.demos.graph.ui;
30import java.io.IOException;
31import java.net.URISyntaxException;
32import java.util.Arrays;
33import java.util.Random;
35import com.jogamp.common.net.Uri;
36import com.jogamp.common.os.Clock;
37import com.jogamp.common.os.Platform;
38import com.jogamp.common.util.IOUtil;
39import com.jogamp.common.util.InterruptSource;
40import com.jogamp.common.util.VersionUtil;
41import com.jogamp.graph.curve.Region;
42import com.jogamp.graph.curve.opengl.RenderState;
43import com.jogamp.graph.font.Font;
44import com.jogamp.graph.font.FontFactory;
45import com.jogamp.graph.ui.GraphShape;
46import com.jogamp.graph.ui.Group;
47import com.jogamp.graph.ui.Scene;
48import com.jogamp.graph.ui.Shape;
49import com.jogamp.graph.ui.AnimGroup;
50import com.jogamp.graph.ui.layout.Alignment;
51import com.jogamp.graph.ui.layout.Gap;
52import com.jogamp.graph.ui.layout.GridLayout;
53import com.jogamp.graph.ui.shapes.Button;
54import com.jogamp.graph.ui.shapes.Label;
55import com.jogamp.graph.ui.shapes.Rectangle;
56import com.jogamp.math.FloatUtil;
57import com.jogamp.math.Quaternion;
58import com.jogamp.math.Vec2f;
59import com.jogamp.math.Vec3f;
60import com.jogamp.math.Vec4f;
61import com.jogamp.math.geom.AABBox;
62import com.jogamp.newt.Display;
63import com.jogamp.newt.MonitorDevice;
64import com.jogamp.newt.NewtFactory;
65import com.jogamp.newt.Screen;
66import com.jogamp.newt.Window;
67import com.jogamp.newt.event.KeyAdapter;
68import com.jogamp.newt.event.KeyEvent;
69import com.jogamp.newt.event.MouseAdapter;
70import com.jogamp.newt.event.MouseEvent;
71import com.jogamp.newt.event.WindowAdapter;
72import com.jogamp.newt.event.WindowEvent;
73import com.jogamp.newt.opengl.GLWindow;
74import com.jogamp.opengl.GL;
75import com.jogamp.opengl.GL2ES2;
76import com.jogamp.opengl.GLAnimatorControl;
77import com.jogamp.opengl.GLAutoDrawable;
78import com.jogamp.opengl.GLCapabilities;
79import com.jogamp.opengl.GLContext;
80import com.jogamp.opengl.GLEventListener;
81import com.jogamp.opengl.GLPipelineFactory;
82import com.jogamp.opengl.GLProfile;
83import com.jogamp.opengl.JoglVersion;
84import com.jogamp.opengl.demos.graph.FontSetDemos;
85import com.jogamp.opengl.demos.graph.MSAATool;
86import com.jogamp.opengl.demos.util.CommandlineOptions;
87import com.jogamp.opengl.demos.util.MiscUtils;
88import com.jogamp.opengl.util.Animator;
89import com.jogamp.opengl.util.av.GLMediaPlayer;
90import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
91import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
92import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser;
94import jogamp.graph.ui.TreeTool;
118 static final boolean DEBUG =
false;
120 static final String[] originalTexts = {
121 " JOGL, Java™ Binding for the OpenGL® API ",
122 " GraphUI, Resolution Independent Curves ",
123 " JogAmp, Java™ libraries for 3D & Media ",
124 " Linux, Android, Windows, MacOS; iOS, embedded, etc on demand"
127 public static void main(
final String[] args)
throws IOException {
130 if (0 != args.length) {
131 final int[] idx = { 0 };
132 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
135 }
else if (args[idx[0]].equals(
"-v")) {
137 demo.setVelocity(
MiscUtils.
atoi(args[idx[0]], (
int) demo.velocity * 1000) / 1000f);
138 }
else if(args[idx[0]].equals(
"-aspeed")) {
139 demo.setVelocity(80/1000f);
141 }
else if(args[idx[0]].equals(
"-rspeed")) {
144 }
else if(args[idx[0]].equals(
"-no_anim_box")) {
145 demo.showAnimBox =
false;
146 }
else if(args[idx[0]].equals(
"-audio")) {
149 demo.audioUri = Uri.cast( args[idx[0]] );
150 }
catch (
final URISyntaxException e1) {
151 System.err.println(e1);
152 demo.audioUri =
null;
163 System.err.println(VersionUtil.getPlatformInfo());
167 System.out.println(
"Requested: " + caps);
180 animator.
add(window);
191 System.err.println(
"Press enter to continue");
204 boolean showAnimBox =
true;
205 float frame_velocity = 5f / 1e3f;
206 float velocity = 30 / 1e3f;
207 float ang_velo = velocity * 60f;
213 final int[] manualScreenShotCount = { 0 };
215 private boolean debug =
false;
216 private boolean trace =
false;
218 private final Font fontButtons, fontSymbols, font, fontStatus;
219 private float dpiV = 96;
220 private float pixPerMM;
222 private final Scene scene;
223 private final AABBox sceneBox;
224 private float top_ypos = 0;
226 private final AABBox animBox;
228 private final AnimGroup.
Set[] dynAnimSet = {
null,
null,
null };
229 private boolean firstReshape =
true;
230 private boolean z_only =
true;
231 private int txt_idx = 0;
232 private int m_state = -1;
233 private long t0_us = 0;
234 private long t1_pause_us = 0;
240 this(
null, renderModes,
false,
false);
243 private UISceneDemo03b(
final String fontfilename,
final int renderModes,
final boolean debug,
final boolean trace) {
244 setVelocity(80/1000f);
250 UISceneDemo03b.options.renderModes = renderModes;
260 }
catch (
final IOException ioe) {
261 throw new RuntimeException(ioe);
265 sceneBox =
new AABBox();
269 animGroup =
new AnimGroup(
null);
270 animBox =
new AABBox();
276 animator =
new Animator(0 );
280 void setVelocity(
final float v) {
282 ang_velo = velocity * 60f;
299 final float sign = angle >= 0f ? 1f : -1f;
302 case 0: v = euler.x();
break;
303 case 1: v = euler.y();
break;
304 case 2: v = euler.z();
break;
307 final float av = Math.abs(v);
310 angle = 2f * eps * sign;
313 case 0: euler.
add(angle, 0, 0);
break;
314 case 1: euler.
add(0, angle, 0);
break;
315 case 2: euler.
add(0, 0, angle);
break;
317 System.err.println(
"Rot: angleDelta "+angle+
" (eps "+eps+
"): "+eulerOld+
" -> "+euler);
326 if( upObj instanceof
Window ) {
331 pixPerMM = pixPerX[1];
334 System.err.println(
"Monitor detected: "+monitor);
335 System.err.println(
"Monitor dpi: "+monitorDPI[0]+
" x "+monitorDPI[1]);
337 System.err.println(
"Surface dpi "+pixPerX[0]+
" x "+pixPerX[1]);
340 System.err.println(
"Using default DPI of "+dpiV);
349 System.err.println(
"UISceneDemo20: init (1.1)");
353 System.err.println(
"UISceneDemo20: init (1.0)");
364 System.err.println(
"VSync Swap Interval: "+gl.getSwapInterval());
365 System.err.println(
"Chosen: "+glad.getChosenGLCapabilities());
368 gl.setSwapInterval(1);
379 if(
null != audioUri ) {
394 if(
null != mPlayer) {
402 scene.
reshape(glad, x, y, width, height);
403 if( !firstReshape ) {
408 final float sceneBoxFrameWidth = sceneBox.
getWidth() * 0.0025f;
411 r.
setColor(0.45f, 0.45f, 0.45f, 0.9f);
420 animGroup.
scale(0.85f, 0.85f, 1f);
424 animGroup.
scale(1.0f, 1.0f, 1f);
432 System.err.println(
"SceneBox " + sceneBox);
434 System.err.println(
"AnimGroup.0: "+animGroup);
436 final Label statusLabel;
438 final AABBox fbox = fontStatus.
getGlyphBounds(
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
440 System.err.println(
"StatusLabelScale: " + statusLabelScale +
" = " + sceneBox.
getWidth() +
" / " + fbox.
getWidth() +
", " + fbox);
442 statusLabel =
new Label(options.
renderModes, fontStatus,
"Nothing there yet");
443 statusLabel.
setScale(statusLabelScale, statusLabelScale, 1f);
444 statusLabel.
setColor(0.1f, 0.1f, 0.1f, 1.0f);
449 System.err.println(
"UISceneDemo20: init (1.1)");
451 sub01SetupWindowListener(glw, scene, animGroup, statusLabel, dpiV);
454 sub02AddUItoScene(scene, animGroup, 2, glad);
460 System.err.println(
"AnimBox " + animBox);
461 System.err.println(
"AnimGroup.1 " + animGroup);
464 final float fontScale2;
466 final String vs =
"Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp. XXXXXXXXXXXXXXXXXXXXXXXXXXX";
469 System.err.println(
"FontScale2: " + fontScale2 +
" = " + animBox.
getWidth() +
" / " + fbox.
getWidth());
472 top_ypos = clippedBox.
getMaxY();
476 final String vs =
"Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp.";
477 top_ypos -= fontScale2 * 1.5f;
479 font, vs, fontScale2,
new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
480 50 / 1e3f , clippedBox, top_ypos);
485 final String vs = VersionUtil.getPlatformInfo().replace(Platform.getNewline(),
"; ").replace(VersionUtil.SEPERATOR,
" *** ").replaceAll(
"\\s+",
" ");
486 top_ypos -= fontScale2 * 1.2f;
488 font, vs, fontScale2,
new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
489 30 / 1e3f , clippedBox, top_ypos);
492 firstReshape =
false;
497 final boolean hadActiveAnimSet =
null != dynAnimSet[0] && dynAnimSet[0].isAnimationActive();
498 if ( 0 == m_state && !hadActiveAnimSet && !animGroup.
getTickPaused() ) {
504 if(
null != dynAnimSet[0] ) {
506 final long t1_us = Clock.currentNanos() / 1000;
507 final float has_dur_s = (t1_us - t0_us) / 1e6f;
508 final String curText = originalTexts[txt_idx];
509 System.err.printf(
"Text travel-duration %.3f s, %d chars%n", has_dur_s, curText.length());
510 if( scene.
getScreenshotCount() - manualScreenShotCount[0] < 1 + originalTexts.length ) {
514 t1_pause_us = t1_us + 1500 * 1000;
516 }
else if( 1 == m_state && t1_pause_us <= Clock.currentNanos() / 1000 ) {
519 if( autoSpeed > 0 ) {
520 if( velocity < 60/1000f ) {
521 setVelocity(velocity + 9/1000f);
523 setVelocity(velocity - 9/1000f);
526 }
else if( autoSpeed < 0 ) {
527 if( velocity > 11/1000f ) {
528 setVelocity(velocity - 9/1000f);
530 setVelocity(velocity + 9/1000f);
534 txt_idx = ( txt_idx + 1 ) % originalTexts.length;
537 System.err.println(
"Next animation loop ...");
538 }
else if( -1 == m_state ) {
540 createAnimSets(drawable.
getGL());
541 t0_us = Clock.currentNanos();
547 private void createAnimSets(
final GL gl) {
549 final String curText = originalTexts[txt_idx];
550 final float fontScale;
554 System.err.println(
"FontScale: " + fontScale +
" = " + animBox.
getWidth() +
" / " + fbox.
getWidth());
560 options.
renderModes, font, curText, fontScale,
new Vec4f(0.1f, 0.1f, 0.1f, 1f),
562 animBox, z_only,
new Random(),
new AnimGroup.TargetLerp(
Vec3f.
UNIT_Y));
570 ", GLSL "+ctx.getGLSLVersionNumber().getVersionString() +
572 final float fontScale2;
581 new AnimGroup.SineLerp(z_only ? Vec3f.UNIT_Z : Vec3f.UNIT_Y, 1.618f, 1.618f),
582 (
final AnimGroup.Set as,
final int idx,
final AnimGroup.ShapeData sd) -> {
583 sd.shape.setColor(0.1f, 0.1f, 0.1f, 0.9f);
586 animBox.getMinX() + as.refShape.getScaledWidth() * 1.0f,
587 animBox.getMinY() + as.refShape.getScaledHeight() * 2.0f, 0f);
589 sd.startPos.set( sd.targetPos.x() + animBox.getWidth(),
590 sd.targetPos.y(), sd.targetPos.z());
591 sd.shape.moveTo( sd.startPos );
597 final float size2 = fontScale/2;
598 final float yscale = 1.1f;
599 final GraphShape refShape =
new Rectangle(options.
renderModes, size2, size2*yscale, sceneBox.
getWidth() * 0.0025f );
603 new AnimGroup.TargetLerp(Vec3f.UNIT_Z), refShape);
604 final AnimGroup.ShapeSetup shapeSetup = (
final AnimGroup.Set as,
final int idx,
final AnimGroup.ShapeData sd) -> {
605 sd.targetPos.add(animBox.
getMinX() + as.refShape.getScaledWidth() * 1.0f,
606 top_ypos - as.refShape.getScaledHeight() * 1.5f, 0f);
608 sd.startPos.set( sd.targetPos.x() + animBox.
getWidth(),
609 sd.targetPos.y(), sd.targetPos.z());
610 sd.shape.moveTo( sd.startPos );
612 refShape.setColor(1.0f, 0.0f, 0.0f, 0.9f);
613 refShape.setRotation( refShape.getRotation().rotateByAngleZ(FloatUtil.QUARTER_PI) );
614 dynAnimSet[2].
addShape(animGroup, refShape, shapeSetup);
616 final Shape s =
new Rectangle(options.
renderModes, size2, size2*yscale, sceneBox.
getWidth() * 0.0025f ).validate(hasGLP);
617 s.setColor(0.0f, 1.0f, 0.0f, 0.9f);
618 s.move(refShape.getScaledWidth() * 1.5f * 1, 0, 0);
619 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
622 final Shape s =
new Rectangle(options.
renderModes, size2, size2*yscale, sceneBox.
getWidth() * 0.0025f ).validate(hasGLP);
623 s.setColor(0.0f, 0.0f, 1.0f, 0.9f);
624 s.move(refShape.getScaledWidth() * 1.5f * 2, 0, 0);
625 s.getRotation().rotateByAngleZ(FloatUtil.QUARTER_PI);
626 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
636 void sub01SetupWindowListener(
final GLWindow window,
final Scene scene,
final AnimGroup animGroup,
final Label statusLabel,
final float dpiV) {
637 window.addWindowListener(
new WindowAdapter() {
639 public void windowResized(
final WindowEvent e) {
640 window.setTitle(UISceneDemo03b.class.getSimpleName() +
": " + window.getSurfaceWidth() +
" x " + window.getSurfaceHeight());
644 public void windowDestroyNotify(
final WindowEvent e) {
645 final GLAnimatorControl animator = window.getAnimator();
646 if(
null != animator ) {
651 window.addKeyListener(
new KeyAdapter() {
653 public void keyReleased(
final KeyEvent e) {
654 final short keySym = e.getKeySymbol();
655 if (keySym == KeyEvent.VK_PLUS ||
656 keySym == KeyEvent.VK_ADD)
658 if (e.isShiftDown()) {
659 setVelocity(velocity + 10 / 1000f);
661 setVelocity(velocity + 1 / 1000f);
663 }
else if (keySym == KeyEvent.VK_MINUS ||
664 keySym == KeyEvent.VK_SUBTRACT)
666 if (e.isShiftDown()) {
667 setVelocity(velocity - 10 / 1000f);
669 setVelocity(velocity - 1 / 1000f);
671 }
else if( keySym == KeyEvent.VK_F4 || keySym == KeyEvent.VK_ESCAPE || keySym == KeyEvent.VK_Q ) {
672 MiscUtils.destroyWindow(window);
673 }
else if( keySym == KeyEvent.VK_SPACE ) {
674 animGroup.setTickPaused ( !animGroup.getTickPaused() );
675 }
else if( keySym == KeyEvent.VK_ENTER ) {
676 animGroup.stopAnimation();
680 window.addMouseListener(
new MouseAdapter() {
682 public void mouseWheelMoved(
final MouseEvent e) {
684 if( e.isControlDown() ) {
686 }
else if( e.isAltDown() ) {
689 final float angle = e.getRotation()[1] < 0f ? FloatUtil.adegToRad(-1f) : FloatUtil.adegToRad(1f);
690 rotateShape(animGroup, angle, axis);
693 window.addGLEventListener(
new GLEventListener() {
696 public void init(
final GLAutoDrawable drawable) {
697 System.err.println(JoglVersion.getGLInfo(drawable.getGL(),
null));
700 public void dispose(
final GLAutoDrawable drawable) {}
702 public void display(
final GLAutoDrawable drawable) {
703 if( animGroup.isToggleOn() ) {
704 final Quaternion rot = animGroup.getRotation();
705 final Vec3f euler = rot.toEuler(
new Vec3f());
706 if( FloatUtil.HALF_PI <= euler.y() ) {
708 }
else if( euler.y() <= -FloatUtil.HALF_PI ) {
711 rot.rotateByAngleY( frame_velocity * dir );
712 animGroup.setRotation(rot);
714 final String text = String.format(
"%s, v %.1f mm/s, r %.3f rad/s",
715 scene.getStatusText(drawable, options.
renderModes, dpiV), velocity * 1e3f, ang_velo);
716 statusLabel.setText(text);
719 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {}
729 void sub02AddUItoScene(
final Scene scene,
final AnimGroup animGroup,
final int mainAnimSetIdx,
final GLAutoDrawable glad) {
730 final Group buttonsRight =
new Group();
732 final float buttonWidth = sceneBox.
getWidth() * 0.09f;
733 final float buttonHeight = buttonWidth / 3.0f;
734 final float buttonZOffset = scene.getZEpsilon(16);
735 final Vec2f fixedSymSize =
new Vec2f(0.0f, 1.0f);
736 final Vec2f symSpacing =
new Vec2f(0f, 0.2f);
738 buttonsRight.setLayout(
new GridLayout(buttonWidth, buttonHeight, Alignment.Fill,
new Gap(buttonHeight*0.50f, buttonWidth*0.10f), 7));
740 final Button button =
new Button(options.
renderModes, fontSymbols,
742 buttonWidth, buttonHeight, buttonZOffset);
743 button.setSpacing(symSpacing, fixedSymSize);
744 button.onToggle((
final Shape s) -> {
745 System.err.println(
"Play/Pause "+s);
746 animGroup.setTickPaused ( s.isToggleOn() );
747 if( s.isToggleOn() ) {
748 animGroup.setTickPaused ( false );
749 if(
null != mPlayer ) {
753 animGroup.setTickPaused ( true );
754 if(
null != mPlayer ) {
755 mPlayer.
pause(
false);
759 button.setToggle(
true);
760 buttonsRight.addShape(button);
763 final Button button =
new Button(options.
renderModes, fontSymbols, fontSymbols.
getUTF16String(
"fast_forward"), buttonWidth, buttonHeight, buttonZOffset);
764 button.setSpacing(symSpacing, fixedSymSize);
765 button.addMouseListener(
new Shape.MouseGestureAdapter() {
767 public void mouseClicked(final MouseEvent e) {
768 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
770 as.setAnimationActive(false);
773 buttonsRight.addShape(button);
776 final Button button =
new Button(options.
renderModes, fontSymbols,
778 buttonWidth, buttonHeight, buttonZOffset);
779 button.setSpacing(symSpacing, fixedSymSize);
780 button.setToggleable(
true);
781 button.onToggle((
final Shape s) -> {
784 buttonsRight.addShape(button);
787 final Button button =
new Button(options.
renderModes, fontButtons,
" < Rot > ", buttonWidth, buttonHeight, buttonZOffset);
788 button.addMouseListener(
new Shape.MouseGestureAdapter() {
790 public void mouseClicked(final MouseEvent e) {
791 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
793 if( e.isControlDown() ) {
795 } else if( e.isAltDown() ) {
798 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
799 rotateShape(animGroup, FloatUtil.adegToRad(1f), axis);
801 rotateShape(animGroup, FloatUtil.adegToRad(-1f), axis);
804 buttonsRight.addShape(button);
807 final Button button =
new Button(options.
renderModes, fontButtons,
" < Velo > ", buttonWidth, buttonHeight, buttonZOffset);
808 button.addMouseListener(
new Shape.MouseGestureAdapter() {
810 public void mouseClicked(final MouseEvent e) {
811 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
812 final float scale = e.isShiftDown() ? 1f : 10f;
813 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
814 setVelocity(velocity - scale / 1000f);
816 setVelocity(velocity + scale / 1000f);
818 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
820 as.setAnimationActive(false);
823 buttonsRight.addShape(button);
826 final Button button =
new Button(options.
renderModes, fontSymbols, fontSymbols.
getUTF16String(
"camera"), buttonWidth, buttonHeight, buttonZOffset);
827 button.setSpacing(symSpacing, fixedSymSize);
828 button.addMouseListener(
new Shape.MouseGestureAdapter() {
830 public void mouseClicked(final MouseEvent e) {
831 scene.screenshot(false, scene.nextScreenshotFile(null, UISceneDemo03b.class.getSimpleName(), options.renderModes, glad.getChosenGLCapabilities(), null));
832 manualScreenShotCount[0]++;
834 buttonsRight.addShape(button);
837 final Button button =
new Button(options.
renderModes, fontSymbols, fontSymbols.
getUTF16String(
"power_settings_new"), buttonWidth, buttonHeight, buttonZOffset);
838 button.setSpacing(symSpacing, fixedSymSize);
839 button.setColor(0.7f, 0.3f, 0.3f, 1.0f);
840 button.addMouseListener(
new Shape.MouseGestureAdapter() {
842 public void mouseClicked(final MouseEvent e) {
843 MiscUtils.destroyWindow(glad);
845 buttonsRight.addShape(button);
847 TreeTool.forAll(buttonsRight, (
final Shape s) -> { s.setDragAndResizable(
false);
return false; });
848 buttonsRight.validate(glad.getChosenGLCapabilities().getGLProfile());
849 buttonsRight.moveTo(sceneBox.
getWidth()/2f - buttonsRight.getScaledWidth()*1.02f,
850 sceneBox.
getHeight()/2f - buttonsRight.getScaledHeight()*1.02f, 0f);
851 scene.addShape(buttonsRight);
853 System.err.println(
"Buttons-Right: Button-1 "+buttonsRight.getShapes().get(0));
854 System.err.println(
"Buttons-Right: SceneBox "+sceneBox);
855 System.err.println(
"Buttons-Right: scaled "+buttonsRight.getScaledWidth()+
" x "+buttonsRight.getScaledHeight());
856 System.err.println(
"Buttons-Right: Box "+buttonsRight.getBounds());
857 System.err.println(
"Buttons-Right: "+buttonsRight);
861 class MyGLMediaEventListener
implements GLMediaEventListener {
863 public void attributesChanged(
final GLMediaPlayer mp,
final GLMediaPlayer.EventMask eventMask,
final long when) {
864 System.err.println(
"MediaPlayer.1 AttributesChanges: "+eventMask+
", when "+when);
865 System.err.println(
"MediaPlayer.1 State: "+mp);
866 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
867 new InterruptSource.Thread() {
872 if ( GLMediaPlayer.State.Paused == mp.getState() ) {
875 System.out.println(
"MediaPlayer.1 "+mp);
876 }
catch (
final Exception e) {
885 boolean destroy =
false;
886 Throwable err =
null;
888 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
891 System.err.println(
"MovieSimple State: Exception");
894 new InterruptSource.Thread() {
904 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) ) {
905 err = mp.getStreamException();
910 System.err.println(
"MovieSimple State: Exception");
911 err.printStackTrace();
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static String getRenderModeString(final int renderModes)
Returns a unique technical description string for renderModes as follows:
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
final void setHintBits(final int mask)
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final int SYMBOLS
Symbols is the default symbol font family and contains rounded material symbol fonts,...
static final FontSet get(final int font)
static final int UBUNTU
Ubuntu is the default font family, {@value}.
Animation-Set covering its ShapeData elements, LerpFunc and animation parameter.
ShapeData addShape(final AnimGroup g, final Shape s, final ShapeSetup op)
Adds given Shape to this Set and its AnimGroup wrapping it in ShapeData.
Group of animated Shapes including other static Shapes, optionally utilizing a Group....
final boolean getTickPaused()
final Set addGlyphSetRandom01(final float pixPerMM, final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, final float accel, final float velocity, final float ang_accel, final float ang_velo, final AABBox animBox, final boolean z_only, final Random random, final LerpFunc lerp)
Add a new Set with ShapeData for each GlyphShape, moving towards its target position using a fixed di...
final void removeAnimSets(final GL2ES2 gl, final RegionRenderer renderer, final List< Set > asList)
Removes the given Sets and destroys them, including their ShapeData and Shape.
final Set addGlyphSet(final float pixPerMM, final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, final Font font, final char refChar, final CharSequence text, final float fontScale, final float accel, final float velocity, final float ang_accel, final float ang_velo, final LerpFunc lerp, final ShapeSetup op)
Add a new Set with ShapeData for each GlyphShape, moving towards its target position using a generic ...
Set addAnimSet(final float pixPerMM, final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final float accel, final float velocity, final float ang_accel, final float ang_velo, final LerpFunc lerp, final Shape refShape)
Add a new Set with an empty ShapeData container.
final Set addGlyphSetHorizScroll01(final float pixPerMM, final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, final float velocity, final AABBox animBox, final float y_offset)
Add a new Set with ShapeData for each GlyphShape, implementing horizontal continuous scrolling while...
Graph based GLRegion Shape.
void addShape(final Shape s)
Adds a Shape.
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
void addShape(final Shape s)
Adds a Shape.
final void setClearParams(final float[] clearColor, final int clearMask)
Sets the clear parameter for glClearColor(..) and glClear(..) to be issued at display(GLAutoDrawable)...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
RegionRenderer getRenderer()
Returns the associated RegionRenderer.
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
int setAAQuality(final int v)
Sets RegionRenderer#setAAQuality(int).
void dispose(final GLAutoDrawable drawable)
Disposes all added Shapes.
final Recti getViewport(final Recti target)
Copies the current int[4] viewport in given target and returns it for chaining.
PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
synchronized void attachInputListenerTo(final GLWindow window)
int getScreenshotCount()
Return the number of nextScreenshotFile(String, String, int, GLCapabilitiesImmutable,...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Reshape scene using setupMatrix(PMVMatrix4f, int, int, int, int) using PMVMatrixSetup.
File nextScreenshotFile(final String dir, final String prefix, final int renderModes, final GLCapabilitiesImmutable caps, final String contentDetail)
Return the unique next technical screenshot PNG File instance as follows:
Generic Shape, potentially using a Graph via GraphShape or other means of representing content.
Shape setColor(final float r, final float g, final float b, final float a)
Set base color.
final Shape move(final float dtx, final float dty, final float dtz)
Move about scaled distance.
final Shape setScale(final Vec3f s)
Set scale factor to given scale.
final Shape setInteractive(final boolean v)
Set whether this shape is interactive in general, i.e.
final Shape setResizable(final boolean resizable)
Set whether this shape is resizable, i.e.
final Shape moveTo(final float tx, final float ty, final float tz)
Move to scaled position.
final Shape setToggle(final boolean v)
Set this shape's toggle state, default is off.
final Quaternion getRotation()
Returns Quaternion for rotation.
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
final Shape setRotation(final Quaternion q)
Sets the rotation Quaternion.
final void destroy(final GL2ES2 gl, final RegionRenderer renderer)
Destroys all data.
final Shape scale(final Vec3f s)
Multiply current scale factor by given scale.
final Shape setRotationPivot(final float px, final float py, final float pz)
Set unscaled rotation origin, aka pivot.
final Shape setToggleable(final boolean toggleable)
Set this shape toggleable, default is off.
A GraphUI text label GraphShape.
A GraphUI rectangle GraphShape.
Basic Float math utility functions.
static final float PI
The value PI, i.e.
static float adegToRad(final float arc_degree)
Converts arc-degree to radians.
static final float HALF_PI
The value PI/2, i.e.
Quaternion implementation supporting Gimbal-Lock free rotations.
Vec3f toEuler(final Vec3f result)
Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ).
final Quaternion setFromEuler(final Vec3f angradXYZ)
Initializes this quaternion from the given Euler rotation array angradXYZ in radians.
Quaternion rotateByAngleY(final float angle)
Rotate this quaternion around Y axis with the given angle in radians.
3D Vector based upon three float components.
static final Vec3f UNIT_Y
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
4D Vector based upon four float components.
Axis Aligned Bounding Box.
final AABBox set(final AABBox o)
Assign values of given AABBox to this instance.
final AABBox resizeWidth(final float deltaLeft, final float deltaRight)
Resize width of this AABBox with explicit left- and right delta values.
final Frustum getFrustum()
Returns the frustum, derived from projection x modelview.
Visual output device, i.e.
static float[] mmToInch(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter value according to the current mode's surface resolution.
static float[] inchToMM(final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void setTitle(final String title)
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
CapabilitiesChooser setCapabilitiesChooser(final CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
final VersionNumberString getGLVersionNumber()
Returns this context OpenGL version.
Factory for pipelining GL instances.
static final GL create(final String pipelineClazzBaseName, final Class<?> reqInterface, final GL downstream, final Object[] additionalArgs)
Creates a pipelined GL instance using the given downstream downstream and optional arguments addition...
Specifies the the OpenGL profile.
static JoglVersion getInstance()
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
StringBuilder toString(final GL gl, StringBuilder sb)
Res independent Shape, Scene attached to GLWindow showing multiple animated shape movements.
static void main(final String[] args)
UISceneDemo03b(final int renderModes)
static void rotateShape(final Shape shape, float angle, final int axis)
Rotate the shape while avoiding 90 degree position.
void init(final GLAutoDrawable glad)
Called by the drawable immediately after the OpenGL context is initialized.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
static CommandlineOptions options
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
GLCapabilities getGLCaps()
int fixDefaultAARenderModeWithDPIThreshold(final float dpiV)
Fix default AA rendering bit, forced if having default_aa_setting is true.
int graphAASamples
Sample count for Graph Region AA render-modes: Region#VBAA_RENDERING_BIT or Region#MSAA_RENDERING_BIT...
int graphAAQuality
Pass2 AA-quality rendering for Graph Region AA render-modes: VBAA_RENDERING_BIT.
void parse(final String[] args)
static void waitForKey(final String preMessage)
static int atoi(final String str, final int def)
static float atof(final String str, final float def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Custom GLCapabilitiesChooser, filtering out all full screen anti-aliasing (FSAA, multisample) capabil...
Font getDefault()
Returns the family FAMILY_REGULAR with STYLE_NONE as retrieved with get(int, int).
float getDescent()
Distance from baseline of lowest descender, a negative value.
float getLineGap()
Typographic line gap, a positive value.
Interface wrapper for font implementation.
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.
AABBox getGlyphBounds(final CharSequence string)
Try using getGlyphBounds(CharSequence, AffineTransform, AffineTransform) to reuse AffineTransform ins...
static String getUTF16String(final char codepoint)
Returns UTF-16 representation of the specified (unicode) codepoint symbol like Character#toChars(int)...
float[] getMaximumSurfaceScale(final float[] result)
Returns the maximum pixel scale of the associated NativeSurface.
float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Specifying NEWT's Window functionality:
float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
MonitorDevice getMainMonitor()
Returns the MonitorDevice with the highest viewport coverage of this window.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Object getUpstreamWidget()
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance,...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
GLContext getContext()
Returns the GLContext associated which this GL object.
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
String glGetString(int name)
Entry point to C language function: const GLubyte * {@native glGetString}(GLenum name) Part of GL_...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expression '0x0B71',...
static final int GL_VENDOR
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VENDOR" with expression '0x1F00',...
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" with expression '0x...