Why does this program crash jogl?

Try running this simple program. The code opens a window and draws a cube. Double clicking in the window is supposed to open up a 2nd frame showing an identical cube. Instead, it crashes the VM with an exception and EXCEPTION_ACCESS_VIOLATION from the graphic driver.

Could someone tell me why this doesn’t work?

import java.awt.;
import java.awt.event.
;

import net.java.games.jogl.*;
import net.java.games.jogl.util.GLUT;

public class Simple {
public static void main(String[] args) {new Simple();}

  public Simple() {      
        Frame frame = new Frame();      
        GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
        canvas.addGLEventListener(new CubeRenderer());
        frame.add(canvas);
        frame.setSize(300, 300);
        frame.show();
  }

static class CubeRenderer implements GLEventListener, MouseListener{
public void init(GLDrawable drawable) {
GL gl = drawable.getGL();
gl.glClearColor(0,0,0,0);
drawable.addMouseListener(this);
}

  public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        gl.glViewport(x, y, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(-1,1,-1,1,-1,1);
        gl.glMatrixMode(GL.GL_MODELVIEW);
  }

  public void display(GLDrawable drawable) {      
        GL gl = drawable.getGL();
        GLUT glut = new GLUT();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        gl.glColor3d(1, .25, .75);
        gl.glLoadIdentity();
        glut.glutSolidCube(gl, 1);
  }
  
  public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
  
  public void mouseEntered(MouseEvent e) {}
  public void mouseExited(MouseEvent e) {}
  public void mousePressed(MouseEvent e) { }  
  public void mouseReleased(MouseEvent e) {} 
  // Double Click to launch new window
  public void mouseClicked(MouseEvent e) {System.err.println("Double Clicking ..."); new Simple();}

}
}


ouble Clicking …


Another exception has been detected while we were handling last error.
Dumping information about last error:
ERROR REPORT FILE = hs_err_pid2280.log
PC = 0x69350594
SIGNAL = -1073741819
FUNCTION NAME = DrvSetContext
OFFSET = 0xF0874
LIBRARY NAME = C:\WINDOWS\System32\atioglxx.dll
Please check ERROR REPORT FILE for further information, if there is any.
Good bye.
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x69350594
Function=DrvSetContext+0xF0874
Library=C:\WINDOWS\System32\atioglxx.dll

Current Java thread:
at net.java.games.jogl.impl.windows.WGL.wglCreateContext(Native Method)
at net.java.games.jogl.impl.windows.WindowsGLContext.choosePixelFormatAndCreateContext(WindowsGLContext.java:296)
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.create(WindowsOnscreenGLContext.java:204)
at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(WindowsGLContext.java:117)
- locked <0x100585f8> (a net.java.games.jogl.impl.windows.WindowsOnscreenGLContext)
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:110)
- locked <0x100585f8> (a net.java.games.jogl.impl.windows.WindowsOnscreenGLContext)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)
- locked <0x100585f8> (a net.java.games.jogl.impl.windows.WindowsOnscreenGLContext)
at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:105)
at java.awt.Component.setBounds(Unknown Source)
at java.awt.BorderLayout.layoutContainer(Unknown Source)
- locked <0x1050dee8> (a java.awt.Component$AWTTreeLock)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
- locked <0x1050dee8> (a java.awt.Component$AWTTreeLock)
at java.awt.Window.show(Unknown Source)
at JOGLstructuredArguments.Simple.(Simple.java:18)
at JOGLstructuredArguments.Simple$CubeRenderer.mouseClicked(Simple.java:53)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Dynamic libraries:
0x00400000 - 0x00407000 C:\Program Files\Java\j2re1.4.2\bin\javaw.exe
0x77F50000 - 0x77FF7000 C:\WINDOWS\System32\ntdll.dll
0x77E60000 - 0x77F46000 C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E5D000 C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78086000 C:\WINDOWS\system32\RPCRT4.dll
0x77D40000 - 0x77DC6000 C:\WINDOWS\system32\USER32.dll
0x77C70000 - 0x77CB0000 C:\WINDOWS\system32\GDI32.dll
0x77C10000 - 0x77C63000 C:\WINDOWS\system32\MSVCRT.dll
0x629C0000 - 0x629C8000 C:\WINDOWS\System32\LPK.DLL
0x72FA0000 - 0x72FFA000 C:\WINDOWS\System32\USP10.dll
0x08000000 - 0x08136000 C:\Program Files\Java\j2re1.4.2\bin\client\jvm.dll
0x76B40000 - 0x76B6C000 C:\WINDOWS\System32\WINMM.dll
0x10000000 - 0x10007000 C:\Program Files\Java\j2re1.4.2\bin\hpi.dll
0x00830000 - 0x0083E000 C:\Program Files\Java\j2re1.4.2\bin\verify.dll
0x00840000 - 0x00858000 C:\Program Files\Java\j2re1.4.2\bin\java.dll
0x00860000 - 0x0086D000 C:\Program Files\Java\j2re1.4.2\bin\zip.dll
0x02C50000 - 0x02D5A000 C:\Program Files\Java\j2re1.4.2\bin\awt.dll
0x73000000 - 0x73023000 C:\WINDOWS\System32\WINSPOOL.DRV
0x76390000 - 0x763AC000 C:\WINDOWS\System32\IMM32.dll
0x771B0000 - 0x772D1000 C:\WINDOWS\system32\ole32.dll
0x5AD70000 - 0x5ADA4000 C:\WINDOWS\System32\uxtheme.dll
0x02DD0000 - 0x02E20000 C:\Program Files\Java\j2re1.4.2\bin\fontmanager.dll
0x51000000 - 0x51047000 C:\WINDOWS\System32\ddraw.dll
0x73BC0000 - 0x73BC6000 C:\WINDOWS\System32\DCIMAN32.dll
0x5C000000 - 0x5C0C8000 C:\WINDOWS\System32\D3DIM700.DLL
0x74720000 - 0x74764000 C:\WINDOWS\System32\MSCTF.dll
0x07100000 - 0x07105000 C:\Program Files\Java\j2re1.4.2\bin\jawt.dll
0x07110000 - 0x07186000 C:\Program Files\Java\j2re1.4.2\bin\jogl.dll
0x5ED00000 - 0x5EDC6000 C:\WINDOWS\System32\OPENGL32.dll
0x68B20000 - 0x68B3E000 C:\WINDOWS\System32\GLU32.dll
0x69000000 - 0x694AC000 C:\WINDOWS\System32\atioglxx.dll
0x67590000 - 0x67597000 C:\Program Files\Groove Networks\Groove\Bin\GrooveHooks.DLL
0x76C90000 - 0x76CB2000 C:\WINDOWS\system32\imagehlp.dll
0x6D510000 - 0x6D58D000 C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C07000 C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000 C:\WINDOWS\System32\PSAPI.DLL

