Death by JOGL (pretty sure it's my OpenGL bug!)


I am using JOGL and have a program that displays surfaces. It works well, though there is a large delay at the beginning. Java Swing is supposed to (when all the crunching and groaning ends) open the canvas to the appropriate size of the window, and the way JOGL works, I get a callback when ready to display. This has always worked for me until now, but the first frame does appear to flash twice, there was some problem getting started.

Then at the end of the display method:

public void display(GL gl) {
// lots-o-GL stuff, then…

for (…)
try {
Writepng.snapshot(saveName(), gl);
} catch(Exception e) {
System.out.println(“Error saving png:” + e);

JOGL dies in Writepng.snapshot, right where I try to find the size of the window:

gl.glGetIntegerv(GL.GL_VIEWPORT, view);

An unexpected error has been detected by HotSpot Virtual Machine:

SIGSEGV (0xb) at pc=0x4ec7fd94, pid=6145, tid=1381542832

Java VM: Java HotSpot™ Client VM (1.5.0-beta2-b51 mixed mode)

Problematic frame:

C []

I’m pretty sure it’s not a bug in the JOGL API, it’s probably something stupid I’m doing, so if anyone knows what’s wrong, let me know.
Code looking just like this worked in Java, and I keep searching for a multithreading problem, but since display is the function, and it calls Writepng at the end, I just don’t see how I could be attacking gl multithreaded.


Cancel that…

I’ll leave this posting as a warning to other java programmers. If you don’t allocate an array, it won’t give you a NullPointerException as it would if you were calling java code, it will just crash in the C part of the code. In this case:

int[] view = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, view);