JOGL v2.6.0
JOGL, High-Performance Graphics Binding for Java™ (public API).
UISceneDemo03.java
Go to the documentation of this file.
1/**
2 * Copyright 2023-2025 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl.demos.graph.ui;
29
30import java.io.IOException;
31import java.net.URISyntaxException;
32import java.util.Arrays;
33import java.util.Random;
34
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;
93
94import jogamp.graph.ui.TreeTool;
95
96/**
97 * Res independent Shape, Scene attached to GLWindow showing multiple animated shape movements.
98 *
99 * This UISceneDemo* implements as a GLEventListener, capable to be used with any GLAutoDrawable.
100 *
101 * This variation of {@link UISceneDemo00} shows
102 * - Two repetitive steady scrolling text lines. One text shorter than the line-width and one longer.
103 * - One line of animated rectangles, rotating around their z-axis and accelerating towards their target.
104 * - A text animation assembling one line of text,
105 * each glyph coming from from a random 3D point moving to its destination all at once including rotation.
106 * - One line of text with sine wave animation flattening and accelerating towards its target.
107 *
108 * Blog entry: https://jausoft.com/blog/2023/08/27/graphui_animation_animgroup/
109 *
110 * Commandline options
111 * - Pass '-keep' to main-function to keep running.
112 * - Pass '-aspeed' to vary velocity
113 * - Pass '-rspeed <float>' angular velocity in radians/s
114 * - Pass '-no_anim_box' to not show a visible and shrunken box around the AnimGroup
115 * - Pass '-audio <uri or file-path>' to play audio (only)
116 */
117public class UISceneDemo03 implements GLEventListener {
118 static final boolean DEBUG = false;
119
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"
125 };
126
127 public static void main(final String[] args) throws IOException {
128 final UISceneDemo03 demo = new UISceneDemo03(0);
129
130 if (0 != args.length) {
131 final int[] idx = { 0 };
132 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
133 if( options.parse(args, idx) ) {
134 continue;
135 } else if (args[idx[0]].equals("-v")) {
136 ++idx[0];
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);
140 demo.autoSpeed = -1;
141 } else if(args[idx[0]].equals("-rspeed")) {
142 ++idx[0];
143 demo.ang_velo = MiscUtils.atof(args[idx[0]], demo.ang_velo);
144 } else if(args[idx[0]].equals("-no_anim_box")) {
145 demo.showAnimBox = false;
146 } else if(args[idx[0]].equals("-audio")) {
147 ++idx[0];
148 try {
149 demo.audioUri = Uri.cast( args[idx[0]] );
150 } catch (final URISyntaxException e1) {
151 System.err.println(e1);
152 demo.audioUri = null;
153 }
154 }
155 }
156 }
157 System.err.println(JoglVersion.getInstance().toString());
158 System.err.println(options);
159
160 final Display dpy = NewtFactory.createDisplay(null);
161 final Screen screen = NewtFactory.createScreen(dpy, 0);
162 System.err.println(VersionUtil.getPlatformInfo());
163 // System.err.println(JoglVersion.getAllAvailableCapabilitiesInfo(dpy.getGraphicsDevice(), null).toString());
164
165 final GLCapabilities caps = options.getGLCaps();
166 System.out.println("Requested: " + caps);
167
168 final GLWindow window = GLWindow.create(screen, caps);
169 if( 0 == options.sceneMSAASamples ) {
171 }
173 window.setTitle(UISceneDemo03.class.getSimpleName() + ": " + window.getSurfaceWidth() + " x " + window.getSurfaceHeight());
174
175 window.addGLEventListener(demo);
176
177 final Animator animator = new Animator(0 /* w/o AWT */);
178 animator.setUpdateFPSFrames(5*60, null);
179 animator.add(window);
181
182 window.addWindowListener(new WindowAdapter() {
183 @Override
184 public void windowDestroyed(final WindowEvent e) {
185 animator.stop();
186 }
187 });
188
189 if( options.wait_to_start ) {
190 System.err.println("Press enter to continue");
191 MiscUtils.waitForKey("Start");
192 }
193
194 window.setVisible(true);
195 System.out.println("Chosen: " + window.getChosenGLCapabilities());
196
197 animator.start();
198 }
199
201 // public static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.NORM_RENDERING_BIT, Region.DEFAULT_AA_QUALITY, 0, 4);
202
203 boolean showAnimBox = true;
204 float frame_velocity = 5f / 1e3f; // [m]/[s]
205 float velocity = 30 / 1e3f; // [m]/[s]
206 float ang_velo = velocity * 60f; // [radians]/[s]
207 int autoSpeed = -1;
208
209 Uri audioUri = null;
210 GLMediaPlayer mPlayer = null;
211
212 final int[] manualScreenShotCount = { 0 };
213
214 private boolean debug = false;
215 private boolean trace = false;
216
217 private final Font fontButtons, fontSymbols, font, fontStatus;
218 private float dpiV = 96;
219 private float pixPerMM;
220 private float monitorRefresh = 60;
221
222 private final Scene scene;
223 private final AABBox sceneBox;
224 private float top_ypos = 0;
225 private final AnimGroup animGroup;
226 private final AABBox animBox;
227 private final AnimGroup.Set[] dynAnimSet = { null, null, null };
228 private boolean firstReshape = true;
229 private boolean z_only = true;
230 private int txt_idx = 0;
231 private int m_state = -1;
232 private long t0_us = 0;
233 private long t1_pause_us = 0;
234
235 /**
236 * @param renderModes
237 */
238 public UISceneDemo03(final int renderModes) {
239 this(null, renderModes, false, false);
240 }
241
242 private UISceneDemo03(final String fontfilename, final int renderModes, final boolean debug, final boolean trace) {
243 setVelocity(80/1000f);
244 autoSpeed = -1;
245
246 this.debug = debug;
247 this.trace = trace;
248
249 options.renderModes = renderModes;
250
251 try {
254 font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf",FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
255 // final Font font = FontFactory.get(IOUtil.getResource("jogamp/graph/font/fonts/ubuntu/Ubuntu-R.ttf",FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
256 System.err.println("Font FreeSerif: " + font.getFullFamilyName());
257 fontStatus = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMono.ttf", FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
258 System.err.println("Font Status: " + fontStatus.getFullFamilyName());
259 } catch (final IOException ioe) {
260 throw new RuntimeException(ioe);
261 }
262
263 scene = new Scene(options.graphAASamples);
264 sceneBox = new AABBox();
265 scene.setClearParams(new float[] { 1f, 1f, 1f, 1f }, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
266 scene.getRenderer().setHintBits(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
267
268 animGroup = new AnimGroup(null);
269 animBox = new AABBox();
270 scene.addShape(animGroup);
271
272 scene.setPMvCullingEnabled(true);
273 animGroup.setPMvCullingEnabled(true);
274 }
275
276 void setVelocity(final float v) {
277 velocity = v; // Math.max(1/1e3f, v);
278 ang_velo = velocity * 60f;
279 autoSpeed = 0;
280 }
281
282
283 /**
284 * Rotate the shape while avoiding 90 degree position
285 * @param shape the shape to rotate
286 * @param angle the angle in radians
287 * @param axis 0 for X-, 1 for Y- and 2 for Z-axis
288 */
289 public static void rotateShape(final Shape shape, float angle, final int axis) {
290 final Quaternion rot = shape.getRotation().copy();
291 final Vec3f euler = rot.toEuler(new Vec3f());
292 final Vec3f eulerOld = euler.copy();
293
294 final float eps = FloatUtil.adegToRad(5f);
295 final float sign = angle >= 0f ? 1f : -1f;
296 final float v;
297 switch( axis ) {
298 case 0: v = euler.x(); break;
299 case 1: v = euler.y(); break;
300 case 2: v = euler.z(); break;
301 default: return;
302 }
303 final float av = Math.abs(v);
304 if( 1f*FloatUtil.HALF_PI - eps <= av && av <= 1f*FloatUtil.HALF_PI + eps ||
305 3f*FloatUtil.HALF_PI - eps <= av && av <= 3f*FloatUtil.HALF_PI + eps) {
306 angle = 2f * eps * sign;
307 }
308 switch( axis ) {
309 case 0: euler.add(angle, 0, 0); break;
310 case 1: euler.add(0, angle, 0); break;
311 case 2: euler.add(0, 0, angle); break;
312 }
313 System.err.println("Rot: angleDelta "+angle+" (eps "+eps+"): "+eulerOld+" -> "+euler);
314 shape.setRotation( rot.setFromEuler(euler) );
315 }
316
317 @Override
318 public void init(final GLAutoDrawable glad) {
319 // Resolution independent, no screen size
320 //
321 final Object upObj = glad.getUpstreamWidget();
322 if( upObj instanceof Window ) {
323 final Window win = (Window)upObj;
324 final MonitorDevice monitor = win.getMainMonitor();
325 final float[] monitorDPI = MonitorDevice.mmToInch( monitor.getPixelsPerMM(new float[2]) );
326 final float[] pixPerXY = win.getPixelsPerMM(new float[2]);
327 pixPerMM = pixPerXY[1]; // [px]/[mm]
328 final float[] dpiXY = MonitorDevice.mmToInch(new float[2], pixPerXY);
329 dpiV = dpiXY[1];
330 monitorRefresh = monitor.getCurrentMode().getRefreshRate();
331 System.err.println("Monitor detected: "+monitor);
332 System.err.println("Monitor dpi: "+monitorDPI[0]+" x "+monitorDPI[1]);
333 System.err.println("Surface scale: native "+Arrays.toString(win.getMaximumSurfaceScale(new float[2]))+", current "+Arrays.toString(win.getCurrentSurfaceScale(new float[2])));
334 System.err.println("Surface dpi "+dpiXY[0]+" x "+dpiXY[1]+", refresh "+monitorRefresh+" Hz");
335 } else {
336 pixPerMM = MonitorDevice.inchToMM(dpiV); // [px]/[mm]
337 monitorRefresh = 60f;
338 System.err.println("Using default DPI of "+dpiV+", refresh "+monitorRefresh+" Hz");
339 }
340 {
342 System.err.println("AUTO RenderMode: dpi "+dpiV+", threshold "+options.noAADPIThreshold+
343 ", mode "+Region.getRenderModeString(o)+" -> "+
345 }
346 if(glad instanceof GLWindow) {
347 System.err.println("FontView01: init (1.1)");
348 final GLWindow glw = (GLWindow) glad;
349 scene.attachInputListenerTo(glw);
350 } else {
351 System.err.println("FontView01: init (1.0)");
352 }
353
354 GL2ES2 gl = glad.getGL().getGL2ES2();
355 if(debug) {
356 gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2();
357 }
358 if(trace) {
359 gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
360 }
361 System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString());
362 System.err.println("VSync Swap Interval: "+gl.getSwapInterval());
363 System.err.println("Chosen: "+glad.getChosenGLCapabilities());
364 MSAATool.dump(glad);
365
366 gl.setSwapInterval(1);
367 gl.glEnable(GL.GL_DEPTH_TEST);
368 // gl.glDepthFunc(GL.GL_LEQUAL);
369 // gl.glEnable(GL.GL_BLEND);
370
372 scene.init(glad);
373
374 //
375 // Optional Audio
376 //
377 if( null != audioUri ) {
379 mPlayer.addEventListener( new MyGLMediaEventListener() );
381 } else {
382 mPlayer = null;
383 }
384
385 firstReshape = true;
386 }
387
388 @Override
389 public void dispose(final GLAutoDrawable drawable) {
390 animGroup.destroy(drawable.getGL().getGL2ES2(), scene.getRenderer());
391 scene.dispose(drawable);
392 if(null != mPlayer) {
393 mPlayer.destroy(drawable.getGL());
394 mPlayer = null;
395 }
396 }
397
398 @Override
399 public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
400 scene.reshape(glad, x, y, width, height);
401 if( !firstReshape ) {
402 return; // done
403 }
404
405 sceneBox.set( scene.getBounds() );
406 final float sceneBoxFrameWidth = sceneBox.getWidth() * 0.0025f;
407 final GraphShape r = new Rectangle(options.renderModes, sceneBox, sceneBoxFrameWidth);
408 if( showAnimBox ) {
409 r.setColor(0.45f, 0.45f, 0.45f, 0.9f);
410 } else {
411 r.setColor(0f, 0f, 0f, 0f);
412 }
413 r.setInteractive(false);
414 animGroup.addShape( r );
415
416 animGroup.setRotationPivot(0, 0, 0);
417 if( showAnimBox ) {
418 animGroup.scale(0.85f, 0.85f, 1f);
419 animGroup.move(-sceneBox.getWidth()/2f*0.075f, 0f, 0f);
420 animGroup.setRotation( animGroup.getRotation().rotateByAngleY(0.1325f) );
421 } else {
422 animGroup.scale(1.0f, 1.0f, 1f);
423 }
424 final GLProfile hasGLP = glad.getChosenGLCapabilities().getGLProfile();
425 animGroup.validate(hasGLP);
426 animGroup.setInteractive(false);
427 animGroup.setToggleable(true);
428 animGroup.setResizable(false);
429 animGroup.setToggle( false );
430 System.err.println("SceneBox " + sceneBox);
431 System.err.println("Frustum " + scene.getMatrix().getFrustum());
432 System.err.println("AnimGroup.0: "+animGroup);
433
434 final Label statusLabel;
435 {
436 final AABBox fbox = fontStatus.getGlyphBounds("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
437 final float statusLabelScale = sceneBox.getWidth() / fbox.getWidth();
438 System.err.println("StatusLabelScale: " + statusLabelScale + " = " + sceneBox.getWidth() + " / " + fbox.getWidth() + ", " + fbox);
439
440 statusLabel = new Label(options.renderModes, fontStatus, "Nothing there yet");
441 statusLabel.setScale(statusLabelScale, statusLabelScale, 1f);
442 statusLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f);
443 statusLabel.moveTo(sceneBox.getMinX(), sceneBox.getMinY() + statusLabelScale * (fontStatus.getMetrics().getLineGap() - fontStatus.getMetrics().getDescent()), 0f);
444 scene.addShape(statusLabel);
445 }
446 if(glad instanceof GLWindow) {
447 System.err.println("UISceneDemo20: init (1.1)");
448 final GLWindow glw = (GLWindow) glad;
449 sub01SetupWindowListener(glw, scene, animGroup, statusLabel, dpiV);
450 }
451 // HUD UI
452 sub02AddUItoScene(scene, animGroup, 2, glad);
453
454 //
455 // Setup the moving glyphs
456 //
457 animBox.set( animGroup.getBounds() );
458 System.err.println("AnimBox " + animBox);
459 System.err.println("AnimGroup.1 " + animGroup);
460
461 top_ypos = 0;
462 final float fontScale2;
463 {
464 final String vs = "Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp. XXXXXXXXXXXXXXXXXXXXXXXXXXX";
465 final AABBox fbox = font.getGlyphBounds(vs);
466 fontScale2 = animBox.getWidth() / fbox.getWidth();
467 System.err.println("FontScale2: " + fontScale2 + " = " + animBox.getWidth() + " / " + fbox.getWidth());
468 }
469 final AABBox clippedBox = new AABBox(animBox).resizeWidth(-sceneBoxFrameWidth, -sceneBoxFrameWidth);
470 top_ypos = clippedBox.getMaxY();
471 // AnimGroup.Set 1:
472 // Circular short scrolling text (right to left) without rotation, no acceleration
473 {
474 final String vs = "Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp.";
475 top_ypos -= fontScale2 * 1.5f;
476 animGroup.addGlyphSetHorizScroll01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(), options.renderModes,
477 font, vs, fontScale2, new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
478 50 / 1e3f /* velocity */, clippedBox, top_ypos);
479 }
480 // AnimGroup.Set 2:
481 // Circular long scrolling text (right to left) without rotation, no acceleration
482 {
483 final String vs = VersionUtil.getPlatformInfo().replace(Platform.getNewline(), "; ").replace(VersionUtil.SEPERATOR, " *** ").replaceAll("\\s+", " ");
484 top_ypos -= fontScale2 * 1.2f;
485 animGroup.addGlyphSetHorizScroll01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(), options.renderModes,
486 font, vs, fontScale2, new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
487 30 / 1e3f /* velocity */, clippedBox, top_ypos);
488 }
489
490 firstReshape = false;
491 }
492
493 @Override
494 public void display(final GLAutoDrawable drawable) {
495 final boolean hadActiveAnimSet = null != dynAnimSet[0] && dynAnimSet[0].isAnimationActive();
496 if ( 0 == m_state && !hadActiveAnimSet && !animGroup.getTickPaused() ) {
497 //
498 // Setup new animation sequence
499 // - Flush all AnimGroup.Set entries
500 // - Add newly created AnimGroup.Set entries
501 //
502 if( null != dynAnimSet[0] ) {
503 // Print stats and set pause 1.5s
504 final long t1_us = Clock.currentNanos() / 1000;
505 final float has_dur_s = (t1_us - t0_us) / 1e6f; // [us]
506 final String curText = originalTexts[txt_idx];
507 System.err.printf("Text travel-duration %.3f s, %d chars%n", has_dur_s, curText.length());
508 m_state = 1;
509 t1_pause_us = t1_us + 1500 * 1000;
510 }
511 } else if( 1 == m_state && t1_pause_us <= Clock.currentNanos() / 1000 ) {
512 // Flush all AnimGroup.Set entries and prep param for next cycle
513 animGroup.removeAnimSets(drawable.getGL().getGL2ES2(), scene.getRenderer(), Arrays.asList(dynAnimSet));
514 if( autoSpeed > 0 ) {
515 if( velocity < 60/1000f ) {
516 setVelocity(velocity + 9/1000f);
517 } else {
518 setVelocity(velocity - 9/1000f);
519 autoSpeed = -1;
520 }
521 } else if( autoSpeed < 0 ) {
522 if( velocity > 11/1000f ) {
523 setVelocity(velocity - 9/1000f);
524 } else {
525 setVelocity(velocity + 9/1000f);
526 autoSpeed = 1;
527 }
528 }
529 txt_idx = ( txt_idx + 1 ) % originalTexts.length;
530 z_only = !z_only;
531 m_state = -1;
532 System.err.println("Next animation loop ...");
533 } else if( -1 == m_state ) {
534 // Add newly created AnimGroup.Set entries
535 createAnimSets(drawable.getGL());
536 t0_us = Clock.currentNanos();
537 m_state = 0;
538 }
539 scene.display(drawable);
540 }
541
542 private void createAnimSets(final GL gl) {
543 final GLProfile hasGLP = gl.getGLProfile();
544 final String curText = originalTexts[txt_idx];
545 final float fontScale;
546 {
547 final AABBox fbox = font.getGlyphBounds(curText);
548 fontScale = animBox.getWidth() / fbox.getWidth();
549 System.err.println("FontScale: " + fontScale + " = " + animBox.getWidth() + " / " + fbox.getWidth());
550 }
551
552 // AnimGroup.Set 3: This `mainAnimSet[0]` is controlling overall animation duration
553 // Rotating animated text moving to target (right to left) + slight acceleration on rotation
554 dynAnimSet[0] = animGroup.addGlyphSetRandom01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
555 options.renderModes, font, curText, fontScale, new Vec4f(0.1f, 0.1f, 0.1f, 1f),
556 0f /* accel */, velocity, FloatUtil.PI/20f /* ang_accel */, ang_velo,
557 animBox, z_only, new Random(), new AnimGroup.TargetLerp(Vec3f.UNIT_Y));
558
559 // AnimGroup.Set 4:
560 // Sine animated text moving to target (right to left) with sine amplitude alternating on Z- and Y-axis + acceleration
561 {
562 final GLContext ctx = gl.getContext();
563 final String vs = "JogAmp Version "+JoglVersion.getInstance().getImplementationVersion()+
564 ", GL "+ctx.getGLVersionNumber().getVersionString()+
565 ", GLSL "+ctx.getGLSLVersionNumber().getVersionString() +
566 " by "+gl.glGetString(GL.GL_VENDOR);
567 final float fontScale2;
568 {
569 final AABBox fbox = font.getGlyphBounds(vs);
570 fontScale2 = animBox.getWidth() / fbox.getWidth() * 0.6f;
571 }
572 // Translation : We use velocity as acceleration (good match) and pass only velocity/10 as starting velocity
573 dynAnimSet[1] = animGroup.addGlyphSet(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
574 options.renderModes, font, 'X', vs, fontScale2,
575 velocity /* accel */, velocity/10f, 0f /* ang_accel */, 2*FloatUtil.PI /* 1-rotation/s */,
576 new AnimGroup.SineLerp(z_only ? Vec3f.UNIT_Z : Vec3f.UNIT_Y, 1.618f, 1.618f),
577 (final AnimGroup.Set as, final int idx, final AnimGroup.ShapeData sd) -> {
578 sd.shape.setColor(0.1f, 0.1f, 0.1f, 0.9f);
579
580 sd.targetPos.add(
581 animBox.getMinX() + as.refShape.getScaledWidth() * 1.0f,
582 animBox.getMinY() + as.refShape.getScaledHeight() * 2.0f, 0f);
583
584 sd.startPos.set( sd.targetPos.x() + animBox.getWidth(),
585 sd.targetPos.y(), sd.targetPos.z());
586 sd.shape.moveTo( sd.startPos );
587 } );
588 }
589 // AnimGroup.Set 5:
590 // 3 animated Shapes moving to target (right to left) while rotating around z-axis + acceleration on translation
591 {
592 final float size2 = fontScale/2;
593 final float yscale = 1.1f;
594 final GraphShape refShape = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f );
595 dynAnimSet[2] = animGroup.addAnimSet(
596 pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
597 velocity /* accel */, velocity/10f, 0f /* ang_accel */, 2*FloatUtil.PI /* 1-rotation/s */,
598 new AnimGroup.TargetLerp(Vec3f.UNIT_Z), refShape);
599 final AnimGroup.ShapeSetup shapeSetup = (final AnimGroup.Set as, final int idx, final AnimGroup.ShapeData sd) -> {
600 sd.targetPos.add(animBox.getMinX() + as.refShape.getScaledWidth() * 1.0f,
601 top_ypos - as.refShape.getScaledHeight() * 1.5f, 0f);
602
603 sd.startPos.set( sd.targetPos.x() + animBox.getWidth(),
604 sd.targetPos.y(), sd.targetPos.z());
605 sd.shape.moveTo( sd.startPos );
606 };
607 refShape.setColor(1.0f, 0.0f, 0.0f, 0.9f);
608 refShape.setRotation( refShape.getRotation().rotateByAngleZ(FloatUtil.QUARTER_PI) );
609 dynAnimSet[2].addShape(animGroup, refShape, shapeSetup);
610 {
611 final Shape s = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f ).validate(hasGLP);
612 s.setColor(0.0f, 1.0f, 0.0f, 0.9f);
613 s.move(refShape.getScaledWidth() * 1.5f * 1, 0, 0);
614 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
615 }
616 {
617 final Shape s = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f ).validate(hasGLP);
618 s.setColor(0.0f, 0.0f, 1.0f, 0.9f);
619 s.move(refShape.getScaledWidth() * 1.5f * 2, 0, 0);
620 s.getRotation().rotateByAngleZ(FloatUtil.QUARTER_PI);
621 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
622 }
623 }
624 }
625
626 /**
627 * Setup Window listener for I/O
628 * @param window
629 * @param animGroup
630 */
631 void sub01SetupWindowListener(final GLWindow window, final Scene scene, final AnimGroup animGroup, final Label statusLabel, final float dpiV) {
632 window.addWindowListener(new WindowAdapter() {
633 @Override
634 public void windowResized(final WindowEvent e) {
635 window.setTitle(UISceneDemo03.class.getSimpleName() + ": " + window.getSurfaceWidth() + " x " + window.getSurfaceHeight());
636 }
637
638 @Override
639 public void windowDestroyNotify(final WindowEvent e) {
640 final GLAnimatorControl animator = window.getAnimator();
641 if( null != animator ) {
642 animator.stop();
643 }
644 }
645 });
646 window.addKeyListener(new KeyAdapter() {
647 @Override
648 public void keyReleased(final KeyEvent e) {
649 final short keySym = e.getKeySymbol();
650 if (keySym == KeyEvent.VK_PLUS ||
651 keySym == KeyEvent.VK_ADD)
652 {
653 if (e.isShiftDown()) {
654 setVelocity(velocity + 10 / 1000f);
655 } else {
656 setVelocity(velocity + 1 / 1000f);
657 }
658 } else if (keySym == KeyEvent.VK_MINUS ||
659 keySym == KeyEvent.VK_SUBTRACT)
660 {
661 if (e.isShiftDown()) {
662 setVelocity(velocity - 10 / 1000f);
663 } else {
664 setVelocity(velocity - 1 / 1000f);
665 }
666 } else if( keySym == KeyEvent.VK_F4 || keySym == KeyEvent.VK_ESCAPE || keySym == KeyEvent.VK_Q ) {
667 MiscUtils.destroyWindow(window);
668 } else if( keySym == KeyEvent.VK_SPACE ) {
669 animGroup.setTickPaused ( !animGroup.getTickPaused() );
670 } else if( keySym == KeyEvent.VK_ENTER ) {
671 animGroup.stopAnimation();
672 }
673 }
674 });
675 window.addMouseListener( new MouseAdapter() {
676 @Override
677 public void mouseWheelMoved(final MouseEvent e) {
678 int axis = 1;
679 if( e.isControlDown() ) {
680 axis = 0;
681 } else if( e.isAltDown() ) {
682 axis = 2;
683 }
684 final float angle = e.getRotation()[1] < 0f ? FloatUtil.adegToRad(-1f) : FloatUtil.adegToRad(1f);
685 rotateShape(animGroup, angle, axis);
686 }
687 });
688 window.addGLEventListener(new GLEventListener() {
689 float dir = 1f;
690 @Override
691 public void init(final GLAutoDrawable drawable) {
692 System.err.println(JoglVersion.getGLInfo(drawable.getGL(), null));
693 }
694 @Override
695 public void dispose(final GLAutoDrawable drawable) {}
696 @Override
697 public void display(final GLAutoDrawable drawable) {
698 if( animGroup.isToggleOn() ) {
699 final Quaternion rot = animGroup.getRotation();
700 final Vec3f euler = rot.toEuler(new Vec3f());
701 if( FloatUtil.HALF_PI <= euler.y() ) {
702 dir = -1f;
703 } else if( euler.y() <= -FloatUtil.HALF_PI ) {
704 dir = 1f;
705 }
706 rot.rotateByAngleY( frame_velocity * dir );
707 animGroup.setRotation(rot);
708 }
709 final String text = String.format("%s, v %.1f mm/s, r %.3f rad/s",
710 scene.getStatusText(drawable, options.renderModes, dpiV), velocity * 1e3f, ang_velo);
711 statusLabel.setText(text);
712 }
713 @Override
714 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
715 });
716 }
717
718 /**
719 * Add a HUD UI to the scene
720 * @param scene
721 * @param animGroup
722 * @param glad
723 */
724 void sub02AddUItoScene(final Scene scene, final AnimGroup animGroup, final int mainAnimSetIdx, final GLAutoDrawable glad) {
725 final Group buttonsRight = new Group();
726
727 final float buttonWidth = sceneBox.getWidth() * 0.09f;
728 final float buttonHeight = buttonWidth / 3.0f;
729 final float buttonZOffset = scene.getZEpsilon(16);
730 final Vec2f fixedSymSize = new Vec2f(0.0f, 1.0f);
731 final Vec2f symSpacing = new Vec2f(0f, 0.2f);
732
733 buttonsRight.setLayout(new GridLayout(buttonWidth, buttonHeight, Alignment.Fill, new Gap(buttonHeight*0.50f, buttonWidth*0.10f), 8));
734 {
735 final Button button = new Button(options.renderModes, fontSymbols,
736 fontSymbols.getUTF16String("play_arrow"), fontSymbols.getUTF16String("pause"),
737 buttonWidth, buttonHeight, buttonZOffset);
738 button.setSpacing(symSpacing, fixedSymSize);
739 button.onToggle((final Shape s) -> {
740 System.err.println("Play/Pause "+s);
741 animGroup.setTickPaused ( s.isToggleOn() );
742 if( s.isToggleOn() ) {
743 animGroup.setTickPaused ( false );
744 if( null != mPlayer ) {
745 mPlayer.resume();
746 }
747 } else {
748 animGroup.setTickPaused ( true );
749 if( null != mPlayer ) {
750 mPlayer.pause(false);
751 }
752 }
753 });
754 button.setToggle(true); // on == play
755 buttonsRight.addShape(button);
756 }
757 {
758 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("fast_forward"), buttonWidth, buttonHeight, buttonZOffset); // next (ffwd)
759 button.setSpacing(symSpacing, fixedSymSize);
760 button.addMouseListener(new Shape.MouseGestureAdapter() {
761 @Override
762 public void mouseClicked(final MouseEvent e) {
763 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
764 if( null != as ) {
765 as.setAnimationActive(false);
766 }
767 } } );
768 buttonsRight.addShape(button);
769 }
770 {
771 final Button button = new Button(options.renderModes, fontSymbols,
772 fontSymbols.getUTF16String("rotate_right"), fontSymbols.getUTF16String("stop_circle"),
773 buttonWidth, buttonHeight, buttonZOffset); // rotate (replay)
774 button.setSpacing(symSpacing, fixedSymSize);
775 button.setToggleable(true);
776 button.onToggle((final Shape s) -> {
777 animGroup.toggle();
778 });
779 buttonsRight.addShape(button);
780 }
781 {
782 final Button button = new Button(options.renderModes, fontButtons, " < Rot > ", buttonWidth, buttonHeight, buttonZOffset);
783 button.addMouseListener(new Shape.MouseGestureAdapter() {
784 @Override
785 public void mouseClicked(final MouseEvent e) {
786 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
787 int axis = 1;
788 if( e.isControlDown() ) {
789 axis = 0;
790 } else if( e.isAltDown() ) {
791 axis = 2;
792 }
793 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
794 rotateShape(animGroup, FloatUtil.adegToRad(1f), axis);
795 } else {
796 rotateShape(animGroup, FloatUtil.adegToRad(-1f), axis);
797 }
798 } } );
799 buttonsRight.addShape(button);
800 }
801 {
802 final Button button = new Button(options.renderModes, fontButtons, " < Velo > ", buttonWidth, buttonHeight, buttonZOffset);
803 button.addMouseListener(new Shape.MouseGestureAdapter() {
804 @Override
805 public void mouseClicked(final MouseEvent e) {
806 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
807 final float scale = e.isShiftDown() ? 1f : 10f;
808 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
809 setVelocity(velocity - scale / 1000f);
810 } else {
811 setVelocity(velocity + scale / 1000f);
812 }
813 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
814 if( null != as ) {
815 as.setAnimationActive(false);
816 }
817 } } );
818 buttonsRight.addShape(button);
819 }
820 {
821 final Button button = new Button(options.renderModes, fontButtons, "increment", "realtime", buttonWidth, buttonHeight, buttonZOffset);
822 button.onToggle((final Shape s) -> {
823 animGroup.setFixedPeriod( s.isToggleOn() ? 0 : 1f/monitorRefresh );
824 System.err.println("Realtime/Incr "+s+", period "+animGroup.getFixedPeriod());
825 });
826 button.setToggle(true); // on == realtime
827 buttonsRight.addShape(button);
828 }
829 {
830 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("camera"), buttonWidth, buttonHeight, buttonZOffset); // snapshot (camera)
831 button.setSpacing(symSpacing, fixedSymSize);
832 button.addMouseListener(new Shape.MouseGestureAdapter() {
833 @Override
834 public void mouseClicked(final MouseEvent e) {
835 scene.screenshot(false, scene.nextScreenshotFile(null, UISceneDemo03.class.getSimpleName(), options.renderModes, glad.getChosenGLCapabilities(), null));
836 manualScreenShotCount[0]++;
837 } } );
838 buttonsRight.addShape(button);
839 }
840 {
841 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("power_settings_new"), buttonWidth, buttonHeight, buttonZOffset); // exit (power_settings_new)
842 button.setSpacing(symSpacing, fixedSymSize);
843 button.setColor(0.7f, 0.3f, 0.3f, 1.0f);
844 button.addMouseListener(new Shape.MouseGestureAdapter() {
845 @Override
846 public void mouseClicked(final MouseEvent e) {
847 MiscUtils.destroyWindow(glad);
848 } } );
849 buttonsRight.addShape(button);
850 }
851 TreeTool.forAll(buttonsRight, (final Shape s) -> { s.setDragAndResizable(false); return false; });
852 buttonsRight.validate(glad.getChosenGLCapabilities().getGLProfile());
853 buttonsRight.moveTo(sceneBox.getWidth()/2f - buttonsRight.getScaledWidth()*1.02f,
854 sceneBox.getHeight()/2f - buttonsRight.getScaledHeight()*1.02f, 0f);
855 scene.addShape(buttonsRight);
856 if( DEBUG ) {
857 System.err.println("Buttons-Right: Button-1 "+buttonsRight.getShapes().get(0));
858 System.err.println("Buttons-Right: SceneBox "+sceneBox);
859 System.err.println("Buttons-Right: scaled "+buttonsRight.getScaledWidth()+" x "+buttonsRight.getScaledHeight());
860 System.err.println("Buttons-Right: Box "+buttonsRight.getBounds());
861 System.err.println("Buttons-Right: "+buttonsRight);
862 }
863 }
864
865 class MyGLMediaEventListener implements GLMediaEventListener {
866 @Override
867 public void attributesChanged(final GLMediaPlayer mp, final GLMediaPlayer.EventMask eventMask, final long when) {
868 System.err.println("MediaPlayer.1 AttributesChanges: "+eventMask+", when "+when);
869 System.err.println("MediaPlayer.1 State: "+mp);
870 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
871 new InterruptSource.Thread() {
872 @Override
873 public void run() {
874 try {
875 mp.initGL(null);
876 if ( GLMediaPlayer.State.Paused == mp.getState() ) { // init OK
877 mp.resume();
878 }
879 System.out.println("MediaPlayer.1 "+mp);
880 } catch (final Exception e) {
881 e.printStackTrace();
882 mp.destroy(null);
883 mPlayer = null;
884 return;
885 }
886 }
887 }.start();
888 }
889 boolean destroy = false;
890 Throwable err = null;
891
892 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
893 err = mp.getStreamException();
894 if( null != err ) {
895 System.err.println("MovieSimple State: Exception");
896 destroy = true;
897 } else {
898 new InterruptSource.Thread() {
899 @Override
900 public void run() {
901 mp.setPlaySpeed(1f);
902 mp.seek(0);
903 mp.resume();
904 }
905 }.start();
906 }
907 }
908 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) ) {
909 err = mp.getStreamException();
910 destroy = true;;
911 }
912 if( destroy ) {
913 if( null != err ) {
914 System.err.println("MovieSimple State: Exception");
915 err.printStackTrace();
916 }
917 mp.destroy(null);
918 mPlayer = null;
919 }
920 }
921 }
922
923}
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
Definition: Region.java:62
static String getRenderModeString(final int renderModes)
Returns a unique technical description string for renderModes as follows:
Definition: Region.java:251
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
Definition: Region.java:115
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.
Definition: AnimGroup.java:101
ShapeData addShape(final AnimGroup g, final Shape s, final ShapeSetup op)
Adds given Shape to this Set and its AnimGroup wrapping it in ShapeData.
Definition: AnimGroup.java:172
Group of animated Shapes including other static Shapes, optionally utilizing a Group....
Definition: AnimGroup.java:60
final boolean getTickPaused()
Definition: AnimGroup.java:542
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...
Definition: AnimGroup.java:453
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.
Definition: AnimGroup.java:264
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 ...
Definition: AnimGroup.java:372
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.
Definition: AnimGroup.java:327
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...
Definition: AnimGroup.java:496
Graph based GLRegion Shape.
Definition: GraphShape.java:55
void addShape(final Shape s)
Adds a Shape.
Definition: Group.java:225
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
Definition: Group.java:346
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
Definition: Group.java:686
GraphUI Scene.
Definition: Scene.java:103
void addShape(final Shape s)
Adds a Shape.
Definition: Scene.java:292
final void setClearParams(final float[] clearColor, final int clearMask)
Sets the clear parameter for glClearColor(..) and glClear(..) to be issued at display(GLAutoDrawable)...
Definition: Scene.java:226
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
Definition: Scene.java:412
RegionRenderer getRenderer()
Returns the associated RegionRenderer.
Definition: Scene.java:213
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
Definition: Scene.java:235
int setAAQuality(final int v)
Sets RegionRenderer#setAAQuality(int).
Definition: Scene.java:388
void dispose(final GLAutoDrawable drawable)
Disposes all added Shapes.
Definition: Scene.java:610
final Recti getViewport(final Recti target)
Copies the current int[4] viewport in given target and returns it for chaining.
Definition: Scene.java:775
PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
Definition: Scene.java:786
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
Definition: Scene.java:683
synchronized void attachInputListenerTo(final GLWindow window)
Definition: Scene.java:251
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
Definition: Scene.java:492
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.
Definition: Scene.java:463
Generic Shape, potentially using a Graph via GraphShape or other means of representing content.
Definition: Shape.java:87
Shape setColor(final float r, final float g, final float b, final float a)
Set base color.
Definition: Shape.java:1389
final Shape move(final float dtx, final float dty, final float dtz)
Move about scaled distance.
Definition: Shape.java:557
final Shape setScale(final Vec3f s)
Set scale factor to given scale.
Definition: Shape.java:641
final Shape setInteractive(final boolean v)
Set whether this shape is interactive in general, i.e.
Definition: Shape.java:1711
final Shape setResizable(final boolean resizable)
Set whether this shape is resizable, i.e.
Definition: Shape.java:1769
final Shape moveTo(final float tx, final float ty, final float tz)
Move to scaled position.
Definition: Shape.java:543
final Shape setToggle(final boolean v)
Set this shape's toggle state, default is off.
Definition: Shape.java:1587
final Quaternion getRotation()
Returns Quaternion for rotation.
Definition: Shape.java:595
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
Definition: Shape.java:850
final Shape setRotation(final Quaternion q)
Sets the rotation Quaternion.
Definition: Shape.java:604
final void destroy(final GL2ES2 gl, final RegionRenderer renderer)
Destroys all data.
Definition: Shape.java:457
final Shape scale(final Vec3f s)
Multiply current scale factor by given scale.
Definition: Shape.java:661
final Shape setRotationPivot(final float px, final float py, final float pz)
Set unscaled rotation origin, aka pivot.
Definition: Shape.java:620
final Shape setToggleable(final boolean toggleable)
Set this shape toggleable, default is off.
Definition: Shape.java:1573
A GraphUI text label GraphShape.
Definition: Label.java:50
A GraphUI rectangle GraphShape.
Definition: Rectangle.java:47
Basic Float math utility functions.
Definition: FloatUtil.java:83
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.
Definition: Quaternion.java:45
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.
Definition: Vec3f.java:37
static final Vec3f UNIT_Y
Definition: Vec3f.java:41
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
Definition: Vec3f.java:239
4D Vector based upon four float components.
Definition: Vec4f.java:37
Axis Aligned Bounding Box.
Definition: AABBox.java:54
final float getWidth()
Definition: AABBox.java:879
final AABBox set(final AABBox o)
Assign values of given AABBox to this instance.
Definition: AABBox.java:262
final float getHeight()
Definition: AABBox.java:883
final AABBox resizeWidth(final float deltaLeft, final float deltaRight)
Resize width of this AABBox with explicit left- and right delta values.
Definition: AABBox.java:218
final Frustum getFrustum()
Returns the frustum, derived from projection x modelview.
Visual output device, i.e.
static float[] mmToInch(final float[] result, final float[] ppmm)
Converts [1/mm] to [1/inch] from ppmm into result.
static float[] inchToMM(final float[] result, final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
final MonitorMode getCurrentMode()
Returns the cached current MonitorMode w/o native query.
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter value according to the current mode's surface resolution.
final float getRefreshRate()
Returns the vertical refresh rate.
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.
Definition: Screen.java:58
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:466
final void setTitle(final String title)
Definition: GLWindow.java:297
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:461
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
CapabilitiesChooser setCapabilitiesChooser(final CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.
Definition: GLWindow.java:261
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
final VersionNumberString getGLVersionNumber()
Returns this context OpenGL version.
Definition: GLContext.java:781
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.
Definition: GLProfile.java:77
static JoglVersion getInstance()
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
StringBuilder toString(final GL gl, StringBuilder sb)
static void dump(final GLAutoDrawable drawable)
Definition: MSAATool.java:51
Res independent Shape, Scene attached to GLWindow showing multiple animated shape movements.
static void main(final String[] args)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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 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.
int fixDefaultAARenderModeWithDPIThreshold(final float dpiV)
Changes default AA rendering bit if not modified via parse(), i.e.
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.
static void waitForKey(final String preMessage)
Definition: MiscUtils.java:167
static int atoi(final String str, final int def)
Definition: MiscUtils.java:60
static float atof(final String str, final float def)
Definition: MiscUtils.java:78
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.
Definition: Animator.java:344
final synchronized boolean stop()
Stops this animator.
Definition: Animator.java:368
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.
Definition: Font.java:60
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)...
Definition: Font.java:338
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:
Definition: Window.java:115
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',...
Definition: GL.java:43
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',...
Definition: GL.java:607
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...
Definition: GL.java:738
GLMediaPlayer interface specifies a TextureSequence state machine using a multiplexed audio/video str...
State pause(boolean flush)
Pauses the StreamWorker decoding thread.
State destroy(GL gl)
Releases the GL, stream and other resources, including attached user objects.
static final int STREAM_ID_NONE
Constant {@value} for mute or not available.
static final int TEXTURE_COUNT_DEFAULT
Default texture count, value {@value}.
void playStream(Uri streamLoc, int vid, int aid, int sid, int textureCount)
Issues asynchronous stream initialization.
void addEventListener(GLMediaEventListener l)
Adds a GLMediaEventListener to this player.
StreamException getStreamException()
Returns the StreamException caught in the decoder thread, or null if none occured.
State resume()
Starts or resumes the StreamWorker decoding thread.
static final int STREAM_ID_AUTO
Constant {@value} for auto or unspecified.