Login  Register

Re: Right method to exit/dispose on linux

Posted by jmaasing on Feb 18, 2014; 6:21pm
URL: https://forum.jogamp.org/Right-method-to-exit-dispose-on-linux-tp4031504p4031647.html

The following works very good for me, the animator will make sure the display callback is called to let me update the display.


public class NewtWindow {

        public static void main(String... args) {
                NewtWindow app = new NewtWindow();
                app.run();
        }

        private void run() {
                final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL4));
                caps.setBackgroundOpaque(true);
                caps.setDoubleBuffered(true);
                GLWindow glWindow = GLWindow.create(caps);
                glWindow.setSize(1024, 768);
                glWindow.setUndecorated(false);
                glWindow.setPointerVisible(true);
                glWindow.setVisible(true);
                glWindow.setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE);

                Animator animator = new Animator(glWindow);
                glWindow.addGLEventListener(new GLEventListener() {
                        @Override
                        public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
                                System.out.println("Reshape <" + width + "," + height + ">");
                        }

                        @Override
                        public void init(GLAutoDrawable drawable) {
                                System.out.println("Init");
                        }

                        @Override
                        public void dispose(GLAutoDrawable drawable) {
                                animator.stop() ;
                                System.out.println("Dispose");
                        }

                        @Override
                        public void display(GLAutoDrawable drawable) {
                                System.out.println("Display");
                        }
                });

                animator.start();

        }
}