Jogamp
Bug 741 HiDPI: Simplify ScalableSurface (2): Add request pixelScale API entry, fixed...
[jogl.git] / src / test / com / jogamp / opengl / test / junit / jogl / demos / es2 / newt / TestGearsES2NewtCanvasAWT.java
CommitLineData
cedbdb09
SG
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:
2571ed0b 6 *
cedbdb09
SG
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
2571ed0b 9 *
cedbdb09
SG
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.
2571ed0b 13 *
cedbdb09
SG
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.
2571ed0b 23 *
cedbdb09
SG
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 */
2571ed0b 28
cedbdb09
SG
29package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
30
31import java.awt.BorderLayout;
c6224657
SG
32import java.awt.Button;
33import java.awt.Component;
34import java.awt.Container;
cedbdb09 35import java.awt.Frame;
c6224657 36import java.awt.TextArea;
2571ed0b
SG
37import java.awt.event.ComponentEvent;
38import java.awt.event.ComponentListener;
cedbdb09
SG
39import java.io.IOException;
40import java.lang.reflect.InvocationTargetException;
41
c6224657 42import com.jogamp.common.os.Platform;
cedbdb09
SG
43import com.jogamp.newt.Display;
44import com.jogamp.newt.NewtFactory;
45import com.jogamp.newt.Screen;
2571ed0b 46import com.jogamp.newt.Window;
cedbdb09 47import com.jogamp.newt.awt.NewtCanvasAWT;
2571ed0b 48import com.jogamp.newt.event.KeyEvent;
cedbdb09
SG
49import com.jogamp.newt.event.WindowEvent;
50import com.jogamp.newt.event.WindowAdapter;
51import com.jogamp.newt.opengl.GLWindow;
52import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
53import com.jogamp.opengl.test.junit.util.MiscUtils;
54import com.jogamp.opengl.test.junit.util.UITestCase;
55import com.jogamp.opengl.test.junit.util.QuitAdapter;
cedbdb09 56import com.jogamp.opengl.util.Animator;
cedbdb09 57import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
8be1fc98 58import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter;
cedbdb09 59
2571ed0b 60import javax.media.nativewindow.ScalableSurface;
cedbdb09
SG
61import javax.media.nativewindow.util.Dimension;
62import javax.media.nativewindow.util.Point;
63import javax.media.nativewindow.util.PointImmutable;
64import javax.media.nativewindow.util.DimensionImmutable;
cedbdb09
SG
65import javax.media.opengl.GLCapabilities;
66import javax.media.opengl.GLCapabilitiesImmutable;
67import javax.media.opengl.GLProfile;
68import javax.swing.SwingUtilities;
69
70import org.junit.Assert;
c6224657 71import org.junit.Assume;
cedbdb09
SG
72import org.junit.BeforeClass;
73import org.junit.AfterClass;
74import org.junit.Test;
43cc2ea7
SG
75import org.junit.FixMethodOrder;
76import org.junit.runners.MethodSorters;
cedbdb09 77
43cc2ea7 78@FixMethodOrder(MethodSorters.NAME_ASCENDING)
2571ed0b 79public class TestGearsES2NewtCanvasAWT extends UITestCase {
af384deb 80 public enum FrameLayout { None, TextOnBottom, BorderBottom, BorderBottom2, BorderCenter, BorderCenterSurrounded, DoubleBorderCenterSurrounded };
c6224657 81 public enum ResizeBy { GLWindow, Component, Frame };
2571ed0b 82
cedbdb09
SG
83 static int screenIdx = 0;
84 static PointImmutable wpos;
14b27853 85 static DimensionImmutable wsize, rwsize = null;
57bf60b7
SG
86 static FrameLayout frameLayout = FrameLayout.None;
87 static ResizeBy resizeBy = ResizeBy.Component;
2571ed0b
SG
88 static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
89
cedbdb09
SG
90 static long duration = 500; // ms
91 static boolean opaque = true;
92 static int forceAlpha = -1;
93 static boolean fullscreen = false;
94 static boolean pmvUseBackingArray = true;
95 static int swapInterval = 1;
96 static boolean showFPS = false;
97 static int loops = 1;
98 static boolean loop_shutdown = false;
c6224657 99 static boolean shallUseOffscreenFBOLayer = false;
cedbdb09
SG
100 static boolean forceES2 = false;
101 static boolean forceGL3 = false;
3fb76fce 102 static boolean manualTest = false;
cedbdb09 103 static boolean exclusiveContext = false;
30b2490e 104 static boolean useAnimator = true;
2571ed0b 105
cedbdb09
SG
106 @BeforeClass
107 public static void initClass() {
108 if(null == wsize) {
109 wsize = new Dimension(640, 480);
110 }
111 }
112
113 @AfterClass
114 public static void releaseClass() {
115 }
116
c6224657
SG
117 static void setGLWindowSize(final Frame frame, final GLWindow glw, final DimensionImmutable new_sz) {
118 try {
119 glw.setSize(new_sz.getWidth(), new_sz.getHeight());
120 if( null != frame ) {
121 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
122 public void run() {
123 frame.pack();
124 } } );
125 }
126 } catch( Throwable throwable ) {
127 throwable.printStackTrace();
128 Assume.assumeNoException( throwable );
2571ed0b 129 }
c6224657
SG
130 }
131 static void setComponentSize(final Frame frame, final Component comp, final DimensionImmutable new_sz) {
132 try {
133 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
134 public void run() {
135 java.awt.Dimension d = new java.awt.Dimension(new_sz.getWidth(), new_sz.getHeight());
136 comp.setMinimumSize(d);
137 comp.setPreferredSize(d);
138 comp.setSize(d);
139 if( null != frame ) {
140 frame.pack();
141 }
142 } } );
143 } catch( Throwable throwable ) {
144 throwable.printStackTrace();
145 Assume.assumeNoException( throwable );
2571ed0b 146 }
c6224657
SG
147 }
148 static void setFrameSize(final Frame frame, final boolean frameLayout, final DimensionImmutable new_sz) {
149 try {
150 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
151 public void run() {
152 java.awt.Dimension d = new java.awt.Dimension(new_sz.getWidth(), new_sz.getHeight());
153 frame.setSize(d);
154 if( frameLayout ) {
155 frame.validate();
156 }
157 } } );
158 } catch( Throwable throwable ) {
159 throwable.printStackTrace();
160 Assume.assumeNoException( throwable );
2571ed0b 161 }
c6224657 162 }
2571ed0b 163
c6224657
SG
164 static void setSize(final ResizeBy resizeBy, final Frame frame, final boolean frameLayout, final Component comp, final GLWindow glw, final DimensionImmutable new_sz) {
165 switch( resizeBy ) {
166 case GLWindow:
167 setGLWindowSize(frameLayout ? frame : null, glw, new_sz);
168 break;
169 case Component:
170 setComponentSize(frameLayout ? frame : null, comp, new_sz);
171 break;
172 case Frame:
173 setFrameSize(frame, frameLayout, new_sz);
174 break;
2571ed0b
SG
175 }
176 }
177
178 private void setTitle(final Frame frame, final NewtCanvasAWT glc, final Window win, final GLCapabilitiesImmutable caps) {
179 final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
180 {
181 final java.awt.Rectangle b = glc.getBounds();
182 frame.setTitle("NewtCanvasAWT["+capsA+"], swapI "+swapInterval+", win: ["+b.x+"/"+b.y+" "+b.width+"x"+b.height+"], pix: "+glc.getNativeWindow().getSurfaceWidth()+"x"+glc.getNativeWindow().getSurfaceHeight());
183 }
184 win.setTitle("GLWindow["+capsA+"], swapI "+swapInterval+", win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight());
c6224657 185 }
2571ed0b 186
c6224657
SG
187 // public enum ResizeBy { GLWindow, Component, Frame };
188 protected void runTestGL(final GLCapabilitiesImmutable caps, final ResizeBy resizeBy, final FrameLayout frameLayout) throws InterruptedException, InvocationTargetException {
cedbdb09
SG
189 System.err.println("requested: vsync "+swapInterval+", "+caps);
190 Display dpy = NewtFactory.createDisplay(null);
191 Screen screen = NewtFactory.createScreen(dpy, screenIdx);
192 final GLWindow glWindow = GLWindow.create(screen, caps);
193 Assert.assertNotNull(glWindow);
58153310
SG
194 glWindow.setSurfaceScale(reqSurfacePixelScale);
195 final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
2571ed0b 196
cedbdb09 197 final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
c6224657
SG
198 if ( shallUseOffscreenFBOLayer ) {
199 newtCanvasAWT.setShallUseOffscreenLayer(true);
200 }
2571ed0b 201
c6224657 202 final Frame frame = new Frame("AWT Parent Frame");
2571ed0b 203
c6224657
SG
204 setSize(resizeBy, frame, false, newtCanvasAWT, glWindow, wsize);
205
206 switch( frameLayout) {
207 case None:
208 frame.add(newtCanvasAWT);
209 break;
210 case TextOnBottom:
211 final TextArea ta = new TextArea(2, 20);
212 ta.append("0123456789");
213 ta.append(Platform.getNewline());
214 ta.append("Some Text");
215 ta.append(Platform.getNewline());
216 frame.setLayout(new BorderLayout());
217 frame.add(ta, BorderLayout.SOUTH);
218 frame.add(newtCanvasAWT, BorderLayout.CENTER);
2571ed0b 219 break;
c6224657
SG
220 case BorderBottom:
221 frame.setLayout(new BorderLayout());
222 frame.add(newtCanvasAWT, BorderLayout.SOUTH);
223 break;
af384deb
SG
224 case BorderBottom2:
225 frame.setLayout(new BorderLayout());
226 frame.add(newtCanvasAWT, BorderLayout.SOUTH);
227 frame.add(new Button("North"), BorderLayout.NORTH);
228 break;
c6224657
SG
229 case BorderCenter:
230 frame.setLayout(new BorderLayout());
231 frame.add(newtCanvasAWT, BorderLayout.CENTER);
232 break;
233 case BorderCenterSurrounded:
234 frame.setLayout(new BorderLayout());
235 frame.add(new Button("NORTH"), BorderLayout.NORTH);
236 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
237 frame.add(new Button("EAST"), BorderLayout.EAST);
238 frame.add(new Button("WEST"), BorderLayout.WEST);
239 frame.add(newtCanvasAWT, BorderLayout.CENTER);
240 break;
241 case DoubleBorderCenterSurrounded:
242 Container c = new Container();
243 c.setLayout(new BorderLayout());
244 c.add(new Button("north"), BorderLayout.NORTH);
245 c.add(new Button("south"), BorderLayout.SOUTH);
246 c.add(new Button("east"), BorderLayout.EAST);
247 c.add(new Button("west"), BorderLayout.WEST);
248 c.add(newtCanvasAWT, BorderLayout.CENTER);
2571ed0b 249
c6224657
SG
250 frame.setLayout(new BorderLayout());
251 frame.add(new Button("NORTH"), BorderLayout.NORTH);
252 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
253 frame.add(new Button("EAST"), BorderLayout.EAST);
254 frame.add(new Button("WEST"), BorderLayout.WEST);
255 frame.add(c, BorderLayout.CENTER);
256 break;
257 }
2571ed0b 258
cedbdb09
SG
259 final GearsES2 demo = new GearsES2(swapInterval);
260 demo.setPMVUseBackingArray(pmvUseBackingArray);
261 glWindow.addGLEventListener(demo);
2571ed0b
SG
262
263 frame.addComponentListener(new ComponentListener() {
264 @Override
265 public void componentResized(ComponentEvent e) {
266 setTitle(frame, newtCanvasAWT, glWindow, caps);
267 }
268
269 @Override
270 public void componentMoved(ComponentEvent e) {
271 setTitle(frame, newtCanvasAWT, glWindow, caps);
272 }
273
274 @Override
275 public void componentShown(ComponentEvent e) { }
276
277 @Override
278 public void componentHidden(ComponentEvent e) { }
279 });
280
30b2490e
SG
281 final Animator animator = useAnimator ? new Animator() : null;
282 if( useAnimator ) {
283 animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
284 animator.setExclusiveContext(exclusiveContext);
285 }
2571ed0b 286
c225285e 287 final QuitAdapter quitAdapter = new QuitAdapter();
cedbdb09
SG
288 //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
289 //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
290 glWindow.addKeyListener(quitAdapter);
291 glWindow.addWindowListener(quitAdapter);
292
293 glWindow.addWindowListener(new WindowAdapter() {
294 public void windowResized(WindowEvent e) {
f9a00b91 295 System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
cedbdb09
SG
296 }
297 public void windowMoved(WindowEvent e) {
f9a00b91 298 System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
2571ed0b 299 }
cedbdb09 300 });
2571ed0b 301
8be1fc98 302 glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter));
2571ed0b
SG
303 glWindow.addKeyListener(new com.jogamp.newt.event.KeyAdapter() {
304 @Override
305 public void keyPressed(final KeyEvent e) {
306 if( e.isAutoRepeat() ) {
307 return;
308 }
309 if(e.getKeyChar()=='x') {
58153310 310 final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]);
2571ed0b
SG
311 final int[] reqSurfacePixelScale;
312 if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
313 reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
314 } else {
315 reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
316 }
317 System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
58153310
SG
318 glWindow.setSurfaceScale(reqSurfacePixelScale);
319 final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
2571ed0b 320 final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
58153310 321 final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
2571ed0b
SG
322 System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
323 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
3fb76fce 324 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
2571ed0b
SG
325 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
326 setTitle(frame, newtCanvasAWT, glWindow, caps);
327 Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
328 }
329 } } );
330
30b2490e
SG
331 if( useAnimator ) {
332 animator.add(glWindow);
333 animator.start();
334 Assert.assertTrue(animator.isStarted());
335 Assert.assertTrue(animator.isAnimating());
336 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
337 }
cedbdb09
SG
338
339 SwingUtilities.invokeAndWait(new Runnable() {
340 public void run() {
c6224657
SG
341 if( ResizeBy.Frame == resizeBy ) {
342 frame.validate();
343 } else {
2571ed0b
SG
344 frame.pack();
345 }
346 frame.setVisible(true);
cedbdb09 347 }
2571ed0b 348 });
af384deb 349 Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
2571ed0b
SG
350 Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true));
351
30b2490e
SG
352 if( useAnimator ) {
353 animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
354 }
2571ed0b 355
cedbdb09
SG
356 System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
357 System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
f9a00b91 358 System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
2571ed0b
SG
359
360 final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
58153310 361 final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
2571ed0b 362 System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
3fb76fce 363 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
2571ed0b
SG
364 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
365 setTitle(frame, newtCanvasAWT, glWindow, caps);
366 Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
367
c6224657 368 if( null != rwsize ) {
2571ed0b 369 Thread.sleep(500); // 500ms delay
c6224657 370 setSize(resizeBy, frame, true, newtCanvasAWT, glWindow, rwsize);
f9a00b91 371 System.err.println("window resize "+rwsize+" -> pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
c6224657 372 }
2571ed0b 373
30b2490e
SG
374 final long t0 = System.currentTimeMillis();
375 long t1 = t0;
376 while(!quitAdapter.shouldQuit() && t1-t0<duration) {
cedbdb09 377 Thread.sleep(100);
30b2490e 378 t1 = System.currentTimeMillis();
cedbdb09
SG
379 }
380
30b2490e
SG
381 if( useAnimator ) {
382 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
383 animator.stop();
384 Assert.assertFalse(animator.isAnimating());
385 Assert.assertFalse(animator.isStarted());
386 }
cedbdb09
SG
387 Assert.assertEquals(null, glWindow.getExclusiveContextThread());
388 SwingUtilities.invokeAndWait(new Runnable() {
2571ed0b
SG
389 public void run() {
390 frame.dispose();
cedbdb09
SG
391 }
392 });
393 glWindow.destroy();
394 Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
395 }
396
397 @Test
398 public void test01GL2ES2() throws InterruptedException, InvocationTargetException {
399 for(int i=1; i<=loops; i++) {
400 System.err.println("Loop "+i+"/"+loops);
401 final GLProfile glp;
402 if(forceGL3) {
403 glp = GLProfile.get(GLProfile.GL3);
404 } else if(forceES2) {
405 glp = GLProfile.get(GLProfile.GLES2);
406 } else {
407 glp = GLProfile.getGL2ES2();
408 }
409 final GLCapabilities caps = new GLCapabilities( glp );
410 caps.setBackgroundOpaque(opaque);
411 if(-1 < forceAlpha) {
2571ed0b 412 caps.setAlphaBits(forceAlpha);
cedbdb09 413 }
c6224657 414 runTestGL(caps, resizeBy, frameLayout);
cedbdb09
SG
415 if(loop_shutdown) {
416 GLProfile.shutdown();
417 }
418 }
419 }
420
421 @Test
422 public void test02GL3() throws InterruptedException, InvocationTargetException {
3fb76fce 423 if(manualTest) return;
2571ed0b 424
cedbdb09
SG
425 if( !GLProfile.isAvailable(GLProfile.GL3) ) {
426 System.err.println("GL3 n/a");
6e08b6f0 427 return;
cedbdb09
SG
428 }
429 final GLProfile glp = GLProfile.get(GLProfile.GL3);
430 final GLCapabilities caps = new GLCapabilities( glp );
c6224657 431 runTestGL(caps, resizeBy, frameLayout);
cedbdb09 432 }
2571ed0b
SG
433
434 @Test
435 public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException {
3fb76fce 436 if( manualTest ) return;
2571ed0b
SG
437
438 reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
439 reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
440
441 GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
442 runTestGL(caps, resizeBy, frameLayout);
443 }
444
cedbdb09 445 public static void main(String args[]) throws IOException {
cedbdb09 446 int x=0, y=0, w=640, h=480;
c6224657 447 int rw=-1, rh=-1;
cedbdb09 448 boolean usePos = false;
2571ed0b 449
cedbdb09
SG
450 for(int i=0; i<args.length; i++) {
451 if(args[i].equals("-time")) {
452 i++;
453 duration = MiscUtils.atol(args[i], duration);
c6224657
SG
454 } else if(args[i].equals("-rwidth")) {
455 i++;
456 rw = MiscUtils.atoi(args[i], rw);
457 } else if(args[i].equals("-rheight")) {
458 i++;
459 rh = MiscUtils.atoi(args[i], rh);
460 } else if(args[i].equals("-layout")) {
461 i++;
462 frameLayout = FrameLayout.valueOf(args[i]);
463 } else if(args[i].equals("-resizeBy")) {
464 i++;
465 resizeBy = ResizeBy.valueOf(args[i]);
cedbdb09
SG
466 } else if(args[i].equals("-translucent")) {
467 opaque = false;
468 } else if(args[i].equals("-forceAlpha")) {
469 i++;
470 forceAlpha = MiscUtils.atoi(args[i], 0);
471 } else if(args[i].equals("-fullscreen")) {
472 fullscreen = true;
473 } else if(args[i].equals("-pmvDirect")) {
474 pmvUseBackingArray = false;
475 } else if(args[i].equals("-vsync")) {
476 i++;
477 swapInterval = MiscUtils.atoi(args[i], swapInterval);
c6224657
SG
478 } else if(args[i].equals("-layeredFBO")) {
479 shallUseOffscreenFBOLayer = true;
cedbdb09
SG
480 } else if(args[i].equals("-exclctx")) {
481 exclusiveContext = true;
30b2490e
SG
482 } else if(args[i].equals("-noanim")) {
483 useAnimator = false;
cedbdb09
SG
484 } else if(args[i].equals("-es2")) {
485 forceES2 = true;
486 } else if(args[i].equals("-gl3")) {
487 forceGL3 = true;
488 } else if(args[i].equals("-showFPS")) {
489 showFPS = true;
490 } else if(args[i].equals("-width")) {
491 i++;
492 w = MiscUtils.atoi(args[i], w);
493 } else if(args[i].equals("-height")) {
494 i++;
495 h = MiscUtils.atoi(args[i], h);
496 } else if(args[i].equals("-x")) {
497 i++;
498 x = MiscUtils.atoi(args[i], x);
499 usePos = true;
500 } else if(args[i].equals("-y")) {
501 i++;
502 y = MiscUtils.atoi(args[i], y);
503 usePos = true;
2571ed0b
SG
504 } else if(args[i].equals("-pixelScale")) {
505 i++;
506 final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]);
507 reqSurfacePixelScale[0] = pS;
508 reqSurfacePixelScale[1] = pS;
cedbdb09
SG
509 } else if(args[i].equals("-screen")) {
510 i++;
511 screenIdx = MiscUtils.atoi(args[i], 0);
512 } else if(args[i].equals("-loops")) {
513 i++;
514 loops = MiscUtils.atoi(args[i], 1);
515 } else if(args[i].equals("-loop-shutdown")) {
516 loop_shutdown = true;
3fb76fce
SG
517 } else if(args[i].equals("-manual")) {
518 manualTest = true;
cedbdb09
SG
519 }
520 }
521 wsize = new Dimension(w, h);
c6224657
SG
522 if( 0 < rw && 0 < rh ) {
523 rwsize = new Dimension(rw, rh);
524 }
2571ed0b 525
cedbdb09
SG
526 if(usePos) {
527 wpos = new Point(x, y);
528 }
2571ed0b 529
c6224657
SG
530 System.err.println("frameLayout "+frameLayout);
531 System.err.println("resizeBy "+resizeBy);
cedbdb09
SG
532 System.err.println("position "+wpos);
533 System.err.println("size "+wsize);
c6224657 534 System.err.println("resize "+rwsize);
cedbdb09
SG
535 System.err.println("screen "+screenIdx);
536 System.err.println("translucent "+(!opaque));
2571ed0b 537 System.err.println("forceAlpha "+forceAlpha);
cedbdb09 538 System.err.println("fullscreen "+fullscreen);
2571ed0b 539 System.err.println("pmvDirect "+(!pmvUseBackingArray));
cedbdb09
SG
540 System.err.println("loops "+loops);
541 System.err.println("loop shutdown "+loop_shutdown);
c6224657 542 System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
cedbdb09
SG
543 System.err.println("forceES2 "+forceES2);
544 System.err.println("forceGL3 "+forceGL3);
545 System.err.println("swapInterval "+swapInterval);
546 System.err.println("exclusiveContext "+exclusiveContext);
30b2490e 547 System.err.println("useAnimator "+useAnimator);
cedbdb09
SG
548
549 org.junit.runner.JUnitCore.main(TestGearsES2NewtCanvasAWT.class.getName());
550 }
551}
http://JogAmp.org git info: FAQ, tutorial and man pages.