JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGearsES2AWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 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.awt;
30
31import com.jogamp.nativewindow.ScalableSurface;
32import com.jogamp.opengl.*;
33
34import com.jogamp.opengl.util.Animator;
35
36import com.jogamp.opengl.awt.GLCanvas;
37
38import com.jogamp.common.os.Platform;
39import com.jogamp.common.util.awt.AWTEDTExecutor;
40import com.jogamp.newt.event.awt.AWTKeyAdapter;
41import com.jogamp.newt.event.awt.AWTWindowAdapter;
42import com.jogamp.newt.event.KeyEvent;
43import com.jogamp.newt.event.TraceKeyAdapter;
44import com.jogamp.newt.event.TraceWindowAdapter;
45import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
46import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
47import com.jogamp.opengl.test.junit.util.MiscUtils;
48import com.jogamp.opengl.test.junit.util.UITestCase;
49import com.jogamp.opengl.test.junit.util.QuitAdapter;
50
51import java.awt.BorderLayout;
52import java.awt.Button;
53import java.awt.Component;
54import java.awt.Container;
55import java.awt.Dimension;
56import java.awt.EventQueue;
57import java.awt.Frame;
58import java.awt.TextArea;
59import java.io.BufferedReader;
60import java.io.IOException;
61import java.io.InputStreamReader;
62import java.lang.reflect.InvocationTargetException;
63
64import org.junit.Assert;
65import org.junit.Assume;
66import org.junit.BeforeClass;
67import org.junit.AfterClass;
68import org.junit.Test;
69import org.junit.FixMethodOrder;
70import org.junit.runners.MethodSorters;
71
72@FixMethodOrder(MethodSorters.NAME_ASCENDING)
73public class TestGearsES2AWT extends UITestCase {
74 public enum FrameLayout { None, TextOnBottom, BorderCenterSurrounded, DoubleBorderCenterSurrounded };
75 public enum ResizeBy { Component, Frame };
76
77 static long duration = 500; // ms
78 static int width = 640, height = 480;
79 static int xpos = 10, ypos = 10;
80 static FrameLayout frameLayout = FrameLayout.None;
81 static ResizeBy resizeBy = ResizeBy.Component;
82 static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
83
84 static boolean forceES2 = false;
85 static boolean forceGL3 = false;
86 static boolean manualTest = false;
87 static boolean shallUseOffscreenFBOLayer = false;
88 static boolean shallUseOffscreenPBufferLayer = false;
89 static boolean useMSAA = false;
90 static boolean useStencil = false;
91 static boolean shutdownRemoveGLCanvas = true;
92 static boolean shutdownDisposeFrame = true;
93 static boolean shutdownSystemExit = false;
94 static int swapInterval = 1;
95 static boolean exclusiveContext = false;
96 static boolean useAnimator = true;
97 static Thread awtEDT;
98 static java.awt.Dimension rwsize = null;
99
100 @BeforeClass
101 public static void initClass() {
102 try {
103 EventQueue.invokeAndWait(new Runnable() {
104 @Override
105 public void run() {
106 awtEDT = Thread.currentThread();
107 } } );
108 } catch (final Exception e) {
109 e.printStackTrace();
110 Assert.assertNull(e);
111 }
112 }
113
114 @AfterClass
115 public static void releaseClass() {
116 }
117
118 static void setComponentSize(final Frame frame, final Component comp, final java.awt.Dimension new_sz) {
119 try {
120 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
121 @Override
122 public void run() {
123 comp.setMinimumSize(new_sz);
124 comp.setPreferredSize(new_sz);
125 comp.setSize(new_sz);
126 if( null != frame ) {
127 frame.pack();
128 }
129 } } );
130 } catch( final Throwable throwable ) {
131 throwable.printStackTrace();
132 Assume.assumeNoException( throwable );
133 }
134 }
135 static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) {
136 try {
137 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
138 @Override
139 public void run() {
140 frame.setSize(new_sz);
141 if( frameLayout ) {
142 frame.validate();
143 }
144 } } );
145 } catch( final Throwable throwable ) {
146 throwable.printStackTrace();
147 Assume.assumeNoException( throwable );
148 }
149 }
150
151 static void setSize(final ResizeBy resizeBy, final Frame frame, final boolean frameLayout, final Component comp, final java.awt.Dimension new_sz) {
152 switch( resizeBy ) {
153 case Component:
154 setComponentSize(frameLayout ? frame : null, comp, new_sz);
155 break;
156 case Frame:
157 setFrameSize(frame, frameLayout, new_sz);
158 break;
159 }
160 }
161
162 private void setTitle(final Frame frame, final GLCanvas glc, final GLCapabilitiesImmutable caps) {
163 final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
164 final java.awt.Rectangle b = glc.getBounds();
165 final float[] minSurfacePixelScale = glc.getMinimumSurfaceScale(new float[2]);
166 final float[] maxSurfacePixelScale = glc.getMaximumSurfaceScale(new float[2]);
167 final float[] reqSurfacePixelScale = glc.getRequestedSurfaceScale(new float[2]);
168 final float[] hasSurfacePixelScale = glc.getCurrentSurfaceScale(new float[2]);
169 AWTEDTExecutor.singleton.invoke(false, new Runnable() {
170 @Override
171 public void run() {
172 frame.setTitle("GLCanvas["+capsA+"], swapI "+swapInterval+", win: ["+b.x+"/"+b.y+" "+b.width+"x"+b.height+"], pix: "+glc.getSurfaceWidth()+"x"+glc.getSurfaceHeight()+
173 ", scale[min "+minSurfacePixelScale[0]+"x"+minSurfacePixelScale[1]+", max "+
174 maxSurfacePixelScale[0]+"x"+maxSurfacePixelScale[1]+", req "+
175 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" -> has "+
176 hasSurfacePixelScale[0]+"x"+hasSurfacePixelScale[1]+"]");
177 } } );
178 }
179
180 protected void runTestGL(final GLCapabilities caps, final ResizeBy resizeBy, final FrameLayout frameLayout) throws InterruptedException, InvocationTargetException {
181 final Frame frame = new Frame("GearsES2 AWT Test");
182 Assert.assertNotNull(frame);
183
184 final GLCanvas glCanvas = new GLCanvas(caps);
185 Assert.assertNotNull(glCanvas);
186 setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height));
187 glCanvas.setSurfaceScale(reqSurfacePixelScale);
188 final float[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new float[2]);
189 frame.setLocation(xpos, ypos);
190
191 switch( frameLayout) {
192 case None:
193 frame.add(glCanvas);
194 break;
195 case TextOnBottom:
196 final TextArea ta = new TextArea(2, 20);
197 ta.append("0123456789");
198 ta.append(Platform.getNewline());
199 ta.append("Some Text");
200 ta.append(Platform.getNewline());
201 frame.setLayout(new BorderLayout());
202 frame.add(ta, BorderLayout.SOUTH);
203 frame.add(glCanvas, BorderLayout.CENTER);
204 break;
205 case BorderCenterSurrounded:
206 frame.setLayout(new BorderLayout());
207 frame.add(new Button("NORTH"), BorderLayout.NORTH);
208 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
209 frame.add(new Button("EAST"), BorderLayout.EAST);
210 frame.add(new Button("WEST"), BorderLayout.WEST);
211 frame.add(glCanvas, BorderLayout.CENTER);
212 break;
213 case DoubleBorderCenterSurrounded:
214 final Container c = new Container();
215 c.setLayout(new BorderLayout());
216 c.add(new Button("north"), BorderLayout.NORTH);
217 c.add(new Button("south"), BorderLayout.SOUTH);
218 c.add(new Button("east"), BorderLayout.EAST);
219 c.add(new Button("west"), BorderLayout.WEST);
220 c.add(glCanvas, BorderLayout.CENTER);
221
222 frame.setLayout(new BorderLayout());
223 frame.add(new Button("NORTH"), BorderLayout.NORTH);
224 frame.add(new Button("SOUTH"), BorderLayout.SOUTH);
225 frame.add(new Button("EAST"), BorderLayout.EAST);
226 frame.add(new Button("WEST"), BorderLayout.WEST);
227 frame.add(c, BorderLayout.CENTER);
228 break;
229 }
230 setTitle(frame, glCanvas, caps);
231
232 final GearsES2 demo = new GearsES2(swapInterval);
233 glCanvas.addGLEventListener(demo);
234
236 glCanvas.addGLEventListener(snap);
237 glCanvas.addGLEventListener(new GLEventListener() {
238 @Override
239 public void init(final GLAutoDrawable drawable) { }
240 @Override
241 public void dispose(final GLAutoDrawable drawable) { }
242 @Override
243 public void display(final GLAutoDrawable drawable) { }
244 @Override
245 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
246 setTitle(frame, glCanvas, caps);
247 }
248 });
249
250 final Animator animator = useAnimator ? new Animator(glCanvas) : null;
251 if( useAnimator && exclusiveContext ) {
252 animator.setExclusiveContext(awtEDT);
253 }
254 final QuitAdapter quitAdapter = new QuitAdapter();
255 new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas).addTo(glCanvas);
256 new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);
257
258 final com.jogamp.newt.event.KeyListener kl = new com.jogamp.newt.event.KeyAdapter() {
259 @Override
260 public void keyPressed(final KeyEvent e) {
261 if( e.isAutoRepeat() ) {
262 return;
263 }
264 if(e.getKeyChar()=='x') {
265 final float[] hadSurfacePixelScale = glCanvas.getCurrentSurfaceScale(new float[2]);
266 final float[] reqSurfacePixelScale;
267 if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
268 reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
269 } else {
270 reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
271 }
272 System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
273 glCanvas.setSurfaceScale(reqSurfacePixelScale);
274 final float[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new float[2]);
275 final float[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new float[2]);
276 System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
277 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
278 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
279 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
280 setTitle(frame, glCanvas, caps);
281 }
282 } };
283 new AWTKeyAdapter(kl, glCanvas).addTo(glCanvas);
284
285 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
286 @Override
287 public void run() {
288 if( ResizeBy.Frame == resizeBy ) {
289 frame.validate();
290 } else {
291 frame.pack();
292 }
293 frame.setVisible(true);
294 }});
295 Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true, null));
296 Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true, null));
297
298 final float[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new float[2]);
299 System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
300 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
301 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
302 setTitle(frame, glCanvas, caps);
303
304 if( useAnimator ) {
305 animator.start();
306 Assert.assertTrue(animator.isStarted());
307 Assert.assertTrue(animator.isAnimating());
308 Assert.assertEquals(exclusiveContext ? awtEDT : null, glCanvas.getExclusiveContextThread());
309 animator.setUpdateFPSFrames(60, System.err);
310 }
311
312 System.err.println("canvas pos/siz: "+glCanvas.getX()+"/"+glCanvas.getY()+" "+glCanvas.getSurfaceWidth()+"x"+glCanvas.getSurfaceHeight());
313
314 snap.setMakeSnapshot();
315
316 if( null != rwsize ) {
317 Thread.sleep(500); // 500ms delay
318 setSize(resizeBy, frame, true, glCanvas, rwsize);
319 System.err.println("window resize pos/siz: "+glCanvas.getX()+"/"+glCanvas.getY()+" "+glCanvas.getSurfaceWidth()+"x"+glCanvas.getSurfaceHeight());
320 }
321
322 snap.setMakeSnapshot();
323
324 final long t0 = System.currentTimeMillis();
325 long t1 = t0;
326 while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
327 Thread.sleep(100);
328 t1 = System.currentTimeMillis();
329 }
330
331 Assert.assertNotNull(frame);
332 Assert.assertNotNull(glCanvas);
333
334 if( useAnimator ) {
335 Assert.assertNotNull(animator);
336 Assert.assertEquals(exclusiveContext ? awtEDT : null, glCanvas.getExclusiveContextThread());
337 animator.stop();
338 Assert.assertFalse(animator.isAnimating());
339 Assert.assertFalse(animator.isStarted());
340 Assert.assertEquals(null, glCanvas.getExclusiveContextThread());
341 }
342
343 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
344 @Override
345 public void run() {
346 frame.setVisible(false);
347 }});
348 Assert.assertEquals(false, frame.isVisible());
349 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
350 @Override
351 public void run() {
352 if(shutdownRemoveGLCanvas) {
353 frame.remove(glCanvas);
354 }
355 if(shutdownDisposeFrame) {
356 frame.dispose();
357 }
358 if(shutdownSystemExit) {
359 System.exit(0);
360 }
361 }});
362 }
363
364 @Test
365 public void test01() throws InterruptedException, InvocationTargetException {
366 final GLProfile glp;
367 if(forceGL3) {
368 glp = GLProfile.get(GLProfile.GL3);
369 } else if(forceES2) {
371 } else {
372 glp = GLProfile.getGL2ES2();
373 }
374 final GLCapabilities caps = new GLCapabilities(glp);
375 if(useMSAA) {
376 caps.setNumSamples(4);
377 caps.setSampleBuffers(true);
378 }
379 if(useStencil) {
380 caps.setStencilBits(1);
381 }
382 if(shallUseOffscreenFBOLayer) {
383 caps.setOnscreen(false);
384 }
385 if(shallUseOffscreenPBufferLayer) {
386 caps.setPBuffer(true);
387 }
388 runTestGL(caps, resizeBy, frameLayout);
389 }
390
391 @Test
392 public void test02_GLES2() throws InterruptedException, InvocationTargetException {
393 if(manualTest) return;
394
396 System.err.println("GLES2 n/a");
397 return;
398 }
400 final GLCapabilities caps = new GLCapabilities( glp );
401 runTestGL(caps, resizeBy, frameLayout);
402 }
403
404 @Test
405 public void test03_GL3() throws InterruptedException, InvocationTargetException {
406 if(manualTest) return;
407
409 System.err.println("GL3 n/a");
410 return;
411 }
412 final GLProfile glp = GLProfile.get(GLProfile.GL3);
413 final GLCapabilities caps = new GLCapabilities( glp );
414 runTestGL(caps, resizeBy, frameLayout);
415 }
416
417 @Test
418 public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException {
419 if( manualTest ) return;
420
421 reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
422 reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
423
425 runTestGL(caps, resizeBy, frameLayout);
426 }
427
428 public static void main(final String args[]) {
429 boolean waitForKey = false;
430 int rw=-1, rh=-1;
431
432 for(int i=0; i<args.length; i++) {
433 if(args[i].equals("-time")) {
434 i++;
435 duration = MiscUtils.atol(args[i], duration);
436 } else if(args[i].equals("-width")) {
437 i++;
438 width = MiscUtils.atoi(args[i], width);
439 } else if(args[i].equals("-height")) {
440 i++;
441 height = MiscUtils.atoi(args[i], height);
442 } else if(args[i].equals("-x")) {
443 i++;
444 xpos = MiscUtils.atoi(args[i], xpos);
445 } else if(args[i].equals("-y")) {
446 i++;
447 ypos = MiscUtils.atoi(args[i], ypos);
448 } else if(args[i].equals("-rwidth")) {
449 i++;
450 rw = MiscUtils.atoi(args[i], rw);
451 } else if(args[i].equals("-rheight")) {
452 i++;
453 rh = MiscUtils.atoi(args[i], rh);
454 } else if(args[i].equals("-pixelScale")) {
455 i++;
456 final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]);
457 reqSurfacePixelScale[0] = pS;
458 reqSurfacePixelScale[1] = pS;
459 } else if(args[i].equals("-layout")) {
460 i++;
461 frameLayout = FrameLayout.valueOf(args[i]);
462 } else if(args[i].equals("-resizeBy")) {
463 i++;
464 resizeBy = ResizeBy.valueOf(args[i]);
465 } else if(args[i].equals("-es2")) {
466 forceES2 = true;
467 } else if(args[i].equals("-gl3")) {
468 forceGL3 = true;
469 } else if(args[i].equals("-vsync")) {
470 i++;
471 swapInterval = MiscUtils.atoi(args[i], swapInterval);
472 } else if(args[i].equals("-exclctx")) {
473 exclusiveContext = true;
474 } else if(args[i].equals("-noanim")) {
475 useAnimator = false;
476 } else if(args[i].equals("-layeredFBO")) {
477 shallUseOffscreenFBOLayer = true;
478 } else if(args[i].equals("-layeredPBuffer")) {
479 shallUseOffscreenPBufferLayer = true;
480 } else if(args[i].equals("-msaa")) {
481 useMSAA = true;
482 } else if(args[i].equals("-stencil")) {
483 useStencil = true;
484 } else if(args[i].equals("-wait")) {
485 waitForKey = true;
486 } else if(args[i].equals("-shutdownKeepGLCanvas")) {
487 shutdownRemoveGLCanvas = false;
488 } else if(args[i].equals("-shutdownKeepFrame")) {
489 shutdownDisposeFrame = false;
490 } else if(args[i].equals("-shutdownKeepAll")) {
491 shutdownRemoveGLCanvas = false;
492 shutdownDisposeFrame = false;
493 } else if(args[i].equals("-shutdownSystemExit")) {
494 shutdownSystemExit = true;
495 } else if(args[i].equals("-manual")) {
496 manualTest = true;
497 }
498 }
499 if( 0 < rw && 0 < rh ) {
500 rwsize = new Dimension(rw, rh);
501 }
502
503 System.err.println("resize "+rwsize);
504 System.err.println("frameLayout "+frameLayout);
505 System.err.println("resizeBy "+resizeBy);
506 System.err.println("forceES2 "+forceES2);
507 System.err.println("forceGL3 "+forceGL3);
508 System.err.println("swapInterval "+swapInterval);
509 System.err.println("exclusiveContext "+exclusiveContext);
510 System.err.println("useMSAA "+useMSAA);
511 System.err.println("useAnimator "+useAnimator);
512
513 System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
514 System.err.println("shallUseOffscreenPBufferLayer "+shallUseOffscreenPBufferLayer);
515
516 if(waitForKey) {
517 final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
518 System.err.println("Press enter to continue");
519 try {
520 System.err.println(stdin.readLine());
521 } catch (final IOException e) { }
522 }
523 org.junit.runner.JUnitCore.main(TestGearsES2AWT.class.getName());
524 }
525}
void setOnscreen(final boolean onscreen)
Sets whether the surface shall be on- or offscreen.
final boolean isAutoRepeat()
getModifiers() contains AUTOREPEAT_MASK.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
Definition: KeyEvent.java:161
AWT: printable: PRESSED (t0), TYPED (t0), RELEASED (t1) non-printable: PRESSED (t0),...
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
Specifies a set of OpenGL capabilities.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
void setStencilBits(final int stencilBits)
Sets the number of bits requested for the stencil buffer.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
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 GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
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 GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
A heavyweight AWT component which provides OpenGL rendering support.
Definition: GLCanvas.java:170
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.If canSetSurfaceScale() returns fal...
Definition: GLCanvas.java:685
final Thread getExclusiveContextThread()
Definition: GLCanvas.java:1127
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: GLCanvas.java:659
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLCanvas.java:1248
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
Definition: GLCanvas.java:1243
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Definition: GLCanvas.java:1065
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Definition: GLCanvas.java:692
void runTestGL(final GLCapabilities caps, final ResizeBy resizeBy, final FrameLayout frameLayout)
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
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
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
boolean isBackgroundOpaque()
Returns whether an opaque or translucent surface is requested, supported or chosen.
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,...
Listener for KeyEvents.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.