29package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
32import java.io.IOException;
33import java.lang.reflect.InvocationTargetException;
35import com.jogamp.newt.Display;
36import com.jogamp.newt.NewtFactory;
37import com.jogamp.newt.Screen;
38import com.jogamp.newt.awt.NewtCanvasAWT;
39import com.jogamp.newt.event.WindowEvent;
40import com.jogamp.newt.event.WindowAdapter;
41import com.jogamp.newt.opengl.GLWindow;
42import com.jogamp.newt.opengl.util.NEWTDemoListener;
43import com.jogamp.opengl.test.junit.util.MiscUtils;
44import com.jogamp.opengl.test.junit.util.UITestCase;
45import com.jogamp.opengl.util.Animator;
46import com.jogamp.opengl.util.AnimatorBase;
47import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2;
48import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter;
49import com.jogamp.opengl.test.junit.newt.parenting.NewtReparentingKeyAdapter;
51import com.jogamp.nativewindow.util.Dimension;
52import com.jogamp.nativewindow.util.DimensionImmutable;
53import com.jogamp.opengl.GLCapabilities;
54import com.jogamp.opengl.GLCapabilitiesImmutable;
55import com.jogamp.opengl.GLProfile;
56import javax.swing.SwingUtilities;
59import org.junit.FixMethodOrder;
60import org.junit.runners.MethodSorters;
70@FixMethodOrder(MethodSorters.NAME_ASCENDING)
74 static long duration = 1000;
75 static int swapInterval = 1;
76 static boolean shallUseOffscreenFBOLayer =
false;
77 static boolean forceES2 =
false;
78 static boolean forceGL3 =
false;
79 static boolean mainRun =
false;
80 static boolean exclusiveContext =
false;
81 static boolean useAnimator =
true;
85 System.err.println(
"requested: vsync "+swapInterval+
", "+caps);
98 if ( shallUseOffscreenFBOLayer ) {
102 final Frame frame =
new Frame(
"AWT Parent Frame");
104 final java.awt.Dimension d =
new java.awt.Dimension(wsize.
getWidth(), wsize.
getHeight());
107 frame.add(newtCanvasAWT);
108 frame.setTitle(
"Gears NewtCanvasAWT Test (translucent "+!caps.isBackgroundOpaque()+
"), swapInterval "+swapInterval+
", size "+wsize);
133 animator.
add(glWindow);
137 SwingUtilities.invokeAndWait(
new Runnable() {
141 frame.setVisible(
true);
153 final long t0 = System.currentTimeMillis();
155 while(!newtDemoListener.
shouldQuit() && t1-t0<duration) {
157 t1 = System.currentTimeMillis();
163 SwingUtilities.invokeAndWait(
new Runnable() {
173 public void test01GL2ES2() throws InterruptedException, InvocationTargetException {
177 }
else if(forceES2) {
187 public void test02GL3() throws InterruptedException, InvocationTargetException {
191 System.err.println(
"GL3 n/a");
199 public static void main(
final String args[])
throws IOException {
202 for(
int i=0; i<args.length; i++) {
203 if(args[i].equals(
"-time")) {
206 }
else if(args[i].equals(
"-vsync")) {
209 }
else if(args[i].equals(
"-layeredFBO")) {
210 shallUseOffscreenFBOLayer =
true;
211 }
else if(args[i].equals(
"-exclctx")) {
212 exclusiveContext =
true;
213 }
else if(args[i].equals(
"-noanim")) {
215 }
else if(args[i].equals(
"-es2")) {
217 }
else if(args[i].equals(
"-gl3")) {
222 System.err.println(
"size "+wsize);
223 System.err.println(
"shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
224 System.err.println(
"forceES2 "+forceES2);
225 System.err.println(
"forceGL3 "+forceGL3);
226 System.err.println(
"swapInterval "+swapInterval);
227 System.err.println(
"exclusiveContext "+exclusiveContext);
228 System.err.println(
"useAnimator "+useAnimator);
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.
AWT Canvas containing a NEWT Window using native parenting.
void setShallUseOffscreenLayer(final boolean v)
Request an offscreen layer, if supported.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
final int getX()
Returns the current x position of this window, relative to it's parent.
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
void quitAdapterEnable(final boolean v)
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
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.
static void main(final String args[])
void runTestGL(final GLCapabilitiesImmutable caps)
AWT specializing demo functionality of NewtReparentingKeyAdapter, includes NEWTDemoListener.
Extending demo functionality of NEWTDemoListener.
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Immutable Dimension Interface, consisting of it's read only components:
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.