Jogamp
Bug 741 HiDPI: Add ScalableSurface interface to get/set pixelScale w/ full OSX impl.
[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;
102 static boolean mainRun = false;
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);
2571ed0b
SG
194 glWindow.setSurfaceScale(reqSurfacePixelScale);
195
cedbdb09 196 final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
c6224657
SG
197 if ( shallUseOffscreenFBOLayer ) {
198 newtCanvasAWT.setShallUseOffscreenLayer(true);
199 }
2571ed0b 200
c6224657 201 final Frame frame = new Frame("AWT Parent Frame");
2571ed0b 202
c6224657
SG
203 setSize(resizeBy, frame, false, newtCanvasAWT, glWindow, wsize);
204
205 switch( frameLayout) {
206 case None:
207 frame.add(newtCanvasAWT);
208 break;
209 case TextOnBottom:
210 final TextArea ta = new TextArea(2, 20);
211 ta.append("0123456789");
212 ta.append(Platform.getNewline());
213 ta.append("Some Text");
214 ta.append(Platform.getNewline());
215 frame.setLayout(new BorderLayout());
216 frame.add(ta, BorderLayout.SOUTH);
217 frame.add(newtCanvasAWT, BorderLayout.CENTER);
2571ed0b 218 break;
c6224657
SG
219 case BorderBottom:
220 frame.setLayout(new BorderLayout());
221 frame.add(newtCanvasAWT, BorderLayout.SOUTH);
222 break;
af384deb
SG
223 case BorderBottom2:
224 frame.setLayout(new BorderLayout());
225 frame.add(newtCanvasAWT, BorderLayout.SOUTH);
226 frame.add(new Button("North"), BorderLayout.NORTH);
227 break;
c6224657
SG
228 case BorderCenter:
229 frame.setLayout(new BorderLayout());
230 frame.add(newtCanvasAWT, BorderLayout.CENTER);
231 break;
232 case BorderCenterSurrounded:
233 frame.setLayout(new BorderLayout());
234 frame.add(new Button("NORTH"), BorderLayout.NORTH);
235 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
236 frame.add(new Button("EAST"), BorderLayout.EAST);
237 frame.add(new Button("WEST"), BorderLayout.WEST);
238 frame.add(newtCanvasAWT, BorderLayout.CENTER);
239 break;
240 case DoubleBorderCenterSurrounded:
241 Container c = new Container();
242 c.setLayout(new BorderLayout());
243 c.add(new Button("north"), BorderLayout.NORTH);
244 c.add(new Button("south"), BorderLayout.SOUTH);
245 c.add(new Button("east"), BorderLayout.EAST);
246 c.add(new Button("west"), BorderLayout.WEST);
247 c.add(newtCanvasAWT, BorderLayout.CENTER);
2571ed0b 248
c6224657
SG
249 frame.setLayout(new BorderLayout());
250 frame.add(new Button("NORTH"), BorderLayout.NORTH);
251 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
252 frame.add(new Button("EAST"), BorderLayout.EAST);
253 frame.add(new Button("WEST"), BorderLayout.WEST);
254 frame.add(c, BorderLayout.CENTER);
255 break;
256 }
2571ed0b 257
cedbdb09
SG
258 final GearsES2 demo = new GearsES2(swapInterval);
259 demo.setPMVUseBackingArray(pmvUseBackingArray);
260 glWindow.addGLEventListener(demo);
2571ed0b
SG
261
262 frame.addComponentListener(new ComponentListener() {
263 @Override
264 public void componentResized(ComponentEvent e) {
265 setTitle(frame, newtCanvasAWT, glWindow, caps);
266 }
267
268 @Override
269 public void componentMoved(ComponentEvent e) {
270 setTitle(frame, newtCanvasAWT, glWindow, caps);
271 }
272
273 @Override
274 public void componentShown(ComponentEvent e) { }
275
276 @Override
277 public void componentHidden(ComponentEvent e) { }
278 });
279
30b2490e
SG
280 final Animator animator = useAnimator ? new Animator() : null;
281 if( useAnimator ) {
282 animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
283 animator.setExclusiveContext(exclusiveContext);
284 }
2571ed0b 285
c225285e 286 final QuitAdapter quitAdapter = new QuitAdapter();
cedbdb09
SG
287 //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
288 //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
289 glWindow.addKeyListener(quitAdapter);
290 glWindow.addWindowListener(quitAdapter);
291
292 glWindow.addWindowListener(new WindowAdapter() {
293 public void windowResized(WindowEvent e) {
f9a00b91 294 System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
cedbdb09
SG
295 }
296 public void windowMoved(WindowEvent e) {
f9a00b91 297 System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
2571ed0b 298 }
cedbdb09 299 });
2571ed0b 300
8be1fc98 301 glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter));
2571ed0b
SG
302 glWindow.addKeyListener(new com.jogamp.newt.event.KeyAdapter() {
303 @Override
304 public void keyPressed(final KeyEvent e) {
305 if( e.isAutoRepeat() ) {
306 return;
307 }
308 if(e.getKeyChar()=='x') {
309 final int[] hadSurfacePixelScale = glWindow.getSurfaceScale(new int[2]);
310 final int[] reqSurfacePixelScale;
311 if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
312 reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
313 } else {
314 reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
315 }
316 System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
317 glWindow.setSurfaceScale(reqSurfacePixelScale);
318 final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
319 final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
320 System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
321 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
322 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
323 setTitle(frame, newtCanvasAWT, glWindow, caps);
324 Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
325 }
326 } } );
327
30b2490e
SG
328 if( useAnimator ) {
329 animator.add(glWindow);
330 animator.start();
331 Assert.assertTrue(animator.isStarted());
332 Assert.assertTrue(animator.isAnimating());
333 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
334 }
cedbdb09
SG
335
336 SwingUtilities.invokeAndWait(new Runnable() {
337 public void run() {
c6224657
SG
338 if( ResizeBy.Frame == resizeBy ) {
339 frame.validate();
340 } else {
2571ed0b
SG
341 frame.pack();
342 }
343 frame.setVisible(true);
cedbdb09 344 }
2571ed0b 345 });
af384deb 346 Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
2571ed0b
SG
347 Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true));
348
30b2490e
SG
349 if( useAnimator ) {
350 animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
351 }
2571ed0b 352
cedbdb09
SG
353 System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
354 System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
f9a00b91 355 System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
2571ed0b
SG
356
357 final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
358 final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
359 System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
360 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
361 setTitle(frame, newtCanvasAWT, glWindow, caps);
362 Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
363
c6224657 364 if( null != rwsize ) {
2571ed0b 365 Thread.sleep(500); // 500ms delay
c6224657 366 setSize(resizeBy, frame, true, newtCanvasAWT, glWindow, rwsize);
f9a00b91 367 System.err.println("window resize "+rwsize+" -> pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
c6224657 368 }
2571ed0b 369
30b2490e
SG
370 final long t0 = System.currentTimeMillis();
371 long t1 = t0;
372 while(!quitAdapter.shouldQuit() && t1-t0<duration) {
cedbdb09 373 Thread.sleep(100);
30b2490e 374 t1 = System.currentTimeMillis();
cedbdb09
SG
375 }
376
30b2490e
SG
377 if( useAnimator ) {
378 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
379 animator.stop();
380 Assert.assertFalse(animator.isAnimating());
381 Assert.assertFalse(animator.isStarted());
382 }
cedbdb09
SG
383 Assert.assertEquals(null, glWindow.getExclusiveContextThread());
384 SwingUtilities.invokeAndWait(new Runnable() {
2571ed0b
SG
385 public void run() {
386 frame.dispose();
cedbdb09
SG
387 }
388 });
389 glWindow.destroy();
390 Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
391 }
392
393 @Test
394 public void test01GL2ES2() throws InterruptedException, InvocationTargetException {
395 for(int i=1; i<=loops; i++) {
396 System.err.println("Loop "+i+"/"+loops);
397 final GLProfile glp;
398 if(forceGL3) {
399 glp = GLProfile.get(GLProfile.GL3);
400 } else if(forceES2) {
401 glp = GLProfile.get(GLProfile.GLES2);
402 } else {
403 glp = GLProfile.getGL2ES2();
404 }
405 final GLCapabilities caps = new GLCapabilities( glp );
406 caps.setBackgroundOpaque(opaque);
407 if(-1 < forceAlpha) {
2571ed0b 408 caps.setAlphaBits(forceAlpha);
cedbdb09 409 }
c6224657 410 runTestGL(caps, resizeBy, frameLayout);
cedbdb09
SG
411 if(loop_shutdown) {
412 GLProfile.shutdown();
413 }
414 }
415 }
416
417 @Test
418 public void test02GL3() throws InterruptedException, InvocationTargetException {
419 if(mainRun) return;
2571ed0b 420
cedbdb09
SG
421 if( !GLProfile.isAvailable(GLProfile.GL3) ) {
422 System.err.println("GL3 n/a");
6e08b6f0 423 return;
cedbdb09
SG
424 }
425 final GLProfile glp = GLProfile.get(GLProfile.GL3);
426 final GLCapabilities caps = new GLCapabilities( glp );
c6224657 427 runTestGL(caps, resizeBy, frameLayout);
cedbdb09 428 }
2571ed0b
SG
429
430 @Test
431 public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException {
432 if( mainRun ) return;
433
434 reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
435 reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
436
437 GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
438 runTestGL(caps, resizeBy, frameLayout);
439 }
440
cedbdb09
SG
441 public static void main(String args[]) throws IOException {
442 mainRun = true;
2571ed0b 443
cedbdb09 444 int x=0, y=0, w=640, h=480;
c6224657 445 int rw=-1, rh=-1;
cedbdb09 446 boolean usePos = false;
2571ed0b 447
cedbdb09
SG
448 for(int i=0; i<args.length; i++) {
449 if(args[i].equals("-time")) {
450 i++;
451 duration = MiscUtils.atol(args[i], duration);
c6224657
SG
452 } else if(args[i].equals("-rwidth")) {
453 i++;
454 rw = MiscUtils.atoi(args[i], rw);
455 } else if(args[i].equals("-rheight")) {
456 i++;
457 rh = MiscUtils.atoi(args[i], rh);
458 } else if(args[i].equals("-layout")) {
459 i++;
460 frameLayout = FrameLayout.valueOf(args[i]);
461 } else if(args[i].equals("-resizeBy")) {
462 i++;
463 resizeBy = ResizeBy.valueOf(args[i]);
cedbdb09
SG
464 } else if(args[i].equals("-translucent")) {
465 opaque = false;
466 } else if(args[i].equals("-forceAlpha")) {
467 i++;
468 forceAlpha = MiscUtils.atoi(args[i], 0);
469 } else if(args[i].equals("-fullscreen")) {
470 fullscreen = true;
471 } else if(args[i].equals("-pmvDirect")) {
472 pmvUseBackingArray = false;
473 } else if(args[i].equals("-vsync")) {
474 i++;
475 swapInterval = MiscUtils.atoi(args[i], swapInterval);
c6224657
SG
476 } else if(args[i].equals("-layeredFBO")) {
477 shallUseOffscreenFBOLayer = true;
cedbdb09
SG
478 } else if(args[i].equals("-exclctx")) {
479 exclusiveContext = true;
30b2490e
SG
480 } else if(args[i].equals("-noanim")) {
481 useAnimator = false;
cedbdb09
SG
482 } else if(args[i].equals("-es2")) {
483 forceES2 = true;
484 } else if(args[i].equals("-gl3")) {
485 forceGL3 = true;
486 } else if(args[i].equals("-showFPS")) {
487 showFPS = true;
488 } else if(args[i].equals("-width")) {
489 i++;
490 w = MiscUtils.atoi(args[i], w);
491 } else if(args[i].equals("-height")) {
492 i++;
493 h = MiscUtils.atoi(args[i], h);
494 } else if(args[i].equals("-x")) {
495 i++;
496 x = MiscUtils.atoi(args[i], x);
497 usePos = true;
498 } else if(args[i].equals("-y")) {
499 i++;
500 y = MiscUtils.atoi(args[i], y);
501 usePos = true;
2571ed0b
SG
502 } else if(args[i].equals("-pixelScale")) {
503 i++;
504 final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]);
505 reqSurfacePixelScale[0] = pS;
506 reqSurfacePixelScale[1] = pS;
cedbdb09
SG
507 } else if(args[i].equals("-screen")) {
508 i++;
509 screenIdx = MiscUtils.atoi(args[i], 0);
510 } else if(args[i].equals("-loops")) {
511 i++;
512 loops = MiscUtils.atoi(args[i], 1);
513 } else if(args[i].equals("-loop-shutdown")) {
514 loop_shutdown = true;
515 }
516 }
517 wsize = new Dimension(w, h);
c6224657
SG
518 if( 0 < rw && 0 < rh ) {
519 rwsize = new Dimension(rw, rh);
520 }
2571ed0b 521
cedbdb09
SG
522 if(usePos) {
523 wpos = new Point(x, y);
524 }
2571ed0b 525
c6224657
SG
526 System.err.println("frameLayout "+frameLayout);
527 System.err.println("resizeBy "+resizeBy);
cedbdb09
SG
528 System.err.println("position "+wpos);
529 System.err.println("size "+wsize);
c6224657 530 System.err.println("resize "+rwsize);
cedbdb09
SG
531 System.err.println("screen "+screenIdx);
532 System.err.println("translucent "+(!opaque));
2571ed0b 533 System.err.println("forceAlpha "+forceAlpha);
cedbdb09 534 System.err.println("fullscreen "+fullscreen);
2571ed0b 535 System.err.println("pmvDirect "+(!pmvUseBackingArray));
cedbdb09
SG
536 System.err.println("loops "+loops);
537 System.err.println("loop shutdown "+loop_shutdown);
c6224657 538 System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
cedbdb09
SG
539 System.err.println("forceES2 "+forceES2);
540 System.err.println("forceGL3 "+forceGL3);
541 System.err.println("swapInterval "+swapInterval);
542 System.err.println("exclusiveContext "+exclusiveContext);
30b2490e 543 System.err.println("useAnimator "+useAnimator);
cedbdb09
SG
544
545 org.junit.runner.JUnitCore.main(TestGearsES2NewtCanvasAWT.class.getName());
546 }
547}
http://JogAmp.org git info: FAQ, tutorial and man pages.