29package com.jogamp.opengl.test.junit.jogl.swt;
31import com.jogamp.opengl.GLAutoDrawable;
32import com.jogamp.opengl.GLCapabilities;
33import com.jogamp.opengl.GLCapabilitiesImmutable;
34import com.jogamp.opengl.GLEventListener;
35import com.jogamp.opengl.GLProfile;
37import org.eclipse.swt.SWT;
38import org.eclipse.swt.layout.FillLayout;
39import org.eclipse.swt.widgets.Composite;
40import org.eclipse.swt.widgets.Display;
41import org.eclipse.swt.widgets.Shell;
42import org.junit.Assert;
43import org.junit.Assume;
44import org.junit.Before;
45import org.junit.BeforeClass;
46import org.junit.After;
48import org.junit.FixMethodOrder;
49import org.junit.runners.MethodSorters;
51import com.jogamp.nativewindow.swt.SWTAccessor;
52import com.jogamp.newt.NewtFactory;
53import com.jogamp.newt.Screen;
54import com.jogamp.newt.opengl.GLWindow;
55import com.jogamp.newt.swt.NewtCanvasSWT;
56import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
57import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
58import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
59import com.jogamp.opengl.test.junit.util.MiscUtils;
60import com.jogamp.opengl.test.junit.util.NewtTestUtil;
61import com.jogamp.opengl.test.junit.util.SWTTestUtil;
62import com.jogamp.opengl.test.junit.util.TestUtil;
63import com.jogamp.opengl.test.junit.util.UITestCase;
64import com.jogamp.opengl.util.Animator;
65import com.jogamp.opengl.util.GLReadBufferUtil;
66import com.jogamp.opengl.util.texture.TextureIO;
81@FixMethodOrder(MethodSorters.NAME_ASCENDING)
84 static int duration = 250;
86 static final int iwidth = 640;
87 static final int iheight = 480;
89 Display display =
null;
91 Composite composite =
null;
104 display =
new Display();
105 Assert.assertNotNull( display );
107 display.syncExec(
new Runnable() {
110 shell =
new Shell( display );
111 Assert.assertNotNull( shell );
112 shell.setLayout(
new FillLayout() );
113 composite =
new Composite( shell, SWT.NONE );
114 composite.setLayout(
new FillLayout() );
115 Assert.assertNotNull( composite );
122 Assert.assertNotNull( display );
123 Assert.assertNotNull( shell );
124 Assert.assertNotNull( composite );
126 display.syncExec(
new Runnable() {
138 catch(
final Throwable throwable ) {
139 throwable.printStackTrace();
140 Assume.assumeNoException( throwable );
142 swtNewtDisplay =
null;
149 final boolean postAttach,
final boolean useAnimator )
throws InterruptedException {
154 Assert.assertNotNull(glWindow1);
155 Assert.assertEquals(
false, glWindow1.
isVisible());
157 Assert.assertNull(glWindow1.
getParent());
160 int displayCount = 0;
164 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
167 if(displayCount < 3) {
168 snapshot(displayCount++,
null, drawable.
getGL(), screenshot,
TextureIO.
PNG,
null);
176 Assert.assertNotNull( canvas1 );
178 display.syncExec(
new Runnable() {
181 shell.setText( getSimpleTestName(
".") );
182 shell.setSize( 640, 480 );
188 display.syncExec(
new Runnable() {
215 final long lStartTime = System.currentTimeMillis();
216 final long lEndTime = lStartTime + duration;
218 while( (System.currentTimeMillis() < lEndTime) && !canvas1.isDisposed() ) {
219 generalWaitAction.run();
221 }
catch(
final Throwable throwable ) {
222 throwable.printStackTrace();
223 Assume.assumeNoException( throwable );
229 display.syncExec(
new Runnable() {
232 if( !canvas1.isDisposed() ) {
261 public static void main(
final String args[]) {
262 for(
int i=0; i<args.length; i++) {
263 if(args[i].equals(
"-time")) {
267 System.out.println(
"durationPerTest: "+duration);
static void invokeOnOSTKThread(final boolean blocking, final Runnable runnable)
Runs the specified action in an SWT compatible OS toolkit thread, which is:
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.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Point getLocationOnScreen(final Point storage)
Returns the window's top-left client-area position in the screen.
final NativeWindow getParent()
final boolean isNativeValid()
final boolean isVisible()
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
SWT Canvas containing a NEWT Window using native parenting.
NativeWindow getNativeWindow()
Returns the associated NativeWindow of this NativeWindowHolder, which is identical to getNativeSurfac...
static NewtCanvasSWT create(final Composite parent, final int style, final Window child)
Creates an instance using NewtCanvasSWT(Composite, int, Window) on the SWT thread.
void dispose()
Destroys this resource:
Window setNEWTChild(final Window newChild)
Sets a new NEWT child, provoking reparenting.
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 String glAvailabilityToString(final AbstractGraphicsDevice device)
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Tests that a basic SWT app can open without crashing under different GL profiles and custom GLCapabil...
void postAttach_WithAnimator()
void preAttach_WithAnimator()
static void main(final String args[])
void runTestAGL(final GLCapabilitiesImmutable caps, final GLEventListener demo, final boolean postAttach, final boolean useAnimator)
void preAttach_NoAnimator()
void test_MultisampleAndAlpha()
static int atoi(final String str, final int def)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static final int TIME_SLICE
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
Point getLocationOnScreen(Point point)
Returns the window's top-left client-area position in the screen.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.