Press 1 and see what mouseMove reveals.
animator.isAnimating() == true and after reaching the countdowns end still true but after pause() it should be false. ? :( Then press 1 and 2 in a row and fpsanimator is fine again ???? i am not allowed to pause without user interaction? just via method? Strange. didn"t figure that out yet import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.util.FPSAnimator; public class Example_Animator implements GLEventListener, KeyListener, MouseListener { public static void main(String[] args) { new Example_Animator(); } private GLProfile glp; private GLCapabilities caps; private GLWindow window; private final FPSAnimator animator; private int count; private boolean countdown = false; public Example_Animator() { glp = GLProfile.getDefault(); caps = new GLCapabilities(glp); window = GLWindow.create(caps); animator = new FPSAnimator(window, 60, true); window.addWindowListener(new WindowAdapter() { public void windowDestroyNotify(WindowEvent arg0) { new Thread() { public void run() { if (animator.isStarted()) animator.stop(); System.exit(0); } }.start(); } }); window.addMouseListener(this); window.addKeyListener(this); window.addGLEventListener(this); window.setSize(800, 600); window.setVisible(true); animator.start(); animator.pause(); } public void display(GLAutoDrawable drawable) { System.out.println(animator.isAnimating()); if (animator.isAnimating()) { if (countdown) { System.out.println(count); count--; if (count == 0) { animator.pause(); countdown = false; } } } } public void mouseMoved(MouseEvent e) { System.out.println(animator.isAnimating()); // animator.isAnimating() is still true after the count of 100 ??? } public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_1) { count = 100; animator.resume(); countdown = true; } if (e.getKeyCode() == KeyEvent.VK_2) { animator.pause(); countdown = false; } if (e.getKeyCode() == KeyEvent.VK_ESCAPE) System.exit(0); } public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} public void keyReleased(KeyEvent e) {} public void mouseClicked(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseDragged(MouseEvent e) {} public void mouseWheelMoved(MouseEvent e) {} }
I am a Robot
|
Administrator
|
Please read the documentation:
"In most situations this method blocks until completion, except when called from the animation thread itself or in some cases from an implementation-internal thread like the AWT event queue thread."
Julien Gouesse | Personal blog | Website
|
This post was updated on .
Thanks.
i have got it.... while display is running and changing the animator inside display is a no no. i did not notice that before. It's in the documentation! thx
I am a Robot
|
Administrator
|
You're welcome. However, you should see a change, it will just occur later, it's not immediate.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |