JOGL v2.6.0-rc-20250722
JOGL, High-Performance Graphics Binding for Java™ (public API).
UISceneDemo03.java
Go to the documentation of this file.
1/**
2 * Copyright 2023 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.MonitorDevice;
63import com.jogamp.newt.event.KeyAdapter;
64import com.jogamp.newt.event.KeyEvent;
65import com.jogamp.newt.event.MouseAdapter;
66import com.jogamp.newt.event.MouseEvent;
67import com.jogamp.newt.event.WindowAdapter;
68import com.jogamp.newt.event.WindowEvent;
69import com.jogamp.newt.opengl.GLWindow;
70import com.jogamp.opengl.GL;
71import com.jogamp.opengl.GL2ES2;
72import com.jogamp.opengl.GLAnimatorControl;
73import com.jogamp.opengl.GLAutoDrawable;
74import com.jogamp.opengl.GLCapabilities;
75import com.jogamp.opengl.GLContext;
76import com.jogamp.opengl.GLEventListener;
77import com.jogamp.opengl.GLProfile;
78import com.jogamp.opengl.JoglVersion;
79import com.jogamp.opengl.demos.graph.FontSetDemos;
80import com.jogamp.opengl.demos.util.CommandlineOptions;
81import com.jogamp.opengl.demos.util.MiscUtils;
82import com.jogamp.opengl.util.Animator;
83import com.jogamp.opengl.util.av.GLMediaPlayer;
84import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
85import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
86
87import jogamp.graph.ui.TreeTool;
88
89/**
90 * Res independent Shape, Scene attached to GLWindow showing multiple animated shape movements.
91 * <p>
92 * This variation of {@link UISceneDemo00} shows
93 * <ul>
94 * <li>Two repetitive steady scrolling text lines. One text shorter than the line-width and one longer.</li>
95 * <li>One line of animated rectangles, rotating around their z-axis and accelerating towards their target.</li>
96 * <li>A text animation assembling one line of text,
97 * each glyph coming from from a random 3D point moving to its destination all at once including rotation.</li>
98 * <li>One line of text with sine wave animation flattening and accelerating towards its target.</li>
99 * </ul>
100 * </p>
101 * <p>
102 * Blog entry: https://jausoft.com/blog/2023/08/27/graphui_animation_animgroup/
103 * </p>
104 * <p>
105 * - Pass '-keep' to main-function to keep running.
106 * - Pass '-aspeed' to vary velocity
107 * - Pass '-rspeed <float>' angular velocity in radians/s
108 * - Pass '-no_anim_box' to not show a visible and shrunken box around the AnimGroup
109 * - Pass '-audio <uri or file-path>' to play audio (only)
110 * </p>
111 */
112public class UISceneDemo03 {
113 static final boolean DEBUG = false;
114
115 static final String[] originalTexts = {
116 " JOGL, Java™ Binding for the OpenGL® API ",
117 " GraphUI, Resolution Independent Curves ",
118 " JogAmp, Java™ libraries for 3D & Media ",
119 " Linux, Android, Windows, MacOS; iOS, embedded, etc on demand"
120 };
121
122 static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
123 // static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.NORM_RENDERING_BIT, Region.DEFAULT_AA_QUALITY, 0, 4);
124 static float frame_velocity = 5f / 1e3f; // [m]/[s]
125 static float velocity = 30 / 1e3f; // [m]/[s]
126 static float ang_velo = velocity * 60f; // [radians]/[s]
127 static int autoSpeed = -1;
128
129 static Uri audioUri = null;
130 static GLMediaPlayer mPlayer = null;
131
132 static final int[] manualScreenShorCount = { 0 };
133
134 static void setVelocity(final float v) {
135 velocity = v; // Math.max(1/1e3f, v);
136 ang_velo = velocity * 60f;
137 autoSpeed = 0;
138 }
139
140 public static void main(final String[] args) throws IOException {
141 setVelocity(80/1000f);
142 autoSpeed = -1;
143 options.keepRunning = true;
144 boolean showAnimBox = true;
145
146 if (0 != args.length) {
147 final int[] idx = { 0 };
148 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
149 if( options.parse(args, idx) ) {
150 continue;
151 } else if (args[idx[0]].equals("-v")) {
152 ++idx[0];
153 setVelocity(MiscUtils.atoi(args[idx[0]], (int) velocity * 1000) / 1000f);
154 } else if(args[idx[0]].equals("-aspeed")) {
155 setVelocity(80/1000f);
156 autoSpeed = -1;
157 options.keepRunning = true;
158 } else if(args[idx[0]].equals("-rspeed")) {
159 ++idx[0];
160 ang_velo = MiscUtils.atof(args[idx[0]], ang_velo);
161 } else if(args[idx[0]].equals("-no_anim_box")) {
162 showAnimBox = false;
163 } else if(args[idx[0]].equals("-audio")) {
164 ++idx[0];
165 try {
166 audioUri = Uri.cast( args[idx[0]] );
167 } catch (final URISyntaxException e1) {
168 System.err.println(e1);
169 audioUri = null;
170 }
171 }
172 }
173 }
174 System.err.println(JoglVersion.getInstance().toString());
175 // renderModes |= Region.COLORCHANNEL_RENDERING_BIT;
176 System.err.println(options);
177
178 final GLCapabilities reqCaps = options.getGLCaps();
179 System.out.println("Requested: " + reqCaps);
180
181 //
182 // Resolution independent, no screen size
183 //
184 final Font font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf",FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
185 // final Font font = FontFactory.get(IOUtil.getResource("jogamp/graph/font/fonts/ubuntu/Ubuntu-R.ttf",FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
186 System.err.println("Font FreeSerif: " + font.getFullFamilyName());
187 final Font fontStatus = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMono.ttf", FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
188 System.err.println("Font Status: " + fontStatus.getFullFamilyName());
189
190 final Scene scene = new Scene(options.graphAASamples);
191 scene.setClearParams(new float[] { 1f, 1f, 1f, 1f }, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
193
194 final AnimGroup animGroup = new AnimGroup(null);
195 scene.addShape(animGroup);
196
197 scene.setPMvCullingEnabled(true);
198 animGroup.setPMvCullingEnabled(true);
199
200 final Animator animator = new Animator(0 /* w/o AWT */);
201 animator.setUpdateFPSFrames(1 * 60, null); // System.err);
202
203 final GLWindow window = GLWindow.create(reqCaps);
204 window.invoke(false, (final GLAutoDrawable glad) -> {
205 glad.getGL().setSwapInterval(options.swapInterval);
206 return true;
207 } );
208 window.setSize(options.surface_width, options.surface_height);
209 window.setTitle(UISceneDemo03.class.getSimpleName() + ": " + window.getSurfaceWidth() + " x " + window.getSurfaceHeight());
210 window.setVisible(true);
211 System.out.println("Chosen: " + window.getChosenGLCapabilities());
212
213 window.addGLEventListener(scene);
214 scene.attachInputListenerTo(window);
215
216 final float pixPerMM, dpiV;
217 {
218 final float[] tmp = window.getPixelsPerMM(new float[2]);
219 pixPerMM = tmp[1]; // [px]/[mm]
220 MonitorDevice.mmToInch( tmp );
221 dpiV = tmp[1];
222 }
223 {
224 final int o = options.fixDefaultAARenderModeWithDPIThreshold(dpiV);
225 System.err.println("AUTO RenderMode: dpi "+dpiV+", threshold "+options.noAADPIThreshold+
226 ", mode "+Region.getRenderModeString(o)+" -> "+
228 }
229
230 animator.add(window);
231 animator.setExclusiveContext(options.exclusiveContext);
232 animator.start();
233
234 //
235 // After initial display we can use screen resolution post initial
236 // Scene.reshape(..)
237 // However, in this example we merely use the resolution to
238 // - Compute the animation values with DPI
239 scene.waitUntilDisplayed();
240
241 window.invoke(true, (drawable) -> {
242 final GL gl = drawable.getGL();
244 // gl.glDepthFunc(GL.GL_LEQUAL);
245 gl.glEnable(GL.GL_BLEND);
246 return true;
247 });
248
249 final GLProfile hasGLP = window.getChosenGLCapabilities().getGLProfile();
250 final AABBox sceneBox = scene.getBounds();
251 final float sceneBoxFrameWidth;
252 {
253 sceneBoxFrameWidth = sceneBox.getWidth() * 0.0025f;
254 final GraphShape r = new Rectangle(options.renderModes, sceneBox, sceneBoxFrameWidth);
255 if( showAnimBox ) {
256 r.setColor(0.45f, 0.45f, 0.45f, 0.9f);
257 } else {
258 r.setColor(0f, 0f, 0f, 0f);
259 }
260 r.setInteractive(false);
261 animGroup.addShape( r );
262 }
263 animGroup.setRotationPivot(0, 0, 0);
264 if( showAnimBox ) {
265 animGroup.scale(0.85f, 0.85f, 1f);
266 animGroup.move(-sceneBox.getWidth()/2f*0.075f, 0f, 0f);
267 animGroup.setRotation( animGroup.getRotation().rotateByAngleY(0.1325f) );
268 } else {
269 animGroup.scale(1.0f, 1.0f, 1f);
270 }
271 animGroup.validate(hasGLP);
272 animGroup.setInteractive(false);
273 animGroup.setToggleable(true);
274 animGroup.setResizable(false);
275 animGroup.setToggle( false );
276 System.err.println("SceneBox " + sceneBox);
277 System.err.println("Frustum " + scene.getMatrix().getFrustum());
278 System.err.println("AnimGroup.0: "+animGroup);
279
280 final Label statusLabel;
281 {
282 final AABBox fbox = fontStatus.getGlyphBounds("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
283 final float statusLabelScale = sceneBox.getWidth() / fbox.getWidth();
284 System.err.println("StatusLabelScale: " + statusLabelScale + " = " + sceneBox.getWidth() + " / " + fbox.getWidth() + ", " + fbox);
285
286 statusLabel = new Label(options.renderModes, fontStatus, "Nothing there yet");
287 statusLabel.setScale(statusLabelScale, statusLabelScale, 1f);
288 statusLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f);
289 statusLabel.moveTo(sceneBox.getMinX(), sceneBox.getMinY() + statusLabelScale * (fontStatus.getMetrics().getLineGap() - fontStatus.getMetrics().getDescent()), 0f);
290 scene.addShape(statusLabel);
291 }
292 sub01SetupWindowListener(window, scene, animGroup, statusLabel, dpiV);
293
294 {
295 final StringBuilder sb = new StringBuilder();
296 for(final String s : originalTexts) {
297 sb.append(s).append("\n");
298 }
299 final Label l = new Label(options.renderModes, font, sb.toString()); // originalTexts[0]);
300 l.validate(hasGLP);
301 final float scale = sceneBox.getWidth() / l.getBounds().getWidth();
302 l.setScale(scale, scale, 1f);
303 l.setColor(0.1f, 0.1f, 0.1f, 1.0f);
304 l.moveTo(sceneBox.getMinX(), 0f, 0f);
305 scene.addShape(l);
306
307 if( options.wait_to_start ) {
308 statusLabel.setText("Press enter to continue");
309 MiscUtils.waitForKey("Start");
310 }
311
312 window.invoke(true, (drawable) -> {
313 final GL2ES2 gl = drawable.getGL().getGL2ES2();
314 scene.screenshot(gl, scene.nextScreenshotFile(null, UISceneDemo03.class.getSimpleName(), options.renderModes, window.getChosenGLCapabilities(), null));
315 scene.removeShape(gl, l);
316 return true;
317 });
318 }
319
320 //
321 // HUD UI
322 //
323 sub02AddUItoScene(scene, animGroup, 2, window);
324
325 //
326 // Setup the moving glyphs
327 //
328 final boolean[] z_only = { true };
329 int txt_idx = 0;
330
331 final AABBox animBox = new AABBox( animGroup.getBounds() );
332 final float g_w = animBox.getWidth();
333 System.err.println("AnimBox " + animBox);
334 System.err.println("AnimGroup.1 " + animGroup);
335
336 final float[] top_ypos = { 0 };
337 window.invoke(true, (drawable) -> {
338 final float fontScale2;
339 {
340 final String vs = "Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp. XXXXXXXXXXXXXXXXXXXXXXXXXXX";
341 final AABBox fbox = font.getGlyphBounds(vs);
342 fontScale2 = g_w / fbox.getWidth();
343 System.err.println("FontScale2: " + fontScale2 + " = " + g_w + " / " + fbox.getWidth());
344 }
345 final AABBox clippedBox = new AABBox(animBox).resizeWidth(-sceneBoxFrameWidth, -sceneBoxFrameWidth);
346 top_ypos[0] = clippedBox.getMaxY();
347 // AnimGroup.Set 1:
348 // Circular short scrolling text (right to left) without rotation, no acceleration
349 {
350 final String vs = "Welcome to Göthel Software *** Jausoft *** https://jausoft.com *** We do software ... Check out Gamp.";
351 top_ypos[0] -= fontScale2 * 1.5f;
352 animGroup.addGlyphSetHorizScroll01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(), options.renderModes,
353 font, vs, fontScale2, new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
354 50 / 1e3f /* velocity */, clippedBox, top_ypos[0]);
355 }
356 // AnimGroup.Set 2:
357 // Circular long scrolling text (right to left) without rotation, no acceleration
358 {
359 final String vs = VersionUtil.getPlatformInfo().replace(Platform.getNewline(), "; ").replace(VersionUtil.SEPERATOR, " *** ").replaceAll("\\s+", " ");
360 top_ypos[0] -= fontScale2 * 1.2f;
361 animGroup.addGlyphSetHorizScroll01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(), options.renderModes,
362 font, vs, fontScale2, new Vec4f(0.1f, 0.1f, 0.1f, 0.9f),
363 30 / 1e3f /* velocity */, clippedBox, top_ypos[0]);
364 }
365 return true;
366 });
367
368 //
369 // Optional Audio
370 //
371 if( null != audioUri ) {
373 mPlayer.addEventListener( new MyGLMediaEventListener() );
375 } else {
376 mPlayer = null;
377 }
378
379 do {
380 System.err.println();
381 System.err.println("Next animation loop ...");
382 //
383 // Setup new animation sequence
384 // - Flush all AnimGroup.Set entries
385 // - Add newly created AnimGroup.Set entries
386 //
387 final String curText = originalTexts[txt_idx];
388 final float fontScale;
389 final AnimGroup.Set[] dynAnimSet = { null, null, null };
390 {
391 final AABBox fbox = font.getGlyphBounds(curText);
392 fontScale = g_w / fbox.getWidth();
393 System.err.println("FontScale: " + fontScale + " = " + g_w + " / " + fbox.getWidth());
394 }
395 z_only[0] = !z_only[0];
396 window.invoke(true, (drawable) -> {
397 // AnimGroup.Set 3: This `mainAnimSet[0]` is controlling overall animation duration
398 // Rotating animated text moving to target (right to left) + slight acceleration on rotation
399 dynAnimSet[0] = animGroup.addGlyphSetRandom01(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
400 options.renderModes, font, curText, fontScale, new Vec4f(0.1f, 0.1f, 0.1f, 1f),
401 0f /* accel */, velocity, FloatUtil.PI/20f /* ang_accel */, ang_velo,
402 animBox, z_only[0], new Random(), new AnimGroup.TargetLerp(Vec3f.UNIT_Y));
403
404 // AnimGroup.Set 4:
405 // Sine animated text moving to target (right to left) with sine amplitude alternating on Z- and Y-axis + acceleration
406 {
407 final GL gl = drawable.getGL();
408 final GLContext ctx = gl.getContext();
409 final String vs = "JogAmp Version "+JoglVersion.getInstance().getImplementationVersion()+
410 ", GL "+ctx.getGLVersionNumber().getVersionString()+
411 ", GLSL "+ctx.getGLSLVersionNumber().getVersionString() +
412 " by "+gl.glGetString(GL.GL_VENDOR);
413 final float fontScale2;
414 {
415 final AABBox fbox = font.getGlyphBounds(vs);
416 fontScale2 = g_w / fbox.getWidth() * 0.6f;
417 }
418 // Translation : We use velocity as acceleration (good match) and pass only velocity/10 as starting velocity
419 dynAnimSet[1] = animGroup.addGlyphSet(pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
420 options.renderModes, font, 'X', vs, fontScale2,
421 velocity /* accel */, velocity/10f, 0f /* ang_accel */, 2*FloatUtil.PI /* 1-rotation/s */,
422 new AnimGroup.SineLerp(z_only[0] ? Vec3f.UNIT_Z : Vec3f.UNIT_Y, 1.618f, 1.618f),
423 (final AnimGroup.Set as, final int idx, final AnimGroup.ShapeData sd) -> {
424 sd.shape.setColor(0.1f, 0.1f, 0.1f, 0.9f);
425
426 sd.targetPos.add(
427 animBox.getMinX() + as.refShape.getScaledWidth() * 1.0f,
428 animBox.getMinY() + as.refShape.getScaledHeight() * 2.0f, 0f);
429
430 sd.startPos.set( sd.targetPos.x() + animBox.getWidth(),
431 sd.targetPos.y(), sd.targetPos.z());
432 sd.shape.moveTo( sd.startPos );
433 } );
434 }
435 // AnimGroup.Set 5:
436 // 3 animated Shapes moving to target (right to left) while rotating around z-axis + acceleration on translation
437 {
438 final float size2 = fontScale/2;
439 final float yscale = 1.1f;
440 final GraphShape refShape = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f );
441 dynAnimSet[2] = animGroup.addAnimSet(
442 pixPerMM, hasGLP, scene.getMatrix(), scene.getViewport(),
443 velocity /* accel */, velocity/10f, 0f /* ang_accel */, 2*FloatUtil.PI /* 1-rotation/s */,
444 new AnimGroup.TargetLerp(Vec3f.UNIT_Z), refShape);
445 final AnimGroup.ShapeSetup shapeSetup = (final AnimGroup.Set as, final int idx, final AnimGroup.ShapeData sd) -> {
446 sd.targetPos.add(animBox.getMinX() + as.refShape.getScaledWidth() * 1.0f,
447 top_ypos[0] - as.refShape.getScaledHeight() * 1.5f, 0f);
448
449 sd.startPos.set( sd.targetPos.x() + animBox.getWidth(),
450 sd.targetPos.y(), sd.targetPos.z());
451 sd.shape.moveTo( sd.startPos );
452 };
453 refShape.setColor(1.0f, 0.0f, 0.0f, 0.9f);
455 dynAnimSet[2].addShape(animGroup, refShape, shapeSetup);
456 {
457 final Shape s = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f ).validate(hasGLP);
458 s.setColor(0.0f, 1.0f, 0.0f, 0.9f);
459 s.move(refShape.getScaledWidth() * 1.5f * 1, 0, 0);
460 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
461 }
462 {
463 final Shape s = new Rectangle(options.renderModes, size2, size2*yscale, sceneBox.getWidth() * 0.0025f ).validate(hasGLP);
464 s.setColor(0.0f, 0.0f, 1.0f, 0.9f);
465 s.move(refShape.getScaledWidth() * 1.5f * 2, 0, 0);
467 dynAnimSet[2].addShape(animGroup, s, shapeSetup);
468 }
469 }
470 return true;
471 });
472 scene.setAAQuality(options.graphAAQuality);
473
474 final long t0_us = Clock.currentNanos() / 1000; // [us]
475 while ( ( null == dynAnimSet[0] || dynAnimSet[0].isAnimationActive() || animGroup.getTickPaused() ) && window.isNativeValid() ) {
476 try { Thread.sleep(250); } catch (final InterruptedException e1) { }
477 }
478 if( window.isNativeValid() ) {
479 final float has_dur_s = ((Clock.currentNanos() / 1000) - t0_us) / 1e6f; // [us]
480 System.err.printf("Text travel-duration %.3f s, %d chars%n", has_dur_s, curText.length());
481 if( scene.getScreenshotCount() - manualScreenShorCount[0] < 1 + originalTexts.length ) {
482 scene.screenshot(true, scene.nextScreenshotFile(null, UISceneDemo03.class.getSimpleName(), options.renderModes, window.getChosenGLCapabilities(), null));
483 }
484 try { Thread.sleep(1500); } catch (final InterruptedException e1) { }
485 while ( animGroup.getTickPaused() && window.isNativeValid() ) {
486 try { Thread.sleep(250); } catch (final InterruptedException e1) { }
487 }
488 if( autoSpeed > 0 ) {
489 if( velocity < 60/1000f ) {
490 setVelocity(velocity + 9/1000f);
491 } else {
492 setVelocity(velocity - 9/1000f);
493 autoSpeed = -1;
494 }
495 } else if( autoSpeed < 0 ) {
496 if( velocity > 11/1000f ) {
497 setVelocity(velocity - 9/1000f);
498 } else {
499 setVelocity(velocity + 9/1000f);
500 autoSpeed = 1;
501 }
502 }
503 txt_idx = ( txt_idx + 1 ) % originalTexts.length;
504 }
505 if( window.isNativeValid() ) {
506 window.invoke(true, (drawable) -> {
507 animGroup.removeAnimSets(drawable.getGL().getGL2ES2(), scene.getRenderer(), Arrays.asList(dynAnimSet));
508 return true;
509 } );
510 }
511 } while (options.keepRunning && window.isNativeValid());
512 if (!options.stayOpen) {
513 MiscUtils.destroyWindow(window);
514 }
515 }
516
517 /**
518 * Setup Window listener for I/O
519 * @param window
520 * @param animGroup
521 */
522 static void sub01SetupWindowListener(final GLWindow window, final Scene scene, final AnimGroup animGroup, final Label statusLabel, final float dpiV) {
523 window.addWindowListener(new WindowAdapter() {
524 @Override
525 public void windowResized(final WindowEvent e) {
526 window.setTitle(UISceneDemo03.class.getSimpleName() + ": " + window.getSurfaceWidth() + " x " + window.getSurfaceHeight());
527 }
528
529 @Override
530 public void windowDestroyNotify(final WindowEvent e) {
531 final GLAnimatorControl animator = window.getAnimator();
532 if( null != animator ) {
533 animator.stop();
534 }
535 }
536 });
537 window.addKeyListener(new KeyAdapter() {
538 @Override
539 public void keyReleased(final KeyEvent e) {
540 final short keySym = e.getKeySymbol();
541 if (keySym == KeyEvent.VK_PLUS ||
542 keySym == KeyEvent.VK_ADD)
543 {
544 if (e.isShiftDown()) {
545 setVelocity(velocity + 10 / 1000f);
546 } else {
547 setVelocity(velocity + 1 / 1000f);
548 }
549 } else if (keySym == KeyEvent.VK_MINUS ||
550 keySym == KeyEvent.VK_SUBTRACT)
551 {
552 if (e.isShiftDown()) {
553 setVelocity(velocity - 10 / 1000f);
554 } else {
555 setVelocity(velocity - 1 / 1000f);
556 }
557 } else if( keySym == KeyEvent.VK_F4 || keySym == KeyEvent.VK_ESCAPE || keySym == KeyEvent.VK_Q ) {
558 MiscUtils.destroyWindow(window);
559 } else if( keySym == KeyEvent.VK_SPACE ) {
560 animGroup.setTickPaused ( !animGroup.getTickPaused() );
561 } else if( keySym == KeyEvent.VK_ENTER ) {
562 animGroup.stopAnimation();
563 }
564 }
565 });
566 window.addMouseListener( new MouseAdapter() {
567 @Override
568 public void mouseWheelMoved(final MouseEvent e) {
569 int axis = 1;
570 if( e.isControlDown() ) {
571 axis = 0;
572 } else if( e.isAltDown() ) {
573 axis = 2;
574 }
575 final float angle = e.getRotation()[1] < 0f ? FloatUtil.adegToRad(-1f) : FloatUtil.adegToRad(1f);
576 rotateShape(animGroup, angle, axis);
577 }
578 });
579 window.addGLEventListener(new GLEventListener() {
580 float dir = 1f;
581 @Override
582 public void init(final GLAutoDrawable drawable) {
583 System.err.println(JoglVersion.getGLInfo(drawable.getGL(), null));
584 }
585 @Override
586 public void dispose(final GLAutoDrawable drawable) {}
587 @Override
588 public void display(final GLAutoDrawable drawable) {
589 if( animGroup.isToggleOn() ) {
590 final Quaternion rot = animGroup.getRotation();
591 final Vec3f euler = rot.toEuler(new Vec3f());
592 if( FloatUtil.HALF_PI <= euler.y() ) {
593 dir = -1f;
594 } else if( euler.y() <= -FloatUtil.HALF_PI ) {
595 dir = 1f;
596 }
597 rot.rotateByAngleY( frame_velocity * dir );
598 animGroup.setRotation(rot);
599 }
600 final String text = String.format("%s, v %.1f mm/s, r %.3f rad/s",
601 scene.getStatusText(drawable, options.renderModes, dpiV), velocity * 1e3f, ang_velo);
602 statusLabel.setText(text);
603 }
604 @Override
605 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
606 });
607 }
608
609 /**
610 * Add a HUD UI to the scene
611 * @param scene
612 * @param animGroup
613 * @param window
614 * @throws IOException
615 */
616 static void sub02AddUItoScene(final Scene scene, final AnimGroup animGroup, final int mainAnimSetIdx, final GLWindow window) throws IOException {
617 final AABBox sceneBox = scene.getBounds();
618 final Group buttonsRight = new Group();
619
620 final Font fontButtons = FontFactory.get(FontFactory.UBUNTU).getDefault();
621 final Font fontSymbols = FontFactory.get(FontFactory.SYMBOLS).getDefault();
622
623 final float buttonWidth = sceneBox.getWidth() * 0.09f;
624 final float buttonHeight = buttonWidth / 3.0f;
625 final float buttonZOffset = scene.getZEpsilon(16);
626 final Vec2f fixedSymSize = new Vec2f(0.0f, 1.0f);
627 final Vec2f symSpacing = new Vec2f(0f, 0.2f);
628
629 buttonsRight.setLayout(new GridLayout(buttonWidth, buttonHeight, Alignment.Fill, new Gap(buttonHeight*0.50f, buttonWidth*0.10f), 7));
630 {
631 final Button button = new Button(options.renderModes, fontSymbols,
632 fontSymbols.getUTF16String("play_arrow"), fontSymbols.getUTF16String("pause"),
633 buttonWidth, buttonHeight, buttonZOffset);
634 button.setSpacing(symSpacing, fixedSymSize);
635 button.onToggle((final Shape s) -> {
636 System.err.println("Play/Pause "+s);
637 animGroup.setTickPaused ( s.isToggleOn() );
638 if( s.isToggleOn() ) {
639 animGroup.setTickPaused ( false );
640 if( null != mPlayer ) {
641 mPlayer.resume();
642 }
643 } else {
644 animGroup.setTickPaused ( true );
645 if( null != mPlayer ) {
646 mPlayer.pause(false);
647 }
648 }
649 });
650 button.setToggle(true); // on == play
651 buttonsRight.addShape(button);
652 }
653 {
654 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("fast_forward"), buttonWidth, buttonHeight, buttonZOffset); // next (ffwd)
655 button.setSpacing(symSpacing, fixedSymSize);
656 button.addMouseListener(new Shape.MouseGestureAdapter() {
657 @Override
658 public void mouseClicked(final MouseEvent e) {
659 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
660 if( null != as ) {
661 as.setAnimationActive(false);
662 }
663 } } );
664 buttonsRight.addShape(button);
665 }
666 {
667 final Button button = new Button(options.renderModes, fontSymbols,
668 fontSymbols.getUTF16String("rotate_right"), fontSymbols.getUTF16String("stop_circle"),
669 buttonWidth, buttonHeight, buttonZOffset); // rotate (replay)
670 button.setSpacing(symSpacing, fixedSymSize);
671 button.setToggleable(true);
672 button.onToggle((final Shape s) -> {
673 animGroup.toggle();
674 });
675 buttonsRight.addShape(button);
676 }
677 {
678 final Button button = new Button(options.renderModes, fontButtons, " < Rot > ", buttonWidth, buttonHeight, buttonZOffset);
679 button.addMouseListener(new Shape.MouseGestureAdapter() {
680 @Override
681 public void mouseClicked(final MouseEvent e) {
682 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
683 int axis = 1;
684 if( e.isControlDown() ) {
685 axis = 0;
686 } else if( e.isAltDown() ) {
687 axis = 2;
688 }
689 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
690 rotateShape(animGroup, FloatUtil.adegToRad(1f), axis);
691 } else {
692 rotateShape(animGroup, FloatUtil.adegToRad(-1f), axis);
693 }
694 } } );
695 buttonsRight.addShape(button);
696 }
697 {
698 final Button button = new Button(options.renderModes, fontButtons, " < Velo > ", buttonWidth, buttonHeight, buttonZOffset);
699 button.addMouseListener(new Shape.MouseGestureAdapter() {
700 @Override
701 public void mouseClicked(final MouseEvent e) {
702 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
703 final float scale = e.isShiftDown() ? 1f : 10f;
704 if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
705 setVelocity(velocity - scale / 1000f);
706 } else {
707 setVelocity(velocity + scale / 1000f);
708 }
709 final AnimGroup.Set as = animGroup.getAnimSet(mainAnimSetIdx);
710 if( null != as ) {
711 as.setAnimationActive(false);
712 }
713 } } );
714 buttonsRight.addShape(button);
715 }
716 {
717 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("camera"), buttonWidth, buttonHeight, buttonZOffset); // snapshot (camera)
718 button.setSpacing(symSpacing, fixedSymSize);
719 button.addMouseListener(new Shape.MouseGestureAdapter() {
720 @Override
721 public void mouseClicked(final MouseEvent e) {
722 scene.screenshot(false, scene.nextScreenshotFile(null, UISceneDemo03.class.getSimpleName(), options.renderModes, window.getChosenGLCapabilities(), null));
723 manualScreenShorCount[0]++;
724 } } );
725 buttonsRight.addShape(button);
726 }
727 {
728 final Button button = new Button(options.renderModes, fontSymbols, fontSymbols.getUTF16String("power_settings_new"), buttonWidth, buttonHeight, buttonZOffset); // exit (power_settings_new)
729 button.setSpacing(symSpacing, fixedSymSize);
730 button.setColor(0.7f, 0.3f, 0.3f, 1.0f);
731 button.addMouseListener(new Shape.MouseGestureAdapter() {
732 @Override
733 public void mouseClicked(final MouseEvent e) {
734 MiscUtils.destroyWindow(window);
735 } } );
736 buttonsRight.addShape(button);
737 }
738 TreeTool.forAll(buttonsRight, (final Shape s) -> { s.setDragAndResizable(false); return false; });
739 buttonsRight.validate(window.getChosenGLCapabilities().getGLProfile());
740 buttonsRight.moveTo(sceneBox.getWidth()/2f - buttonsRight.getScaledWidth()*1.02f,
741 sceneBox.getHeight()/2f - buttonsRight.getScaledHeight()*1.02f, 0f);
742 scene.addShape(buttonsRight);
743 if( DEBUG ) {
744 System.err.println("Buttons-Right: Button-1 "+buttonsRight.getShapes().get(0));
745 System.err.println("Buttons-Right: SceneBox "+sceneBox);
746 System.err.println("Buttons-Right: scaled "+buttonsRight.getScaledWidth()+" x "+buttonsRight.getScaledHeight());
747 System.err.println("Buttons-Right: Box "+buttonsRight.getBounds());
748 System.err.println("Buttons-Right: "+buttonsRight);
749 }
750 }
751
752 /**
753 * Rotate the shape while avoiding 90 degree position
754 * @param shape the shape to rotate
755 * @param angle the angle in radians
756 * @param axis 0 for X-, 1 for Y- and 2 for Z-axis
757 */
758 public static void rotateShape(final Shape shape, float angle, final int axis) {
759 final Quaternion rot = shape.getRotation().copy();
760 final Vec3f euler = rot.toEuler(new Vec3f());
761 final Vec3f eulerOld = euler.copy();
762
763 final float eps = FloatUtil.adegToRad(5f);
764 final float sign = angle >= 0f ? 1f : -1f;
765 final float v;
766 switch( axis ) {
767 case 0: v = euler.x(); break;
768 case 1: v = euler.y(); break;
769 case 2: v = euler.z(); break;
770 default: return;
771 }
772 final float av = Math.abs(v);
773 if( 1f*FloatUtil.HALF_PI - eps <= av && av <= 1f*FloatUtil.HALF_PI + eps ||
774 3f*FloatUtil.HALF_PI - eps <= av && av <= 3f*FloatUtil.HALF_PI + eps) {
775 angle = 2f * eps * sign;
776 }
777 switch( axis ) {
778 case 0: euler.add(angle, 0, 0); break;
779 case 1: euler.add(0, angle, 0); break;
780 case 2: euler.add(0, 0, angle); break;
781 }
782 System.err.println("Rot: angleDelta "+angle+" (eps "+eps+"): "+eulerOld+" -> "+euler);
783 shape.setRotation( rot.setFromEuler(euler) );
784 }
785
786 static class MyGLMediaEventListener implements GLMediaEventListener {
787 @Override
788 public void attributesChanged(final GLMediaPlayer mp, final GLMediaPlayer.EventMask eventMask, final long when) {
789 System.err.println("MediaPlayer.1 AttributesChanges: "+eventMask+", when "+when);
790 System.err.println("MediaPlayer.1 State: "+mp);
791 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
792 new InterruptSource.Thread() {
793 @Override
794 public void run() {
795 try {
796 mp.initGL(null);
797 if ( GLMediaPlayer.State.Paused == mp.getState() ) { // init OK
798 mp.resume();
799 }
800 System.out.println("MediaPlayer.1 "+mp);
801 } catch (final Exception e) {
802 e.printStackTrace();
803 mp.destroy(null);
804 mPlayer = null;
805 return;
806 }
807 }
808 }.start();
809 }
810 boolean destroy = false;
811 Throwable err = null;
812
813 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
814 err = mp.getStreamException();
815 if( null != err ) {
816 System.err.println("MovieSimple State: Exception");
817 destroy = true;
818 } else {
819 new InterruptSource.Thread() {
820 @Override
821 public void run() {
822 mp.setPlaySpeed(1f);
823 mp.seek(0);
824 mp.resume();
825 }
826 }.start();
827 }
828 }
829 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) ) {
830 err = mp.getStreamException();
831 destroy = true;;
832 }
833 if( destroy ) {
834 if( null != err ) {
835 System.err.println("MovieSimple State: Exception");
836 err.printStackTrace();
837 }
838 mp.destroy(null);
839 mPlayer = null;
840 }
841 }
842 };
843}
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 RenderState is owned by RegionRenderer.
static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED
Bitfield hint, if set stating globally enabled GL#GL_DEPTH_TEST, otherwise disabled.
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final FontSet get(final int font)
Animation-Set covering its ShapeData elements, LerpFunc and animation parameter.
Definition: AnimGroup.java:98
Animation Shapes data covering one Shape of Set.
Definition: AnimGroup.java:75
Sine target LerpFunc, approaching ShapeData's target position utilizing the angular value for sine am...
Definition: AnimGroup.java:762
Default target LerpFunc, approaching ShapeData's target position inclusive angular rotation around gi...
Definition: AnimGroup.java:619
Group of animated Shapes including other static Shapes, optionally utilizing a Group....
Definition: AnimGroup.java:60
final boolean getTickPaused()
Definition: AnimGroup.java:539
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:450
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:261
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:369
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:324
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:493
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
RegionRenderer getRenderer()
Returns the associated RegionRenderer.
Definition: Scene.java:213
Shape removeShape(final Shape s)
Removes given shape, w/o Shape#destroy(GL2ES2, RegionRenderer).
Definition: Scene.java:297
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 waitUntilDisplayed()
Blocks until first display(GLAutoDrawable) has completed after construction or dispose(GLAutoDrawable...
Definition: Scene.java:589
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
static float getZEpsilon(final int zBits, final PMVMatrixSetup setup)
Default Z precision on 16-bit depth buffer using -1 z-position and DEFAULT_ZNEAR.
Definition: Scene.java:127
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
int getScreenshotCount()
Return the number of nextScreenshotFile(String, String, int, GLCapabilitiesImmutable,...
Definition: Scene.java:1454
String getStatusText(final GLAutoDrawable glad, final int renderModes, final float dpi)
Return a formatted status string containing avg fps and avg frame duration.
Definition: Scene.java:1388
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:
Definition: Scene.java:1441
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 toggle()
Definition: Shape.java:1596
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 float getScaledWidth()
Returns the scaled width of the bounding AABBox for this shape.
Definition: Shape.java:745
final Shape setToggle(final boolean v)
Set this shape's toggle state, default is off.
Definition: Shape.java:1587
final AABBox getBounds()
Returns the unscaled bounding AABBox for this shape, borrowing internal instance.
Definition: Shape.java:732
final Quaternion getRotation()
Returns Quaternion for rotation.
Definition: Shape.java:595
final boolean isToggleOn()
Returns true this shape's toggle state.
Definition: Shape.java:1610
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 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
boolean setText(final CharSequence text)
Set the text to be rendered.
Definition: Label.java:94
A GraphUI rectangle GraphShape.
Definition: Rectangle.java:47
Basic Float math utility functions.
Definition: FloatUtil.java:83
static final float QUARTER_PI
The value PI/4, i.e.
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.
Quaternion rotateByAngleZ(final float angle)
Rotate this quaternion around Z axis with the given angle in radians.
3D Vector based upon three float components.
Definition: Vec3f.java:37
static final Vec3f UNIT_Z
Definition: Vec3f.java:43
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 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[] ppmm)
Converts [1/mm] to [1/inch] in place.
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 addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
Definition: GLWindow.java:927
final void setTitle(final String title)
Definition: GLWindow.java:297
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
Definition: GLWindow.java:520
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
Definition: GLWindow.java:902
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
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
final VersionNumberString getGLVersionNumber()
Returns this context OpenGL version.
Definition: GLContext.java:781
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static JoglVersion getInstance()
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)
static void rotateShape(final Shape shape, float angle, final int axis)
Rotate the shape while avoiding 90 degree position.
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.
static void waitForKey(final String preMessage)
Definition: MiscUtils.java:167
static int atoi(final String str, final int def)
Definition: MiscUtils.java:60
static void destroyWindow(final GLAutoDrawable glad)
Definition: MiscUtils.java:269
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
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...
String toString()
Returns getFullFamilyName().
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean stop()
Stops this animator.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
boolean invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all regis...
GLAnimatorControl getAnimator()
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GL getGL()
Casts this object to the GL interface.
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...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
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_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
Definition: GL.java:43
static final int GL_VENDOR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VENDOR" with expressi...
Definition: GL.java:607
static final int GL_BLEND
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BLEND" with expressio...
Definition: GL.java:704
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738
As the contract of GLMediaFrameListener and TexSeqEventListener requests, implementations of GLMediaE...
void attributesChanged(GLMediaPlayer mp, EventMask event_mask, long when)
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.
void initGL(GL gl)
Initializes OpenGL related resources.
static final int TEXTURE_COUNT_DEFAULT
Default texture count, value {@value}.
boolean setPlaySpeed(float rate)
Sets the playback speed.
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.
int seek(int msec)
Seeks to the new absolute position.
State resume()
Starts or resumes the StreamWorker decoding thread.
static final int STREAM_ID_AUTO
Constant {@value} for auto or unspecified.