29package com.jogamp.opengl.test.junit.jogl.acore.anim;
31import java.lang.reflect.InvocationTargetException;
33import com.jogamp.opengl.GLCapabilities;
35import com.jogamp.newt.opengl.GLWindow;
36import com.jogamp.opengl.util.Animator;
37import com.jogamp.opengl.test.junit.util.NewtTestUtil;
38import com.jogamp.opengl.test.junit.util.GLTestUtil;
39import com.jogamp.opengl.test.junit.util.UITestCase;
40import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
42import org.junit.Assert;
44import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47@FixMethodOrder(MethodSorters.NAME_ASCENDING)
49 static final int width = 400;
50 static final int height = 400;
54 Assert.assertNotNull(glWindow);
57 glWindow.
setSize(width, height);
58 glWindow.
setTitle(
"GLWindow: "+x+
"/"+y);
62 static void pauseAnimator(
final Animator animator,
final boolean pause) {
65 Assert.assertEquals(
true, animator.
isStarted());
66 Assert.assertEquals(
true, animator.
isPaused());
67 Assert.assertEquals(
false, animator.isAnimating());
70 Assert.assertEquals(
true, animator.
isStarted());
71 Assert.assertEquals(
false, animator.
isPaused());
72 Assert.assertEquals(
true, animator.isAnimating());
75 static void stopAnimator(
final Animator animator) {
77 Assert.assertEquals(
false, animator.isStarted());
78 Assert.assertEquals(
false, animator.isPaused());
79 Assert.assertEquals(
false, animator.isAnimating());
87 Assert.assertEquals(
true, animator.
isStarted());
88 Assert.assertEquals(
true, animator.
isPaused());
89 Assert.assertEquals(
false, animator.isAnimating());
92 final GLWindow c1 = createGLWindow(caps, 0, 0, g1);
94 Assert.assertEquals(
true, animator.
isStarted());
95 Assert.assertEquals(
false, animator.
isPaused());
96 Assert.assertEquals(
true, animator.isAnimating());
99 final GLWindow c2 = createGLWindow(caps, c1.
getX()+width,
105 c1.
getY()+height, g3);
115 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
120 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
125 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
128 Thread.sleep(duration/3);
129 }
catch(
final Exception e) {
133 pauseAnimator(animator,
true);
136 Thread.sleep(duration/3);
137 }
catch(
final Exception e) {
141 pauseAnimator(animator,
false);
144 Thread.sleep(duration/3);
145 }
catch(
final Exception e) {
151 stopAnimator(animator);
167 final GLWindow c1 = createGLWindow(caps, 0, 0, g1);
170 Assert.assertEquals(
true, a1.
isStarted());
171 Assert.assertEquals(
false, a1.
isPaused());
172 Assert.assertEquals(
true, a1.isAnimating());
180 Assert.assertEquals(
true, a2.
isStarted());
181 Assert.assertEquals(
false, a2.
isPaused());
182 Assert.assertEquals(
true, a2.isAnimating());
187 final GLWindow c3 = createGLWindow(caps, c1.
getX()+0, c1.
getY()+height, g3);
190 Assert.assertEquals(
true, a3.
isStarted());
191 Assert.assertEquals(
false, a3.
isPaused());
192 Assert.assertEquals(
true, a3.isAnimating());
198 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
203 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
208 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
211 Thread.sleep(duration/3);
212 }
catch(
final Exception e) {
216 pauseAnimator(a1,
true);
217 pauseAnimator(a2,
true);
218 pauseAnimator(a3,
true);
221 Thread.sleep(duration/3);
222 }
catch(
final Exception e) {
226 pauseAnimator(a1,
false);
227 pauseAnimator(a2,
false);
228 pauseAnimator(a3,
false);
231 Thread.sleep(duration/3);
232 }
catch(
final Exception e) {
251 static long duration = 3*500;
253 public static void main(
final String args[]) {
254 for(
int i=0; i<args.length; i++) {
255 if(args[i].equals(
"-time")) {
258 duration = Integer.parseInt(args[i]);
259 }
catch (
final Exception ex) { ex.printStackTrace(); }
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void setTitle(final String title)
final int getX()
Returns the current x position of this window, relative to it's parent.
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 void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
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.
GLWindow createGLWindow(final GLCapabilities caps, final int x, final int y, final GearsES2 gears)
static void main(final String args[])
void test01SyncedOneAnimator()
void test02AsyncEachAnimator()
boolean waitForInit(final boolean initialized)
static boolean waitForContextCreated(final GLAutoDrawable autoDrawable, final boolean created, final Runnable waitAction)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final Window win, final boolean visible, final Runnable waitAction)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
synchronized boolean isStarted()
Indicates whether this animator has been started.
final synchronized boolean pause()
Pauses this animator.
final synchronized boolean resume()
Resumes animation if paused.
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean isPaused()
Indicates whether this animator is started and either manually paused or paused automatically due to ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.