29package com.jogamp.opengl.test.junit.newt;
31import java.awt.Component;
32import java.awt.Dimension;
33import java.io.IOException;
35import com.jogamp.opengl.GLAutoDrawable;
36import com.jogamp.opengl.GLCapabilities;
37import com.jogamp.opengl.GLProfile;
38import javax.swing.Box;
39import javax.swing.BoxLayout;
40import javax.swing.JFrame;
41import javax.swing.JPanel;
42import javax.swing.SwingUtilities;
44import org.junit.Assert;
45import org.junit.BeforeClass;
47import org.junit.FixMethodOrder;
48import org.junit.runners.MethodSorters;
50import com.jogamp.newt.awt.NewtCanvasAWT;
51import com.jogamp.newt.opengl.GLWindow;
52import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
53import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
54import com.jogamp.opengl.test.junit.util.UITestCase;
55import com.jogamp.opengl.util.Animator;
61@FixMethodOrder(MethodSorters.NAME_ASCENDING)
64 static long durationPerTest = 1000;
69 setTestSupported(
false);
74 public void test01() throws InterruptedException {
78 public void testImpl() throws InterruptedException {
79 final JFrame frame =
new JFrame(this.getSimpleTestName(
"."));
92 final Component openGLComponent1;
93 final Component openGLComponent2;
99 newtCanvasAWT1.setPreferredSize(
new Dimension(640, 480));
104 newtCanvasAWT2.setPreferredSize(
new Dimension(640, 480));
107 openGLComponent1 = newtCanvasAWT1;
108 openGLComponent2 = newtCanvasAWT2;
109 openGLAutoDrawable1 = glWindow1;
110 openGLAutoDrawable2 = glWindow2;
113 final JPanel openGLPanel =
new JPanel();
114 openGLPanel.setLayout(
new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
115 openGLPanel.add(openGLComponent1);
116 openGLPanel.add(Box.createHorizontalStrut(5));
117 openGLPanel.add(openGLComponent2);
119 final JPanel mainPanel = (JPanel) frame.getContentPane();
120 mainPanel.setLayout(
new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
121 mainPanel.add(Box.createHorizontalGlue());
122 mainPanel.add(openGLPanel);
123 mainPanel.add(Box.createHorizontalGlue());
125 final Animator animator =
new Animator(Thread.currentThread().getThreadGroup());
127 animator.
add(openGLAutoDrawable1);
128 animator.
add(openGLAutoDrawable2);
131 SwingUtilities.invokeLater(
new Runnable() {
134 frame.setVisible(
true);
153 SwingUtilities.invokeLater(
new Runnable() {
165 static int atoi(
final String a) {
168 i = Integer.parseInt(a);
169 }
catch (
final Exception ex) { ex.printStackTrace(); }
173 public static void main(
final String[] args)
throws IOException {
174 for(
int i=0; i<args.length; i++) {
175 if(args[i].equals(
"-time")) {
176 if (++i < args.length) {
177 durationPerTest = atoi(args[i]);
AWT Canvas containing a NEWT Window using native parenting.
final void destroy()
Destroys this resource:
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
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.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
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.
TestMultipleNewtCanvasAWT.
static void main(final String[] args)
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)
final long getTotalFPSDuration()
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
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.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.