JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGearsES2NEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 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 */
28
29package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
30
31import java.io.IOException;
32import java.lang.reflect.InvocationTargetException;
33
34import com.jogamp.junit.util.JunitTracer;
35import com.jogamp.newt.Display;
36import com.jogamp.newt.MonitorDevice;
37import com.jogamp.newt.NewtFactory;
38import com.jogamp.newt.Screen;
39import com.jogamp.newt.Window;
40import com.jogamp.newt.event.WindowEvent;
41import com.jogamp.newt.event.KeyAdapter;
42import com.jogamp.newt.event.KeyEvent;
43import com.jogamp.newt.event.TraceMouseAdapter;
44import com.jogamp.newt.event.WindowAdapter;
45import com.jogamp.newt.opengl.GLWindow;
46import com.jogamp.newt.opengl.util.NEWTDemoListener;
47import com.jogamp.newt.util.EDTUtil;
48import com.jogamp.opengl.test.junit.util.MiscUtils;
49import com.jogamp.opengl.test.junit.util.NewtTestUtil;
50import com.jogamp.opengl.test.junit.util.UITestCase;
51import com.jogamp.opengl.util.Animator;
52import com.jogamp.opengl.util.AnimatorBase;
53import com.jogamp.opengl.test.junit.jogl.demos.GLClearOnInitReshape;
54import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
55import com.jogamp.opengl.test.junit.jogl.demos.es2.LineSquareXDemoES2;
56import com.jogamp.nativewindow.NativeWindowFactory;
57import com.jogamp.nativewindow.ScalableSurface;
58import com.jogamp.nativewindow.util.Dimension;
59import com.jogamp.nativewindow.util.Point;
60import com.jogamp.nativewindow.util.PointImmutable;
61import com.jogamp.nativewindow.util.DimensionImmutable;
62import com.jogamp.opengl.GL;
63import com.jogamp.opengl.GLAnimatorControl;
64import com.jogamp.opengl.GLAutoDrawable;
65import com.jogamp.opengl.GLCapabilities;
66import com.jogamp.opengl.GLCapabilitiesImmutable;
67import com.jogamp.opengl.GLEventListener;
68import com.jogamp.opengl.GLPipelineFactory;
69import com.jogamp.opengl.GLProfile;
70
71import jogamp.newt.DefaultEDTUtil;
72
73import org.junit.Assert;
74import org.junit.BeforeClass;
75import org.junit.AfterClass;
76import org.junit.Test;
77import org.junit.FixMethodOrder;
78import org.junit.runners.MethodSorters;
79
80/**
81 * <p>
82 * The demo code uses {@link NEWTDemoListener} functionality.
83 * </p>
84 * <p>
85 * Manual invocation via main allows setting each tests's duration in milliseconds, e.g.{@code -duration 10000} and many more, see {@link #main(String[])}
86 * </p>
87 */
88@FixMethodOrder(MethodSorters.NAME_ASCENDING)
89public class TestGearsES2NEWT extends UITestCase {
90 static int screenIdx = 0;
91 static PointImmutable wpos;
92 static DimensionImmutable wsize, rwsize=null;
93 static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
94
95 static long duration = 500; // ms
96 static boolean opaque = true;
97 static int forceAlpha = -1;
98 static boolean undecorated = false;
99 static boolean alwaysOnTop = false;
100 static boolean alwaysOnBottom = false;
101 static boolean resizable = true;
102 static boolean sticky = false;
103 static boolean max_vert= false;
104 static boolean max_horz= false;
105 static boolean fullscreen = false;
106 static int swapInterval = 1;
107 static boolean waitForKey = false;
108 static boolean mouseVisible = true;
109 static boolean mouseConfined = false;
110 static boolean setPointerIcon = false;
111 static boolean showFPS = false;
112 static int loops = 1;
113 static boolean loop_shutdown = false;
114 static boolean forceES2 = false;
115 static boolean forceES3 = false;
116 static boolean forceGL3 = false;
117 static boolean forceGL2 = false;
118 static boolean forceDebug = false;
119 static boolean forceTrace = false;
120 static int demoType = 1;
121 static boolean traceMouse = false;
122 static boolean manualTest = false;
123 static boolean exclusiveContext = false;
124 static boolean useAnimator = true;
125 static boolean useMappedBuffers = false;
126 static enum SysExit { none, testExit, testError, testEDTError, displayExit, displayError, displayEDTError };
127 static SysExit sysExit = SysExit.none;
128
129 @BeforeClass
130 public static void initClass() {
131 if(null == wsize) {
132 wsize = new Dimension(640, 480);
133 }
134 }
135
136 @AfterClass
137 public static void releaseClass() {
138 }
139
140 protected void runTestGL(final GLCapabilitiesImmutable caps, final boolean undecorated) throws InterruptedException {
141 System.err.println("requested: vsync "+swapInterval+", "+caps);
142 final Display dpy = NewtFactory.createDisplay(null);
143 final Screen screen = NewtFactory.createScreen(dpy, screenIdx);
144 final GLWindow glWindow = GLWindow.create(screen, caps);
145 Assert.assertNotNull(glWindow);
146 glWindow.setSize(wsize.getWidth(), wsize.getHeight());
147 if(null != wpos) {
148 glWindow.setPosition(wpos.getX(), wpos.getY());
149 }
150 glWindow.setSurfaceScale(reqSurfacePixelScale);
151 final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
152
153 glWindow.setUndecorated(undecorated);
154 glWindow.setAlwaysOnTop(alwaysOnTop);
155 glWindow.setAlwaysOnBottom(alwaysOnBottom);
156 glWindow.setResizable(resizable);
157 glWindow.setSticky(sticky);
158 glWindow.setMaximized(max_horz, max_vert);
159 glWindow.setFullscreen(fullscreen);
160 glWindow.setPointerVisible(mouseVisible);
161 glWindow.confinePointer(mouseConfined);
162
163 final GLEventListener demo;
164 if( 2 == demoType ) {
165 final LineSquareXDemoES2 demo2 = new LineSquareXDemoES2(false);
166 demo = demo2;
167 } else if( 1 == demoType ) {
168 final GearsES2 gearsES2 = new GearsES2(swapInterval);
169 gearsES2.setUseMappedBuffers(useMappedBuffers);
170 gearsES2.setValidateBuffers(true);
171 demo = gearsES2;
172 } else if( 0 == demoType ) {
173 demo = new GLClearOnInitReshape();
174 } else {
175 demo = null;
176 }
177 if( forceDebug || forceTrace ) {
178 glWindow.addGLEventListener(new GLEventListener() {
179 @Override
180 public void init(final GLAutoDrawable drawable) {
181 GL _gl = drawable.getGL();
182 if(forceDebug) {
183 try {
184 _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, _gl, null) );
185 } catch (final Exception e) {e.printStackTrace();}
186 }
187
188 if(forceTrace) {
189 try {
190 // Trace ..
191 _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, _gl, new Object[] { System.err } ) );
192 } catch (final Exception e) {e.printStackTrace();}
193 }
194 }
195 @Override
196 public void dispose(final GLAutoDrawable drawable) {}
197 @Override
198 public void display(final GLAutoDrawable drawable) {}
199 @Override
200 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
201 });
202 }
203
204 if( null != demo ) {
205 glWindow.addGLEventListener(demo);
206 }
207
209 glWindow.addGLEventListener(snap);
210 if(waitForKey) {
211 glWindow.addGLEventListener(new GLEventListener() {
212 @Override
213 public void init(final GLAutoDrawable drawable) { }
214 @Override
215 public void dispose(final GLAutoDrawable drawable) { }
216 @Override
217 public void display(final GLAutoDrawable drawable) {
218 final GLAnimatorControl actrl = drawable.getAnimator();
219 if(waitForKey && actrl.getTotalFPSFrames() == 60*3) {
220 JunitTracer.waitForKey("3s mark");
221 actrl.resetFPSCounter();
222 waitForKey = false;
223 }
224 }
225 @Override
226 public void reshape(final GLAutoDrawable drawable, final int x, final int y,
227 final int width, final int height) { }
228 });
229 }
230
231 final Animator animator = useAnimator ? new Animator(0 /* w/o AWT */) : null;
232 if( useAnimator ) {
233 animator.setExclusiveContext(exclusiveContext);
234 }
235
236 glWindow.addWindowListener(new WindowAdapter() {
237 @Override
238 public void windowResized(final WindowEvent e) {
239 System.err.println("window resized: "+glWindow.getBounds()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
240 NEWTDemoListener.setTitle(glWindow);
241 }
242 @Override
243 public void windowMoved(final WindowEvent e) {
244 System.err.println("window moved: "+glWindow.getBounds()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
245 NEWTDemoListener.setTitle(glWindow);
246 }
247 });
248
249 final GLWindow[] glWindow2 = { null };
250
251 final NEWTDemoListener newtDemoListener = new NEWTDemoListener(glWindow);
252 newtDemoListener.quitAdapterEnable(true);
253 glWindow.addKeyListener(newtDemoListener);
254 if( traceMouse ) {
255 glWindow.addMouseListener(new TraceMouseAdapter());
256 }
257 glWindow.addMouseListener(newtDemoListener);
258 glWindow.addWindowListener(newtDemoListener);
259 glWindow.addKeyListener(new KeyAdapter() {
260 @Override
261 public void keyPressed(final KeyEvent e) {
262 if( e.isAutoRepeat() ) {
263 return;
264 }
265 if(e.getKeyChar()=='n') {
266 if( null != glWindow2[0] && glWindow2[0].isNativeValid() ) {
267 glWindow2[0].destroy();
268 glWindow2[0] = null;
269 } else {
270 glWindow2[0] = GLWindow.create(screen, caps);
271 glWindow2[0].setTitle("GLWindow2");
272 glWindow2[0].setPosition(glWindow.getX()+glWindow.getWidth()+64, glWindow.getY());
273 glWindow2[0].setSize(glWindow.getWidth(), glWindow.getHeight());
274 glWindow2[0].addGLEventListener(new LineSquareXDemoES2(false));
275 final Animator animator2 = useAnimator ? new Animator(glWindow2[0]) : null;
276 if( null != animator2 ) {
277 animator2.start();
278 }
279 glWindow2[0].setVisible(true);
280 }
281 }
282 } } );
283
284 if( useAnimator ) {
285 animator.add(glWindow);
286 animator.start();
287 Assert.assertTrue(animator.isStarted());
288 Assert.assertTrue(animator.isAnimating());
289 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
290 }
291
292 if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit || SysExit.displayEDTError == sysExit ) {
293 glWindow.addGLEventListener(new GLEventListener() {
294 @Override
295 public void init(final GLAutoDrawable drawable) {}
296 @Override
297 public void dispose(final GLAutoDrawable drawable) { }
298 @Override
299 public void display(final GLAutoDrawable drawable) {
300 final GLAnimatorControl anim = drawable.getAnimator();
301 if( null != anim && anim.isAnimating() ) {
302 final long ms = anim.getTotalFPSDuration();
303 if( ms >= duration/2 || ms >= 3000 ) { // max 3s wait until provoking error
304 if( SysExit.displayError == sysExit ) {
305 throw new Error("test error send from GLEventListener.display - "+Thread.currentThread());
306 } else if ( SysExit.displayExit == sysExit ) {
307 System.err.println("exit(0) send from GLEventListener");
308 System.exit(0);
309 } else if ( SysExit.displayEDTError == sysExit ) {
310 final Object upstream = drawable.getUpstreamWidget();
311 System.err.println("EDT invokeAndWaitError: upstream type "+upstream.getClass().getName());
312 if( upstream instanceof Window ) {
313 final EDTUtil edt = ((Window)upstream).getScreen().getDisplay().getEDTUtil();
314 System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName());
315 if( edt instanceof DefaultEDTUtil ) {
316 newtDemoListener.doQuit();
317 ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() {
318 @Override
319 public void run() {
320 throw new RuntimeException("XXX Should never ever be seen! - "+Thread.currentThread());
321 }
322 });
323 }
324 }
325 }
326 }
327 } else {
328 System.exit(0);
329 }
330 }
331 @Override
332 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
333 });
334 }
335
336 glWindow.setVisible(true);
337 if( useAnimator ) {
338 animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
339 }
340
341 System.err.println("Window Current State : "+glWindow.getStateMaskString());
342 System.err.println("Window Supported States: "+glWindow.getSupportedStateMaskString());
343 System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
344 System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
345 System.err.println("window insets: "+glWindow.getInsets());
346 System.err.println("window bounds (window): "+glWindow.getBounds());
347 System.err.println("window bounds (pixels): "+glWindow.getSurfaceBounds());
348
349 final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
350 System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
351 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
352 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
353 NEWTDemoListener.setTitle(glWindow);
354 {
355 final MonitorDevice mm = glWindow.getMainMonitor();
356 System.err.println("Monitor: "+mm);
357 }
358
359 snap.setMakeSnapshot();
360
361 if( null != rwsize ) {
362 Thread.sleep(500); // 500ms delay
363 glWindow.setSize(rwsize.getWidth(), rwsize.getHeight());
364 System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
365 }
366
367 snap.setMakeSnapshot();
368
369 final long t0 = System.currentTimeMillis();
370 long t1 = t0;
371 while(!newtDemoListener.shouldQuit() && t1-t0<duration) {
372 Thread.sleep(100);
373 t1 = System.currentTimeMillis();
374 if( SysExit.testError == sysExit || SysExit.testExit == sysExit || SysExit.testEDTError == sysExit) {
375 final long ms = t1-t0;
376 if( ms >= duration/2 || ms >= 3000 ) { // max 3s wait until provoking error
377 if( SysExit.testError == sysExit ) {
378 throw new Error("test error send from test thread");
379 } else if ( SysExit.testExit == sysExit ) {
380 System.err.println("exit(0) send from test thread");
381 System.exit(0);
382 } else if ( SysExit.testEDTError == sysExit ) {
383 final EDTUtil edt = glWindow.getScreen().getDisplay().getEDTUtil();
384 System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName());
385 if( edt instanceof DefaultEDTUtil ) {
386 newtDemoListener.doQuit();
387 ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() {
388 @Override
389 public void run() {
390 throw new RuntimeException("XXX Should never ever be seen!");
391 }
392 });
393 }
394 }
395 }
396 }
397 }
398
399 if( useAnimator ) {
400 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
401 animator.stop();
402 Assert.assertFalse(animator.isAnimating());
403 Assert.assertFalse(animator.isStarted());
404 }
405 Assert.assertEquals(null, glWindow.getExclusiveContextThread());
406 glWindow.destroy();
407 if( null != glWindow2[0] && glWindow2[0].isNativeValid() ) {
408 glWindow2[0].destroy();
409 glWindow2[0] = null;
410 }
411 if( NativeWindowFactory.isAWTAvailable() ) {
412 Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow, false, null));
413 }
414 }
415
416 @Test
417 public void test01_GL2ES2() throws InterruptedException {
418 for(int i=1; i<=loops; i++) {
419 System.err.println("Loop "+i+"/"+loops);
420 final GLProfile glp;
421 if(forceGL3) {
422 glp = GLProfile.get(GLProfile.GL3);
423 } else if(forceES3) {
425 } else if(forceES2) {
427 } else if(forceGL2) {
428 glp = GLProfile.get(GLProfile.GL2);
429 } else {
430 glp = GLProfile.getGL2ES2();
431 }
432 final GLCapabilities caps = new GLCapabilities( glp );
433 caps.setBackgroundOpaque(opaque);
434 if(-1 < forceAlpha) {
435 caps.setAlphaBits(forceAlpha);
436 }
437 runTestGL(caps, undecorated);
438 if(loop_shutdown) {
440 }
441 }
442 }
443
444 @Test
445 public void test02_GLES2() throws InterruptedException {
446 if(manualTest) return;
447
449 System.err.println("GLES2 n/a");
450 return;
451 }
453 final GLCapabilities caps = new GLCapabilities( glp );
454 runTestGL(caps, undecorated);
455 }
456
457 @Test
458 public void test03_GL3() throws InterruptedException {
459 if(manualTest) return;
460
462 System.err.println("GL3 n/a");
463 return;
464 }
465 final GLProfile glp = GLProfile.get(GLProfile.GL3);
466 final GLCapabilities caps = new GLCapabilities( glp );
467 runTestGL(caps, undecorated);
468 }
469
470 @Test
471 public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException {
472 if( manualTest ) return;
473
474 reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
475 reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
476
478 runTestGL(caps, undecorated);
479 }
480
481 public static void main(final String args[]) throws IOException {
482 int x=0, y=0, w=640, h=480, rw=-1, rh=-1;
483 boolean usePos = false;
484
485 for(int i=0; i<args.length; i++) {
486 if(args[i].equals("-time")) {
487 i++;
488 duration = MiscUtils.atol(args[i], duration);
489 } else if(args[i].equals("-translucent")) {
490 opaque = false;
491 } else if(args[i].equals("-forceAlpha")) {
492 i++;
493 forceAlpha = MiscUtils.atoi(args[i], 0);
494 } else if(args[i].equals("-undecorated")) {
495 undecorated = true;
496 } else if(args[i].equals("-atop")) {
497 alwaysOnTop = true;
498 } else if(args[i].equals("-abottom")) {
499 alwaysOnBottom = true;
500 } else if(args[i].equals("-noresize")) {
501 resizable = false;
502 } else if(args[i].equals("-sticky")) {
503 sticky = true;
504 } else if(args[i].equals("-maxv")) {
505 max_vert = true;
506 } else if(args[i].equals("-maxh")) {
507 max_horz = true;
508 } else if(args[i].equals("-fullscreen")) {
509 fullscreen = true;
510 } else if(args[i].equals("-vsync")) {
511 i++;
512 swapInterval = MiscUtils.atoi(args[i], swapInterval);
513 } else if(args[i].equals("-exclctx")) {
514 exclusiveContext = true;
515 } else if(args[i].equals("-noanim")) {
516 useAnimator = false;
517 } else if(args[i].equals("-es2")) {
518 forceES2 = true;
519 } else if(args[i].equals("-es3")) {
520 forceES3 = true;
521 } else if(args[i].equals("-gl3")) {
522 forceGL3 = true;
523 } else if(args[i].equals("-gl2")) {
524 forceGL2 = true;
525 } else if(args[i].equals("-debug")) {
526 forceDebug = true;
527 } else if(args[i].equals("-trace")) {
528 forceTrace = true;
529 } else if(args[i].equals("-mappedBuffers")) {
530 useMappedBuffers = true;
531 } else if(args[i].equals("-wait")) {
532 waitForKey = true;
533 } else if(args[i].equals("-mouseInvisible")) {
534 mouseVisible = false;
535 } else if(args[i].equals("-mouseConfine")) {
536 mouseConfined = true;
537 } else if(args[i].equals("-pointerIcon")) {
538 setPointerIcon = true;
539 } else if(args[i].equals("-showFPS")) {
540 showFPS = true;
541 } else if(args[i].equals("-width")) {
542 i++;
543 w = MiscUtils.atoi(args[i], w);
544 } else if(args[i].equals("-height")) {
545 i++;
546 h = MiscUtils.atoi(args[i], h);
547 } else if(args[i].equals("-x")) {
548 i++;
549 x = MiscUtils.atoi(args[i], x);
550 usePos = true;
551 } else if(args[i].equals("-y")) {
552 i++;
553 y = MiscUtils.atoi(args[i], y);
554 usePos = true;
555 } else if(args[i].equals("-pixelScale")) {
556 i++;
557 final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]);
558 reqSurfacePixelScale[0] = pS;
559 reqSurfacePixelScale[1] = pS;
560 } else if(args[i].equals("-rwidth")) {
561 i++;
562 rw = MiscUtils.atoi(args[i], rw);
563 } else if(args[i].equals("-rheight")) {
564 i++;
565 rh = MiscUtils.atoi(args[i], rh);
566 } else if(args[i].equals("-screen")) {
567 i++;
568 screenIdx = MiscUtils.atoi(args[i], 0);
569 } else if(args[i].equals("-loops")) {
570 i++;
571 loops = MiscUtils.atoi(args[i], 1);
572 } else if(args[i].equals("-loop-shutdown")) {
573 loop_shutdown = true;
574 } else if(args[i].equals("-sysExit")) {
575 i++;
576 sysExit = SysExit.valueOf(args[i]);
577 } else if(args[i].equals("-manual")) {
578 manualTest = true;
579 } else if(args[i].equals("-demo")) {
580 i++;
581 demoType = MiscUtils.atoi(args[i], 0);
582 } else if(args[i].equals("-traceMouse")) {
583 traceMouse = true;
584 }
585 }
586 wsize = new Dimension(w, h);
587 if( 0 < rw && 0 < rh ) {
588 rwsize = new Dimension(rw, rh);
589 }
590
591 if(usePos) {
592 wpos = new Point(x, y);
593 }
594 System.err.println("position "+wpos);
595 System.err.println("size "+wsize);
596 System.err.println("resize "+rwsize);
597 System.err.println("screen "+screenIdx);
598 System.err.println("translucent "+(!opaque));
599 System.err.println("forceAlpha "+forceAlpha);
600 System.err.println("undecorated "+undecorated);
601 System.err.println("atop "+alwaysOnTop);
602 System.err.println("abottom "+alwaysOnBottom);
603 System.err.println("resizable "+resizable);
604 System.err.println("sticky "+sticky);
605 System.err.println("max_vert "+max_vert);
606 System.err.println("max_horz "+max_horz);
607 System.err.println("fullscreen "+fullscreen);
608 System.err.println("mouseVisible "+mouseVisible);
609 System.err.println("mouseConfined "+mouseConfined);
610 System.err.println("pointerIcon "+setPointerIcon);
611 System.err.println("loops "+loops);
612 System.err.println("loop shutdown "+loop_shutdown);
613 System.err.println("forceES2 "+forceES2);
614 System.err.println("forceES3 "+forceES3);
615 System.err.println("forceGL3 "+forceGL3);
616 System.err.println("forceGL2 "+forceGL2);
617 System.err.println("forceDebug "+forceDebug);
618 System.err.println("forceTrace "+forceTrace);
619 System.err.println("swapInterval "+swapInterval);
620 System.err.println("exclusiveContext "+exclusiveContext);
621 System.err.println("useAnimator "+useAnimator);
622 System.err.println("sysExitWithin "+sysExit);
623 System.err.println("mappedBuffers "+useMappedBuffers);
624 System.err.println("demoType "+demoType);
625 System.err.println("traceMouse "+traceMouse);
626
627 if(waitForKey) {
628 JunitTracer.waitForKey("Start");
629 }
630 org.junit.runner.JUnitCore.main(TestGearsES2NEWT.class.getName());
631 }
632}
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
abstract EDTUtil getEDTUtil()
Visual output device, i.e.
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
abstract Display getDisplay()
final boolean isAutoRepeat()
getModifiers() contains AUTOREPEAT_MASK.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
Definition: KeyEvent.java:161
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 String getStateMaskString()
Returns a string representation of the current state mask.
Definition: GLWindow.java:246
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:466
final void setPointerVisible(final boolean mouseVisible)
Makes the pointer visible or invisible.
Definition: GLWindow.java:312
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
Definition: GLWindow.java:927
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:525
final void setTitle(final String title)
Definition: GLWindow.java:297
final void setAlwaysOnTop(final boolean value)
Definition: GLWindow.java:351
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
Definition: GLWindow.java:500
final void setMaximized(final boolean horz, final boolean vert)
Definition: GLWindow.java:391
final int getX()
Returns the current x position of this window, relative to it's parent.
Definition: GLWindow.java:436
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 getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
Definition: GLWindow.java:441
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Definition: GLWindow.java:505
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 String getSupportedStateMaskString()
Returns a string representation of the supported state mask.
Definition: GLWindow.java:256
final Rectangle getSurfaceBounds()
Returns a newly created Rectangle containing window's surface origin and size in pixel units.
Definition: GLWindow.java:471
final MonitorDevice getMainMonitor()
Returns the MonitorDevice with the highest viewport coverage of this window.
Definition: GLWindow.java:292
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
Definition: GLWindow.java:534
final void setAlwaysOnBottom(final boolean value)
Definition: GLWindow.java:361
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final Rectangle getBounds()
Returns a newly created Rectangle containing window origin, getX() & getY(), and size,...
Definition: GLWindow.java:456
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
final int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:451
final void setSticky(final boolean value)
Definition: GLWindow.java:381
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
Definition: GLWindow.java:266
final void setResizable(final boolean value)
Definition: GLWindow.java:371
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
Definition: GLWindow.java:431
final void setUndecorated(final boolean value)
Definition: GLWindow.java:337
final boolean setSurfaceScale(final float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated NativeSurface, where size_in_pixel_uni...
Definition: GLWindow.java:495
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
final int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:446
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
Definition: GLWindow.java:277
final void confinePointer(final boolean grab)
Confine the pointer to this window, ie.
Definition: GLWindow.java:332
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.
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
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 boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
Definition: GLProfile.java:305
static final String GLES3
The embedded OpenGL profile ES 3.x, with x >= 0.
Definition: GLProfile.java:588
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
static void shutdown()
Manual shutdown method, may be called after your last JOGL use within the running JVM.
Definition: GLProfile.java:277
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
void runTestGL(final GLCapabilitiesImmutable caps, final boolean undecorated)
static float atof(final String str, final float def)
Definition: MiscUtils.java:75
static int atoi(final String str, final int def)
Definition: MiscUtils.java:57
static long atol(final String str, final long def)
Definition: MiscUtils.java:66
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
final synchronized Thread getThread()
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)
synchronized boolean isStarted()
Indicates whether this animator has been started.
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
Adding mutable surface pixel scale property to implementing class, usually to a NativeSurface impleme...
static final float IDENTITY_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in same pixel- and window-units.
static final float AUTOMAX_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale,...
Immutable Dimension Interface, consisting of it's read only components:
Specifying NEWT's Window functionality:
Definition: Window.java:115
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
EDT stands for Event Dispatch Thread.
Definition: EDTUtil.java:53
void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean isAnimating()
Indicates whether this animator is started and is not paused.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GLAnimatorControl getAnimator()
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.
GLContext getContext()
Returns the GLContext associated which this GL object.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.