package rob.jogltest; import java.awt.Dimension; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing.JFrame; import net.java.games.jogl.Animator; import net.java.games.jogl.GL; import net.java.games.jogl.GLCanvas; import net.java.games.jogl.GLCapabilities; import net.java.games.jogl.GLDrawable; import net.java.games.jogl.GLDrawableFactory; import net.java.games.jogl.GLEventListener; public class Test implements GLEventListener, WindowListener { private JFrame jf; private GLCanvas glCanvas; private Animator animator; public void go() { jf = new JFrame(); GLDrawableFactory fac = GLDrawableFactory.getFactory(); GLCapabilities cap = new GLCapabilities(); glCanvas = fac.createGLCanvas(cap); glCanvas.addGLEventListener(this); glCanvas.setPreferredSize(new Dimension(640,480)); jf.getContentPane().add(glCanvas); jf.pack(); jf.addWindowListener(this); jf.setVisible(true); startRendering(); } private void startRendering() { animator = new Animator(glCanvas); animator.start(); System.out.println("Animator started"); } private void stopRendering() { animator.stop(); System.out.println("Animator stopped"); } public void displayChanged( GLDrawable drawable, boolean modeChanged, boolean deviceChanged) { GL gl = drawable.getGL(); } public void reshape(GLDrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getGL(); } public void display(GLDrawable drawable) { GL gl = drawable.getGL(); System.out.println("display >"); try { Thread.sleep(50); } catch (InterruptedException ie) { } System.out.println("display <"); } public void init(GLDrawable drawable) { GL gl = drawable.getGL(); } public static void main(String[] args) { Test t = new Test(); t.go(); } public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { //System.exit(0); } public void windowClosing(WindowEvent e) { stopRendering(); jf.setVisible(false); jf.dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }