package test; import java.awt.BorderLayout; import javax.media.opengl.*; import javax.swing.*; public class SimpleTest implements GLEventListener { public SimpleTest() { super(); } public void init(GLAutoDrawable drw) { drw.setGL(new DebugGL(drw.getGL())); GL gl = drw.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); } // init public void display(GLAutoDrawable drw) { GL gl = drw.getGL(); gl.glColor3f(1.0F, 0.4F, 0.0F); gl.glBegin(GL.GL_TRIANGLES); gl.glVertex3f(0.0F, 0.0F, 0.0F); gl.glVertex3f(1.0F, 0.0F, 0.0F); gl.glVertex3f(1.0F, 1.0F, 0.0F); gl.glEnd(); } // display public void reshape(GLAutoDrawable drw, int x, int y, int wid, int hite) { } // reshape public void displayChanged(GLAutoDrawable drw, boolean modeCh, boolean devCh) { } // displayChanged public static void main(String[] argv) { GLCapabilities glCaps = new GLCapabilities(); // This line fails with the current (1.1.1.1-rc8 - February 22) build, // but works if GLCanvas is changed to GLJPanel. With the 1.1.0 // release build, it works either way. When it fails, the JFrame, when // first made visible, crashes with an IllegalArgumentException deep // inside the GL class heirarchy. GLCanvas canv = new GLCanvas(glCaps); final JFrame fram = new JFrame("TestFrame"); fram.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fram.setSize(640, 480); fram.getContentPane().add(canv, BorderLayout.CENTER); canv.addGLEventListener(new SimpleTest()); SwingUtilities.invokeLater(new Runnable() { public void run() { fram.setVisible(true); } // run }); } // main } // SimpleTest