28package com.jogamp.opengl.test.junit.jogl.acore.anim;
30import java.awt.BorderLayout;
31import java.awt.Dimension;
33import com.jogamp.common.util.InterruptSource;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLEventListener;
37import com.jogamp.opengl.GLProfile;
38import com.jogamp.opengl.awt.GLCanvas;
39import javax.swing.SwingUtilities;
41import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
42import com.jogamp.opengl.util.Animator;
52@SuppressWarnings(
"serial")
56 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
58 setMinimumSize(
new Dimension(640, 480));
59 getContentPane().setLayout(
new BorderLayout());
61 getContentPane().add(panel, BorderLayout.CENTER);
69 long startTime = 0, lastTime = 0;
74 startTime = System.currentTimeMillis();
83 final long time = System.currentTimeMillis();
84 if (animator.isAnimating() && step * 2000 < time - startTime) {
85 final long td = time - lastTime;
88 System.out.println(Thread.currentThread().getName()+
": #"+step+
" "+td+
" ms: animator.pause(): paused "+animator);
89 new InterruptSource.Thread() {
92 java.lang.Thread.sleep(1000);
93 }
catch (
final InterruptedException e) {
96 SwingUtilities.invokeLater(
new Runnable() {
99 final long td = System.currentTimeMillis() - lastTime;
102 System.out.println(java.lang.Thread.currentThread().getName()+
": #"+step+
" "+td+
" ms: animator.resume(): animating "+animator);
104 System.out.println(java.lang.Thread.currentThread().getName()+
": #"+step+
" "+td+
" ms: animator.resume(): Ooops - not paused! - animating "+animator);
114 public void reshape(
final GLAutoDrawable glad,
final int i,
final int i1,
final int i2,
final int i3) {
119 System.out.println(
"animator.start()");
122 public static void main(
final String args[]) {
123 java.awt.EventQueue.invokeLater(
new Runnable() {
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getMaxProgrammable(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the programmable shader pipeline.
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.
Manual test case to validate Animator pause/resume on AWT-EDT.
Bug898AnimatorFromEDTAWT()
static void main(final String args[])
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
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 ...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.