import javax.swing.*; import java.awt.*; import net.java.games.jogl.*; import net.java.games.jogl.util.*; /** * This class demonstrates that Automatic detection * of ATI Video Cards for ATI WORKAROUND work really * fine on first GLCanvas created but leads to * NullPointerException of DummyGL (in best cases) * and sometimes to JVM Crash with ACCESS_VIOLATION_EXCEPTION * raised from my atioglxx.dll. This is with my actual (just be4 lattest) * ATI drivers for my RADEON 9700. *
* Uncomment ATI_WORKAROUND System variable setting to show the Bug. * If not commented you can see it works properly. * * @author sebastien Wirth alias Fmpc77 */ public class TestMulti { public TestMulti() { } /** * @param args the command line arguments */ void go(){ /*############ Comment this line *############ to c Automatic ATI Detection Failure on 2nd GLCanvas */ System.setProperty("ATI_WORKAROUND", "true"); ////////////////////////////////////////////// // FIRST GLCANVAS FRAMEWORK ////////////////////////////////////////////// JFrame window1 = new JFrame("Window1"); window1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // window1.setResizable(false); GLCapabilities cap1 = new GLCapabilities(); // cap.setSampleBuffers(true); // cap.setNumSamples(4); GLCanvas canvas1 = GLDrawableFactory.getFactory().createGLCanvas( cap1 ); canvas1.setSize(320,180); canvas1.addGLEventListener( new SimpleGLEventListener("SimpleListener 1") ); Animator animator1 = new Animator(canvas1); window1.getContentPane().add(canvas1); window1.pack(); window1.setVisible(true); animator1.start(); ////////////////////////////////////////////// // SECOND GLCANVAS ////////////////////////////////////////////// JFrame window2 = new JFrame("Window2"); window2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GLCapabilities cap2 = new GLCapabilities(); GLCanvas canvas2 = GLDrawableFactory.getFactory().createGLCanvas( cap2 ); canvas2.setSize(320,180); canvas2.addGLEventListener( new SimpleGLEventListener("SimpleListener 2") ); Animator animator2 = new Animator(canvas2); window2.getContentPane().add(canvas2); window2.pack(); window2.setVisible(true); animator2.start(); } public static void main(String[] args) { new TestMulti().go(); } class SimpleGLEventListener implements GLEventListener{ private String name; private GLUT glut = new GLUT(); SimpleGLEventListener(String inName){ name = inName; } public void display(net.java.games.jogl.GLDrawable gLDrawable) { gLDrawable.getGL().glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gLDrawable.getGL().glClear(GL.GL_COLOR_BUFFER_BIT); gLDrawable.getGL().glColor3f(1f, 0f,0f); gLDrawable.getGL().glWindowPos2f(10f, 10f); glut.glutBitmapString(gLDrawable.getGL(), GLUT.BITMAP_9_BY_15, "Hi I am "+name); } public void displayChanged(net.java.games.jogl.GLDrawable gLDrawable, boolean param, boolean param2) { } public void init(net.java.games.jogl.GLDrawable gLDrawable) { } public void reshape(net.java.games.jogl.GLDrawable gLDrawable, int param, int param2, int param3, int param4) { } } }