Heap at VM Abort:
Heap
def new generation total 576K, used 307K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 57% used [0x10010000, 0x10059cb8, 0x10090000)
from space 64K, 19% used [0x100a0000, 0x100a3310, 0x100b0000)
to space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
tenured generation total 1408K, used 210K [0x104f0000, 0x10650000, 0x14010000)
the space 1408K, 14% used [0x104f0000, 0x10524998, 0x10524a00, 0x10650000)
compacting perm gen total 4096K, used 3991K [0x14010000, 0x14410000, 0x18010000)
the space 4096K, 97% used [0x14010000, 0x143f5e40, 0x143f6000, 0x14410000)

Local Time = Thu Sep 18 20:36:32 2003
Elapsed Time = 2

The exception above was detected in native code outside the VM

Java VM: Java HotSpot™ Client VM (1.4.2-b28 mixed mode)

An error report file has been saved as hs_err_pid2280.log.

Please refer to the file for further information.

This code works just fine on my gf2mx.

Also crashes on this system with an ATI Rage 128. It looks like the original poster also has an ATI card as I’ve got a similar dll that’s failing.

Double Clicking …

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x691304E7
Function=DrvSwapBuffers+0xABFF7
Library=C:\WINDOWS\System32\atioglaa.dll

Having owned a rage 128 I can say with some authority that it sucks. Make sure you have the latest drivers. Beyond that I don’t know what to tell you.

I’m not too worried about this card. This is my work pc and not my 3D dev machine. And yes, it sucks.

Outside of the more recent 9000 series of ATI hardware - you’re probably going to see all sorts of driver foolishness. For some reason it wasn’t until recently that ATI took ‘conformant’ driver writing seriously.

[quote]Outside of the more recent 9000 series of ATI hardware - you’re probably going to see all sorts of driver foolishness. For some reason it wasn’t until recently that ATI took ‘conformant’ driver writing seriously.
[/quote]
That’s true, it wasn’t until Artx was brought under ATi that we customers started to appreciate solid hardware coupled with robust drivers and support.
Look at Half-Life 2 performance on ATi R3xx serie of hardware; even the 9600 Pro puts Nvidia’s latest born to shame.
Of course the picture is painted differently when games resort to older APIs to render scenes (Dx8.1 and lower), but when it comes to DX9 and recent, even older pixel/vertex shaders, ATi got the upper hand.
And it’s not John Carmack who’ll disagree with me on that one.
/me hugs his Radeon 9500 Pro at 355/330 :stuck_out_tongue: