import java.awt.event.*; import javax.swing.*; import net.java.games.jogl.*; /** * A simple test that Jogl is working. *

* Nothing is displayed. The window should come up normally and when the window * is closed, it should exit normally. * * @author Sean Sylvis */ public class JoglSimpleTest implements GLEventListener { private JFrame mFrame; private Animator mAnimator; /** * Constructs a JoglSimpleTest object. */ public JoglSimpleTest() { // Get GL drawing context GLCanvas vCanvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); vCanvas.addGLEventListener(this); // Create AWT frame mFrame = new JFrame("Simple Test"); mFrame.setSize(600, 400); mFrame.getContentPane().add(vCanvas); // Create animation loop object mAnimator = new Animator(vCanvas); // Define window-closing event mFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close(); } }); mFrame.show(); mAnimator.start(); } // inherited comment public void init(GLDrawable pDrawable) { GL gl = pDrawable.getGL(); // Set color buffer clear color gl.glClearColor(1, 1, 1, 0); } // inherited comment public void reshape( GLDrawable pDrawable, int x, int y, int pWidth, int pHeight) { } // inherited comment public void display(GLDrawable pDrawable) { GL gl = pDrawable.getGL(); // Clear buffers gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } // inherited comment public void displayChanged( GLDrawable drawable, boolean modeChanged, boolean deviceChanged) { } /** * */ private void close() { mAnimator.stop(); mFrame.dispose(); } /** * @param pArguments */ public static void main(String[] pArguments) { new JoglSimpleTest(); } }