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;
43import org.junit.Assert;
44import org.junit.Assume;
45import org.junit.Before;
46import org.junit.BeforeClass;
47import org.junit.After;
49import org.junit.FixMethodOrder;
50import org.junit.runners.MethodSorters;
52import com.jogamp.nativewindow.swt.SWTAccessor;
53import com.jogamp.opengl.swt.GLCanvas;
54import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
55import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
56import com.jogamp.opengl.test.junit.util.SWTTestUtil;
57import com.jogamp.opengl.test.junit.util.UITestCase;
58import com.jogamp.opengl.util.Animator;
59import com.jogamp.opengl.util.GLReadBufferUtil;
60import com.jogamp.opengl.util.texture.TextureIO;
75@FixMethodOrder(MethodSorters.NAME_ASCENDING)
78 static int duration = 250;
79 static boolean doAnimation =
true;
81 static final int iwidth = 640;
82 static final int iheight = 480;
84 Display display =
null;
86 Composite composite =
null;
98 display =
new Display();
99 Assert.assertNotNull( display );
102 display.syncExec(
new Runnable() {
105 shell =
new Shell( display );
106 Assert.assertNotNull( shell );
107 shell.setLayout(
new FillLayout() );
108 composite =
new Composite( shell, SWT.NO_BACKGROUND );
109 composite.setLayout(
new FillLayout() );
110 Assert.assertNotNull( composite );
116 Assert.assertNotNull( display );
117 Assert.assertNotNull( shell );
118 Assert.assertNotNull( composite );
120 display.syncExec(
new Runnable() {
132 catch(
final Throwable throwable ) {
133 throwable.printStackTrace();
134 Assume.assumeNoException( throwable );
145 Assert.assertNotNull( canvas );
149 int displayCount = 0;
153 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
156 if(displayCount < 3) {
157 snapshot(displayCount++,
null, drawable.
getGL(), screenshot,
TextureIO.
PNG,
null);
164 display.syncExec(
new Runnable() {
167 shell.setText( getSimpleTestName(
".") );
168 shell.setSize( 640, 480 );
179 final long lStartTime = System.currentTimeMillis();
180 final long lEndTime = lStartTime + duration;
182 while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
185 }
catch(
final Throwable throwable ) {
186 throwable.printStackTrace();
187 Assume.assumeNoException( throwable );
192 display.syncExec(
new Runnable() {
200 public void test() throws InterruptedException {
212 static int atoi(
final String a) {
215 i = Integer.parseInt(a);
216 }
catch (
final Exception ex) { ex.printStackTrace(); }
220 public static void main(
final String args[]) {
221 for(
int i=0; i<args.length; i++) {
222 if(args[i].equals(
"-time")) {
223 duration = atoi(args[++i]);
224 }
else if(args[i].equals(
"-still")) {
228 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 void printInfo(final PrintStream out, final Display d)
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.
A heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Tests that a basic SWT app can open without crashing under different GL profiles.
void test_MultisampleAndAlpha()
static void main(final String args[])
void runTestAGL(final GLCapabilitiesImmutable caps, final GLEventListener demo)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
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}.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.