Login  Register

Re: jogl 2

Posted by Xerxes Rånby on May 24, 2012; 11:13am
URL: https://forum.jogamp.org/jogl-2-tp4013001p4013328.html

Try rewrite your code to let the jButton simply toggle animation on and off:

Add a boolean to your code that control if you want to animate your object or not:

private boolean animate=false;

then change the button logic to toggle this boolean:

      jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               //toggle start/stop animation
               animate=!animate;
            }
     });

Then inside your display(GLAutoDrawable drawable) {
 add:

        if(animate)
           rot+=.2%360;