29package com.jogamp.opengl.test.junit.jogl.demos.es2.swt;
31import java.io.IOException;
32import java.lang.reflect.InvocationTargetException;
34import com.jogamp.nativewindow.swt.SWTAccessor;
35import com.jogamp.opengl.swt.GLCanvas;
36import com.jogamp.opengl.test.junit.util.GLTestUtil;
37import com.jogamp.opengl.test.junit.util.MiscUtils;
38import com.jogamp.opengl.test.junit.util.NewtTestUtil;
39import com.jogamp.opengl.test.junit.util.SWTTestUtil;
40import com.jogamp.opengl.test.junit.util.UITestCase;
41import com.jogamp.opengl.util.Animator;
42import com.jogamp.opengl.util.AnimatorBase;
43import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
45import com.jogamp.nativewindow.util.Dimension;
46import com.jogamp.nativewindow.util.Point;
47import com.jogamp.nativewindow.util.PointImmutable;
48import com.jogamp.nativewindow.util.DimensionImmutable;
49import com.jogamp.opengl.GLCapabilities;
50import com.jogamp.opengl.GLCapabilitiesImmutable;
51import com.jogamp.opengl.GLProfile;
53import org.eclipse.swt.SWT;
54import org.eclipse.swt.layout.FillLayout;
55import org.eclipse.swt.widgets.Composite;
56import org.eclipse.swt.widgets.Display;
57import org.eclipse.swt.widgets.Shell;
58import org.junit.After;
59import org.junit.Assert;
60import org.junit.Assume;
61import org.junit.Before;
62import org.junit.BeforeClass;
63import org.junit.AfterClass;
65import org.junit.FixMethodOrder;
66import org.junit.runners.MethodSorters;
68@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 static int screenIdx = 0;
74 static long duration = 500;
75 static boolean opaque =
true;
76 static int forceAlpha = -1;
77 static boolean fullscreen =
false;
78 static int swapInterval = 1;
79 static boolean showFPS =
false;
81 static boolean loop_shutdown =
false;
82 static boolean forceES2 =
false;
83 static boolean forceGL3 =
false;
84 static boolean mainRun =
false;
85 static boolean exclusiveContext =
false;
98 Display display =
null;
100 Composite composite =
null;
107 display =
new Display();
108 Assert.assertNotNull( display );
111 display.syncExec(
new Runnable() {
114 shell =
new Shell( display );
115 Assert.assertNotNull( shell );
116 shell.setLayout(
new FillLayout() );
117 composite =
new Composite( shell, SWT.NONE );
118 composite.setLayout(
new FillLayout() );
119 Assert.assertNotNull( composite );
125 Assert.assertNotNull( display );
126 Assert.assertNotNull( shell );
127 Assert.assertNotNull( composite );
129 display.syncExec(
new Runnable() {
141 catch(
final Throwable throwable ) {
142 throwable.printStackTrace();
143 Assume.assumeNoException( throwable );
151 System.err.println(
"requested: vsync "+swapInterval+
", "+caps);
154 Assert.assertNotNull( canvas );
162 animator.
add(canvas);
165 Assert.assertTrue(animator.isAnimating());
168 display.syncExec(
new Runnable() {
171 shell.setText( getSimpleTestName(
".") );
174 shell.setLocation( wpos.
getX(), wpos.
getY() );
184 System.err.println(
"TestGearsES2SWT.test: 2.0: Exception "+(
null != waitAction.getException(
true)));
186 System.err.println(
"TestGearsES2SWT.test: 2.1: Exception "+(
null != waitAction.getException(
true)));
191 System.err.println(
"TestGearsES2SWT.test: 3.0: Exception "+(
null != waitAction.getException(
true)));
194 display.syncExec(
new Runnable() {
200 if(
null != rwsize ) {
201 for(
int i=0; i<50; i++) {
204 System.err.println(
"TestGearsES2SWT.test: 4.0: Exception "+(
null != waitAction.getException(
true)));
205 display.syncExec(
new Runnable() {
217 System.err.println(
"TestGearsES2SWT.test: 5.0: Exception "+(
null != waitAction.getException(
true)));
221 Assert.assertFalse(animator.isAnimating());
222 Assert.assertFalse(animator.
isStarted());
225 display.syncExec(
new Runnable() {
233 public void test01GL2ES2() throws InterruptedException, InvocationTargetException {
234 for(
int i=1; i<=loops; i++) {
235 System.err.println(
"Loop "+i+
"/"+loops);
239 }
else if(forceES2) {
246 if(-1 < forceAlpha) {
257 public void test02GL3() throws InterruptedException, InvocationTargetException {
261 System.err.println(
"GL3 n/a");
269 public static void main(
final String args[])
throws IOException {
272 int x=0, y=0, w=640, h=480, rw=-1, rh=-1;
273 boolean usePos =
false;
275 for(
int i=0; i<args.length; i++) {
276 if(args[i].equals(
"-time")) {
279 }
else if(args[i].equals(
"-translucent")) {
281 }
else if(args[i].equals(
"-forceAlpha")) {
284 }
else if(args[i].equals(
"-fullscreen")) {
286 }
else if(args[i].equals(
"-vsync")) {
289 }
else if(args[i].equals(
"-exclctx")) {
290 exclusiveContext =
true;
291 }
else if(args[i].equals(
"-es2")) {
293 }
else if(args[i].equals(
"-gl3")) {
295 }
else if(args[i].equals(
"-showFPS")) {
297 }
else if(args[i].equals(
"-width")) {
300 }
else if(args[i].equals(
"-height")) {
303 }
else if(args[i].equals(
"-x")) {
307 }
else if(args[i].equals(
"-y")) {
311 }
else if(args[i].equals(
"-rwidth")) {
314 }
else if(args[i].equals(
"-rheight")) {
317 }
else if(args[i].equals(
"-screen")) {
320 }
else if(args[i].equals(
"-loops")) {
323 }
else if(args[i].equals(
"-loop-shutdown")) {
324 loop_shutdown =
true;
328 if( 0 < rw && 0 < rh ) {
333 wpos =
new Point(x, y);
335 System.err.println(
"position "+wpos);
336 System.err.println(
"size "+wsize);
337 System.err.println(
"resize "+rwsize);
338 System.err.println(
"screen "+screenIdx);
339 System.err.println(
"translucent "+(!opaque));
340 System.err.println(
"forceAlpha "+forceAlpha);
341 System.err.println(
"fullscreen "+fullscreen);
342 System.err.println(
"loops "+loops);
343 System.err.println(
"loop shutdown "+loop_shutdown);
344 System.err.println(
"forceES2 "+forceES2);
345 System.err.println(
"forceGL3 "+forceGL3);
346 System.err.println(
"swapInterval "+swapInterval);
347 System.err.println(
"exclusiveContext "+exclusiveContext);
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
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.
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 void shutdown()
Manual shutdown method, may be called after your last JOGL use within the running JVM.
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.
Native SWT Canvas implementing GLAutoDrawable.
final GLDrawable getDelegatedDrawable()
If the implementation uses delegation, return the delegated GLDrawable instance, otherwise return thi...
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, final GLCapabilitiesChooser chooser)
Creates an instance using GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser) on...
final Thread getExclusiveContextThread()
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void dispose()
@Override public boolean forceFocus() { final boolean r = super.forceFocus(); if(r && 0 !...
void runTestGL(final GLCapabilitiesImmutable caps)
static void releaseClass()
static void main(final String args[])
static boolean waitForRealized(final GLAutoDrawable glad, final boolean realized, final Runnable waitAction)
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
final long getTotalFPSDuration()
final synchronized Thread getThread()
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)
synchronized boolean isStarted()
Indicates whether this animator has been started.
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:
Immutable Point interface.
Specifies an immutable set of OpenGL capabilities.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...